Multiple Processors and Load Average

The following information shows that there are in total 4 Processors on this machine:

$ grep -i name /proc/cpuinfo
model name      : Dual-Core AMD Opteron(tm) Processor 2218
model name      : Dual-Core AMD Opteron(tm) Processor 2218
model name      : Dual-Core AMD Opteron(tm) Processor 2218
model name      : Dual-Core AMD Opteron(tm) Processor 2218

Does the command top reveal this information clearly?

$ top -b -n 1 | head
top - 08:52:40 up 1516 days, 16:57,  2 users,  load average: 1.12, 1.26, 1.32
Tasks:  97 total,   1 running,  96 sleeping,   0 stopped,   0 zombie
Cpu(s): 18.2%us,  3.4%sy,  0.0%ni, 77.9%id,  0.3%wa,  0.0%hi,  0.3%si,  0.0%st
Mem:  32967244k total, 32844284k used,   122960k free,   216240k buffers
Swap:  2096472k total,   105872k used,  1990600k free,  2005636k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
25437 root      23   0 22.7g  22g 9272 S 142.9 70.6  42140:15 java

Besides, the load average is:

1.12, 1.26, 1.32

over 1 which means over 100% CPU utilization. But what I understand is if there are 4 processors then the value of 1 would mean only 25% CPU utilization in total. Is this correct?

Next, the top command shows that the following java process is utilizing 142.9% of the CPU resource:

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
25437 root      23   0 22.7g  22g 9272 S 142.9 70.6  42140:15 java

Is this value relative to the total capacity of the CPU (with all its 4 processors)?

Can you please help me make it clear to myself what those things (4 processors, load average, 142.9 %CPU for Java) are showing exactly? How do they relate to each other?

"Load average" in top is actually the run queue average length.
Over 1 means on average things are waiting on the cpu, below 1 means on average no-one has to wait. Don't confuse this with %cpu - it's not like that.

The bold summary line show percentages should always be across all the cores, but can get confused if you have the wrong version of top, so always add them up to check you get 100 the first time you use top on a new machine to check this.

As for process %cpu, that depends on your version of top - if it's compiled for your arcihtecture properly, it understands and the % is how much of one CPU is beign used (so more than 100% would require multithreading across multiple cores).

To complicate matters further, a system running at 100% cpu might not be terrible if your shceduler is beign smart - it could well be that you've got a bunch of low priority things in the background that get a bunch of work done while the system is idel, then throtle back when you need it - ie sitting at 100% you might still find that your CPU hungry command you want to run goes just fine and the cpu load happily stays at 100% during and after. It's often a waste of time to monitor CPU percentages overall.
Better is to look at:

  • overall wait % ("wa") - you don't want that to get very high or it indicates something is thrashing in swap or disk.
  • run queue length

In your java example:

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
25437 root      23   0 22.7g  22g 9272 S 142.9 70.6  42140:15 java

Its saying that you have a Priority 23 task, (lower numbers get priority on CPU time) using 70.6% of your free memory and 142.9% of one CPU (ie it's multithreaded and is using about 1.5 Cores).

1 Like