From owner-cvs-all@FreeBSD.ORG Tue Oct 18 07:30:02 2005 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2147216A41F; Tue, 18 Oct 2005 07:30:02 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id 68E8A43D48; Tue, 18 Oct 2005 07:30:01 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.48.2]) by phk.freebsd.dk (Postfix) with ESMTP id B3526BC84; Tue, 18 Oct 2005 07:29:58 +0000 (UTC) To: Bruce Evans From: "Poul-Henning Kamp" In-Reply-To: Your message of "Tue, 18 Oct 2005 15:04:54 +1000." <20051018135821.L93164@delplex.bde.org> Date: Tue, 18 Oct 2005 09:29:57 +0200 Message-ID: <67214.1129620597@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, Andre Oppermann , cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.bin/vmstat vmstat.c src/usr.bin/w w.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2005 07:30:02 -0000 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.