111

I am trying to understand what %CPU means when I run top.

I am seeing %CPU for my application at "400" or "500" most of the time.

Does anyone know what this means?

19080 david 20 0 27.9g 24g 12m S 400 19.7 382:31.81 paper_client

lscpu gives me this output:

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                32
On-line CPU(s) list:   0-31
Thread(s) per core:    2
Core(s) per socket:    8
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 45
Stepping:              7
CPU MHz:               2599.928
BogoMIPS:              5199.94
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              20480K
NUMA node0 CPU(s):     0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
NUMA node1 CPU(s):     1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31
david
  • 2,187
  • 7
  • 25
  • 31

2 Answers2

174

%CPU -- CPU Usage : The percentage of your CPU that is being used by the process. By default, top displays this as a percentage of a single CPU. On multi-core systems, you can have percentages that are greater than 100%. For example, if 3 cores are at 60% use, top will show a CPU use of 180%. See here for more information. You can toggle this behavior by hitting Shifti while top is running to show the overall percentage of available CPUs in use.

Source for above quote.

You can use htop instead.


To answer your question about how many cores and virtual cores you have:

According to your lscpu output:

  • You have 32 cores (CPU(s)) in total.
  • You have 2 physical sockets (Socket(s)), each contains 1 physical processor.
  • Each processor of yours has 8 physical cores (Core(s) per socket) inside, which means you have 8 * 2 = 16 real cores.
  • Each real core can have 2 threads (Thread(s) per core), which means you have real cores * threads = 16 * 2 = 32 cores in total.

So you have 32 virtual cores from 16 real cores.

Also see this, this and this link.

polym
  • 10,852
  • 1
    Thanks for suggestion. How can I find out how many cores and virtual cores I have? If I press 1 while top is running I can see from CPU0 - CPU31. – david Jul 18 '14 at 08:43
  • Use these commands: http://superuser.com/a/178497/333431. – polym Jul 18 '14 at 08:46
  • Ok I got number of CPU cores per CPU as 8 and I got number of physical CPUs as 2. – david Jul 18 '14 at 08:52
  • 1
    lscpu is easier in most modern distros – Dani_l Jul 18 '14 at 08:57
  • @user2809564 Have a look at my updated answer. Don't forget to accept and upvote answers that helped you understand/fix a problem. That's how stackexchange works :)! – polym Jul 18 '14 at 09:55
  • If I care about latency, do I really treat all the cores same? If a program requires two threads communicate with each other, but if 1 thread is running on a core connected to one socket, and another thread is running on a core connected to the 2nd socket, i believe the latency would be high? – endless Jun 11 '18 at 01:05
  • "So you have 16 virtual cores and 16 real cores." That sentence seems misleading. It seems to make me wonder whether there are virtual and real threads? Shouldn't it be "So you have 32 virtual cores from 16 real cores."? – kaartic Apr 01 '19 at 09:36
7

It means you have a lot of cores. One core at max is 100%. So the highest it can be is number_of_cores × 100%.

You may want to look at why your app it as 400%.