tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: getrusage() problems with user vs. system time reporting



On Fri, Oct 28, 2011 at 03:54:57PM -0700, Greg A. Woods wrote:
> > 
> > If you are willing to take the cost of getting the timestamp (in
> > some units) on every kernel entry/exit (as well as the process switch)
> > then the time in usr/sys can be added to the clock tick counts and
> > used when the actual execution time is split.
> > (Doing it that way means the units don't have to be THAT accurate)
> 
> Hmmm.... if we could save the current time on every kernel entry, and
> then increment a new "l_systime" variable with the elapsed time on every
> return to user mode, and of course use the same clock as is used for
> l_rtime (i.e. binuptime()), then the only wild-card variable left is
> interrupt time.

There is an kernel option in i386 (and maybe amd64) to do some
per-syscall stats. One of those counts 'time in syscall' and IIRC
could easily be used to weight the tick counts so that getrusage
gives more accurate times.

The problem is that getting an accurate timestamp is relatively
expensive. It has been almost the dominant part of process switch.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index