Linux – Why does top report the incorrect CPU usage

cpulinuxtop

I have a machine with Intel(R) Xeon(R) CPU E5520 visible as 16 logical cores (8 with HT). If I run something to eat CPU time (single threaded) top correctly reports 100% CPU usage for the process but only around 3-4% total usage.

Cpu(s):  3.6%us,  0.0%sy,  0.0%ni, 96.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.1%st

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1567 www       20   0 65632   84    4 R  100  0.0   0:05.96 burnMMX

Surely the reported usage should be ~6.25% (1 of 16 cores).

  • Is it incorrect because it's a virtual machine?
  • How could I calculate a correct value?

Best Answer

top in the summary reports usage relative to the CPU with all cores added up. On the other hand, when you look in the list of processes, top reports percent referenced to one core (real or HT). Try running a process with 4 threads that can eat up 4 CPU cores, you will find it using 400% CPU.

I can't tell why, but that's how top works on all Linux system I've seen.

Related Question