Top not showing cpu usage even remotely accurately

Dan Nelson dnelson at allantgroup.com
Thu Sep 14 07:20:26 PDT 2006


In the last episode (Sep 14), Ian Smith said:
> I still can't fathom what top tells me on a UP 5.5-STABLE system (300MHz
> Celeron if speed's relevant).  I initiated this thread (weeks ago :) re
> seeing 0.0% idle (as expected) during buildworld but not seeing anything
> add up to anything like 100%, including S)ystem processes, in top. 
[..]>
> However that doesn't explain this typical top view when the system is
> quiescent or nearly so, as it mostly is, with only 5-minutely crons and
> 11-minutely entropy runs and the odd sendmail to be seen in lastcomm: 
> 
> last pid: 18500;  load averages:  0.01,  0.08,  0.06    up 5+08:40:33 17:30:30
> 136 processes: 3 running, 110 sleeping, 23 waiting
> CPU states:  5.7% user,  0.0% nice,  6.3% system,  0.0% interrupt, 88.0% idle
> Mem: 73M Active, 18M Inact, 46M Wired, 8108K Cache, 25M Buf, 2572K Free
> Swap: 384M Total, 106M Used, 278M Free, 27% Inuse
> 
>   PID USERNAME PRI NICE   SIZE    RES STATE    TIME   WCPU    CPU COMMAND
>    11 root     171   52     0K     8K RUN    102.3H 86.82% 86.82% idle
>   743 smithi    96    0 26616K  2908K select 156:40  1.03%  1.03% kdeinit
>   708 smithi    96    0 34140K 15024K select 223:05  0.63%  0.63% Xorg
>   644 root      96    0  1244K   244K select  30:19  0.05%  0.05% moused
>   775 smithi    20    0 11524K  1028K kserel 319:17  0.00%  0.00% xmms

> It never shows more than about 90% idle, whereas a 0.01 shorter term
> load average should indicate more like 99% idle, shouldn't it?  97-99%,
> sometimes 100% idle was what FreeBSD 4.5-R used to tell me with the same
> workload in around the same memory use, but maybe 4.5 was optimistic .. 

I would guess that maybe xmms (or some other threaded app) is your
hidden CPU consumer.  The kernel does not calculate %CPU correctly for
libkse-threaded programs, and they usually show up as 0% all the time. 
The TIME column does update correctly, though.  If you switch to libthr
with libmap.conf, you'll get accurate threaded %CPU reporting.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list