cvs commit: src/usr.bin/vmstat vmstat.c src/usr.bin/w w.c

Poul-Henning Kamp phk at phk.freebsd.dk
Tue Oct 18 00:30:02 PDT 2005


In message <20051018135821.L93164 at delplex.bde.org>, Bruce Evans writes:

>This is bogus, and it breaks vmstat some more in the dead kernel case.
>
>In the live kernel case, clock_gettime() returns the time since an
>unspecified point in the past.  It is still necessary to subtract the
>boottime, one measured by the same clock, especially under systems
>like FreeBSD where the "unspecified point in the past" is undocumented.

The unspecified point in the past is actually the exact time the kernel
booted and therefore clock_gettime(CLOCK_MONOTONIC) does the right thing
for a running kernel.

>I don't know of any good way to determine the uptime of a dead kernel
>now.

It is available in an internal variable in the timecounter code.  If
desired it can be exported to a visible variable once per second.

>The death time for a dead kernel should be saved in a variable near its
>boottime variable so that utilities like vmstat can determine it easily.

That's another option.

Let me know which is preferable.

>For live kernels, subtracting the boot time from the current _real_
>time using difftime() is the correct method.

Actually it isn't, but it comes close.  CLOCK_MONOTONIC is the true
elapsed time since boot, whereas boottime is our retrospective UTC
estimate of that moment.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the cvs-src mailing list