Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jun 2005 13:55:53 +0300
From:      Laszlo Vitos <vitos.laszlo@gmail.com>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        freebsd-amd64@freebsd.org
Subject:   Re: top showing incorrect CPU and WCPU on amd64?
Message-ID:  <200506071355.53607.vitos.laszlo@gmail.com>
In-Reply-To: <20050604162348.V5146@delplex.bde.org>
References:  <200506030943.40215.vitos.laszlo@gmail.com> <20050604162348.V5146@delplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506071355.53607.vitos.laszlo>