Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Sep 2006 20:27:46 +1000 (EST)
From:      Ian Smith <smithi@nimnet.asn.au>
To:        Dan Nelson <dnelson@allantgroup.com>
Cc:        questions@freebsd.org, "Tamouh H." <hakmi@rogers.com>, Giorgos Keramidas <keramida@freebsd.org>
Subject:   Re: Top not showing cpu usage even remotely accurately
Message-ID:  <Pine.BSF.3.96.1060915193930.29169A-100000@gaia.nimnet.asn.au>
In-Reply-To: <20060914142023.GB91336@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 14 Sep 2006, Dan Nelson wrote:

 > In the last episode (Sep 14), Ian Smith said:
 > [..]>
 > > 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.

Ah, thanks for a solid boot up the learning curve, Dan.  Took me a while
to connect kse(2) as it's not referred to as such in ldd output, but I
kept digging. For sure xmms and moz are 2 that have gone mad 'quietly'.

I assume then that libkse is what the three multi-thread programs I'm
running (xmms, mozilla-bin and mysqld) are now using, where for each
of them `ldd $program | grep thr` shows
 libpthread.so.1 => /usr/lib/libpthread.so.1

So can/should I set in (a new) /etc/libmap.conf generally:
     libpthread.so.1         libthr.so.1
     libpthread.so           libthr.so

or would it be better to just target these specific programs, eg:

[/usr/X11R6/lib/mozilla/mozilla-bin/]  # assuming loaded with full path?
     libpthread.so.1         libthr.so.1
     libpthread.so           libthr.so

Are there any likely downsides to using libthr instead?  Esp. mysqld?

I've already found that stopping those three processes lifts shown idle
to ~95%, but then I also note that ldd other things - including kdeinit
ie all main KDE processes - refer to libpthread.so.1 too, but only the
above 3 ever seem to appear in state 'kserel' (This is all new to me :) 

Cheers, Ian




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.1060915193930.29169A-100000>