From owner-cvs-all@FreeBSD.ORG Thu Apr 10 04:21:01 2003 Return-Path: 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 2524E37B401; Thu, 10 Apr 2003 04:21:01 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6EB1143FDD; Thu, 10 Apr 2003 04:20:59 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id VAA25242; Thu, 10 Apr 2003 21:20:56 +1000 Date: Thu, 10 Apr 2003 21:20:55 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Wes Peters In-Reply-To: <200304100705.h3A75OVW019701@repoman.freebsd.org> Message-ID: <20030410204421.A3151@gamplex.bde.org> References: <200304100705.h3A75OVW019701@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/i386/i386 identcpu.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 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: Thu, 10 Apr 2003 11:21:01 -0000 On Thu, 10 Apr 2003, Wes Peters wrote: > wes 2003/04/10 00:05:24 PDT > > FreeBSD src repository > > Modified files: > sys/i386/i386 identcpu.c > Log: > Add a sysctl that records and reports the CPU clock rate calculated > at boot. Funny how often this trivial piece of information crops up > in embedded boxen. > > Sponsored by: St. Bernard Software > > Revision Changes Path > 1.121 +6 -0 src/sys/i386/i386/identcpu.c What's wrong with the existing sysctl (machdep.tsc_freq)? It is machine dependent, but no more than the new sysctl (both only work for certain i386's with TSC's). It doesn't discard up to 6 digits of precision. It reports the current frequency, which should be the actual frequency, which should differ from the frequency determined at boot time since it is difficult to determine the actual frequency at boot time without making the boot too long. I'm currently working on determining these frequencies right (mostly not at boot time. I often need the boot time frequency to compare it with the current and/or actual frequency, but I doubt that programs other than ones doing similar things want anything except the current frequency. When I want the boot-time frequency, I just grep for it in dmesg output or /var/log/messages. Grepping for "freq" usually shows the TSC frequency and not too much noise for me. Unfortunately the "Calibrating clocks" message which gives the most detail about the TSC clock is only printed for verbose boots and the TSC part of it has been axed in -current. Non-verbose boots give the following for me: Apr 9 20:08:28 besplex kernel: Timecounter "TSC" frequency 1532823868 Hz Apr 9 20:08:28 besplex kernel: CPU: AMD Athlon(TM) XP1600+ (1532.82-MHz 686-class CPU) The first line of this is only printed if the TSC is attached to a timecounter, which is in most !SMP && !APM cases. The second line prints the value that is returned by the new sysctl, except it doesn't return the fractional part and has rounding bugs. Bruce