# 'top' never adds up

## TwistedKestrel

I wasn't sure where to post this one, so Hardware seems as a good of a place as any ... anyway, whenever I run the top command on my system, the summary of the CPU states at the top of the screen *never* match up with the list of processes ... why? Is there any way to change this, or any better alternatives?

----------

## savage

I suspect the reason that top doesn't add up is simple rounding errors.  I recently wrote a load monitor for use in a cluster and I was having the same kind of problems (percentages of use, etc. not adding up) until I increased the number of decimal points a fair amount.  It is not a problem with your system / the kernel - just a rounding issue.

i.e. 1.998 gets interpreted as 2.0

----------

## TwistedKestrel

That's definitely part of it ... but still, when I turn on no-idle, and it only shows one process at 0.9 %, yet the summary says something like 90% user, I think there is more to it than rounding errors.

----------

## AmunRa

the numbers don't 'add up' for a number of reasons. Firstly the actual act of monitoring the processes takes up some CPU - a good example of the scientific principle that observing something changes it  :Smile:  In addition, top only checks every x seconds, otherwise it would take up a large chunk of the processor. Therefore in actual fact for a few milli/microseconds top is probably taking up most of your CPU time, and so the resulting numbers won't add up. You'll notice this if you manually refresh top (by pressing space) quite quickly - your usage will shoot up. Top is notoriously system intensive, due to it's continual nature - leaving it running on a busy system is not a good idea  :Smile:  The occasional 'ps -efa' or 'w' is much more system friendly...

Secondly, as previously mentioned, there are rounding errors introduced.

Regards

Dave

----------

## BradN

That still doesn't explain a 89% discrepancy... it shouldn't be off more than a couple percent really.

Something weird is probably happening in the kernel or something... I don't know.

----------

## Cyclone

Are you running ACPI in your kernel?  I know from personal experience that at least in patches as recent as 12/12/2002 that ACPI makes my system load skyrocket.

----------

