Why does the unix command "top" show %CPU values over 1000
search cancel

Why does the unix command "top" show %CPU values over 1000

book

Article ID: 296221

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

The CPU% is spiking tp than 1000 when viewed with the linux top command.
 
[gpadmin@sdw1 ~]$ top
top - 07:21:55 up 15 days, 9:04, 4 users, load average: 16.90, 11.44, 6.19
Tasks: 3008 total, 8 running, 3000 sleeping, 0 stopped, 0 zombie
%Cpu(s): 10.0 us, 2.9 sy, 0.0 ni, 87.0 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st
KiB Mem : 15834599+total, 61439988 free, 56469892 used, 14655500+buff/cache 
KiB Swap: 16778236 total, 16682748 free, 95488 used. 77219097+avail Mem 
PID    USER    PR NI VIRT  RES  SHR   S %CPU %MEM TIME+    COMMAND
390662 gpadmin 20 0  23.0g 8.6g 14020 S 1483 0.6  83:51.94 /usr/lib/jvm/jre/bin/java -Dsun.misc.URLClassPath.disableJarChecking=true -Xmx8g -Xms4+


Environment

OS: linux

Resolution

The reason for this is the  %CPU value is the sum of all cores on the machine, so it can be equal to the number of CPUs multiplied by 100%. In multi-core/multi-CPU environment the top command is working in Irix mode. Press ( SHIFT i )to change to Solaris mode.
In Solaris mode %CPU is the Irix value divided by the number of CPUs.

From the man page of top:

%CPU  --  CPU Usage
           The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.           In a true SMP environment, if a process is multi-threaded and top is not operating in Threads mode, amounts greater than 100% may be reported.  You toggle Threads mode with the `H' interactive command.
           Also for multi-processor environments, if Irix mode is Off, top will operate in Solaris mode where a task's cpu usage will be divided by the total number of CPUs.  You toggle Irix/Solaris modes with the `I' interactive command.