Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Oct 2005 09:29:57 +0200
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, Andre Oppermann <andre@FreeBSD.org>, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/usr.bin/vmstat vmstat.c src/usr.bin/w w.c 
Message-ID:  <67214.1129620597@critter.freebsd.dk>
In-Reply-To: Your message of "Tue, 18 Oct 2005 15:04:54 %2B1000." <20051018135821.L93164@delplex.bde.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20051018135821.L93164@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@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.



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