Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 May 2001 16:21:16 -0700 (PDT)
From:      larse@isi.edu
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   i386/27627: machdep.tsc_freq does not exists on machines with APM or SMP
Message-ID:  <200105242321.f4ONLGC99337@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         27627
>Category:       i386
>Synopsis:       machdep.tsc_freq does not exists on machines with APM or SMP
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 24 16:30:07 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Lars Eggert
>Release:        4.2-RELEASE
>Organization:
>Environment:
FreeBSD e.postel.org 4.2-RELEASE FreeBSD 4.2-RELEASE #6: Thu May 24 15:52:44 PDT 2001     larse@e.postel.org:/usr/src/sys/compile/KERNEL-1.19  i386

>Description:
The machdep.tsc_freq sysctl knob does not exists on systems that have
power management (APM) or SMP enabled. It's the easiest way to query
for probed CPU speed.

The patch below adds a new read-only sysctl know "hw.cpuhz" which is
initialized from tsc_freq at boot time. Since it's read-only, it is
ok to use on SMP and APM-enabled machines.

Please transmogrify the patch as needed for inclusion in the tree.
>How-To-Repeat:

>Fix:
--- /usr/src/sys/i386/isa/clock.c       Wed Aug  2 17:09:29 2000
+++ clock.c     Thu May 24 15:57:07 2001
@@ -140,6 +140,9 @@
 u_int  timer_freq = TIMER_FREQ;
 int    timer0_max_count;
 u_int  tsc_freq;
+#ifdef CPUHZ
+static u_int   cpuhz = 0;
+#endif
 int    tsc_is_broken;
 int    wall_cmos_clock;        /* wall CMOS clock assumed if != 0 */
 
@@ -661,6 +664,9 @@
         * similar to those for the i8254 clock.
         */
        if (tsc_present) 
+#ifdef CPUHZ
+               cpuhz =
+#endif
                tsc_freq = rdtsc() - old_tsc;
 
        if (bootverbose) {
@@ -1164,6 +1170,10 @@
 
 SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
     0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", "");
+
+#ifdef CPUHZ
+SYSCTL_INT(_hw, OID_AUTO, cpuhz, CTLFLAG_RD, &cpuhz, 0, "CPU speed in Hz.");
+#endif
 
 static int
 sysctl_machdep_tsc_freq(SYSCTL_HANDLER_ARGS)

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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