cvs commit: src/sys/i386/i386 identcpu.c

Bruce Evans bde at zeta.org.au
Thu Apr 10 04:21:01 PDT 2003


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


More information about the cvs-all mailing list