Linux 'top' utility wildly inaccurate (more so for multi-CPU/core hardware)?

4

After using top for long time, albeit basically, I have grown to distrust its % CPU column reports. I have an 8-core (quad core Intel i7 920 with hyperthreading) hardware, and see some wild numbers when running a process that should not use more than 5% overall. top happily reports 50%, and I suspect it is not so.

My question is, is it a known fact that it's inaccurate when several CPUs/cores are present?

I used mpstat from the sysstat package, and its showings are much more conservative, certainly within my expectations. I did press 1 for top to switch it to show all the core and us/sy/io stats, but the numbers are substantially higher than with mpstat...

I know that my expectations could be unfounded as well, but my gut feeling tells me top is wrong!

The reason I need to know is because the process I am monitoring only guarantees quality of service with CPU usage "less than 80%" (however vague that sounds), and I need to know how much headroom I have left. It's a streaming server.

amn

Posted 2010-05-01T21:56:13.817

Reputation: 1 622

What CPU usage number in top do you talk about? Single or SMP mode? – Benjamin Bannier – 2010-05-01T21:58:43.157

Both single and SMP report a total that is about twice as high as numbers reported by mpstat. – amn – 2010-05-02T23:14:00.390

Try to install htop. That is is a better version (in my opinion) of top. See what results you get there first. – Waxhead – 2011-12-11T22:53:00.397

Answers

5

Actually you can run top in interactive mode by pressing 'I' and it normalizes the %CPU time by dividing by the total number of CPUs.

Mirza Basim Baig

Posted 2010-05-01T21:56:13.817

Reputation: 51

4

My guess is that a full load on your system would be 800% (100% for each core)

stevenrjanssens

Posted 2010-05-01T21:56:13.817

Reputation: 749

Well, isn't 800% a mathematical impossibility or something :-) That's sort of what it boils down to - wouldn't it be better for 'top' to adjust its reports so that 100% is 100% of the entire CPU array usage space? So, currently, my 50% reported have to be divided by 8 to get a more meaningful number, right? – amn – 2010-05-02T11:23:52.550

Although 800% seems silly, it makes it obvious that multiple cores are being used. I think it's a reasonable kludge when you don't have a distinct list of CPU utilization per core. Scaling the measurement to be within 100% wouldn't tell the user if a process was multi-core or not. – Neil – 2011-05-12T16:30:38.367