top showing incorrect CPU and WCPU on amd64?

Laszlo Vitos vitos.laszlo at gmail.com
Tue Jun 7 10:55:58 GMT 2005


On Saturday 04 June 2005 09:34, Bruce Evans wrote:
> On Fri, 3 Jun 2005, Laszlo Vitos wrote:
> > I observed a strange behavior of top on FreeBSD 5.4-RELEASE on AMD64. It
> > seems like the CPU and WCPU columns in top are an average over the
> > running time of a process. A small test program confirmed this. It sleeps
> > for 2 seconds, then goes over a few iterations of: hogs the cpu in a
> > loop, then sleeps again for a few seconds.
> > The result: CPU and WCPU never reach 100%, nor 0%, they are
> > growing/shrinking in small increments during the process' run time,
> > depending on whether the process is sleeping or looping.
> > Attached is the test program. Can anyone confirm whether this is the
> > expected behavior (and if so, why?)?
>
> No test program is attached :-).

Yes, sorry about that, I don't know why it did not go through.

>
> I think this is the expected beviour.  CPU is a long-term average.  Thus
> if a process runs for half the time and sleeps for half the time, its CPU
> will be about 50%.  It won't be exactly 50% since more weight is given
> to recent history.  WCPU is mostly bogus.  It is an attempt to undo the
> weighting but not enough history is kept to do this correctly and the
> history which is used is close to being garbage.

In the meantime I dug into the sched_* sources a bit and realised that indeed, 
that is the case. Sorry that I didn't look first, but it did not cross my 
mind that this is actually what the expected behaviour supposed to be.
I guess there were a few flame wars about this in the past :)

Anyway, thanks for the info, 
laca


More information about the freebsd-amd64 mailing list