From mux@qualys.com Sun Apr 1 10:49:46 2001 Return-Path: Received: from nebula.cybercable.fr (d217.dhcp212-198-126.noos.fr [212.198.126.217]) by hub.freebsd.org (Postfix) with ESMTP id 089BE37B719 for ; Sun, 1 Apr 2001 10:49:45 -0700 (PDT) (envelope-from mux@qualys.com) Received: (from mux@localhost) by nebula.cybercable.fr (8.11.3/8.11.3) id f31Hn2200759; Sun, 1 Apr 2001 19:49:02 +0200 (CEST) (envelope-from mux) Message-Id: <200104011749.f31Hn2200759@nebula.cybercable.fr> Date: Sun, 1 Apr 2001 19:49:02 +0200 (CEST) From: Maxime Henrion Reply-To: mux@qualys.com To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: [PATCH] Adds a sysctl to get the cpu frequency X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 26272 >Category: i386 >Synopsis: Adds a sysctl to get the cpu frequency >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: closed >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Apr 01 10:50:00 PDT 2001 >Closed-Date: Mon Jun 18 18:20:48 PDT 2001 >Last-Modified: Mon Jun 18 18:21:06 PDT 2001 >Originator: Maxime Henrion >Release: FreeBSD 4.3-RC i386 >Organization: >Environment: System: FreeBSD nebula.cybercable.fr 4.3-RC FreeBSD 4.3-RC #14: Sun Apr 1 19:14:00 CEST 2001 mux@nebula.cybercable.fr:/usr/src/sys/compile/NEBULA i386 >Description: There are severl sysctl's that provide cpu information but none of them gives its frequency. >How-To-Repeat: >Fix: Patch for RELENG_4 : diff -cr /usr/src/sys/i386/i386/identcpu.c ./i386/i386/identcpu.c *** /usr/src/sys/i386/i386/identcpu.c Sat Sep 30 05:32:21 2000 --- ./i386/i386/identcpu.c Sun Apr 1 19:18:00 2001 *************** *** 86,91 **** --- 86,95 ---- SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, cpu_model, 0, "Machine model"); + static char cpu_freq[32] = "unknown"; + SYSCTL_STRING(_hw, HW_FREQUENCY, frequency, CTLFLAG_RD, + cpu_freq, 0, "Machine frequency"); + static struct cpu_nameclass i386_cpus[] = { { "Intel 80286", CPUCLASS_286 }, /* CPU_286 */ { "i386SX", CPUCLASS_386 }, /* CPU_386SX */ *************** *** 509,526 **** #endif #if defined(I586_CPU) case CPUCLASS_586: ! printf("%d.%02d-MHz ", (tsc_freq + 4999) / 1000000, ((tsc_freq + 4999) / 10000) % 100); ! printf("586"); break; #endif #if defined(I686_CPU) case CPUCLASS_686: ! printf("%d.%02d-MHz ", (tsc_freq + 4999) / 1000000, ((tsc_freq + 4999) / 10000) % 100); ! printf("686"); break; #endif default: --- 513,530 ---- #endif #if defined(I586_CPU) case CPUCLASS_586: ! sprintf(cpu_freq, "%d.%02d-MHz ", (tsc_freq + 4999) / 1000000, ((tsc_freq + 4999) / 10000) % 100); ! printf("%s586", cpu_freq); break; #endif #if defined(I686_CPU) case CPUCLASS_686: ! sprintf(cpu_freq, "%d.%02d-MHz ", (tsc_freq + 4999) / 1000000, ((tsc_freq + 4999) / 10000) % 100); ! printf("%s686", cpu_freq); break; #endif default: diff -cr /usr/src/sys/sys/sysctl.h ./sys/sysctl.h *** /usr/src/sys/sys/sysctl.h Thu Feb 22 10:29:42 2001 --- ./sys/sysctl.h Sun Apr 1 19:18:21 2001 *************** *** 416,421 **** --- 416,422 ---- #define HW_FLOATINGPT 10 /* int: has HW floating point? */ #define HW_MACHINE_ARCH 11 /* string: machine architecture */ #define HW_MAXID 12 /* number of valid hw ids */ + #define HW_FREQUENCY 13 /* cpu frequency */ #define CTL_HW_NAMES { \ { 0, 0 }, \ >Release-Note: >Audit-Trail: From: Poul-Henning Kamp To: mux@qualys.com Cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: i386/26272: [PATCH] Adds a sysctl to get the cpu frequency Date: Sun, 01 Apr 2001 23:07:14 +0200 Weeeeelllll... We already have that in machdep.tsc_freq if we trust it to be constant. If we don't trust it to be constant, any reporting is at best a guess and we might as well not report a random number... -- 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. State-Changed-From-To: open->closed State-Changed-By: dd State-Changed-When: Mon Jun 18 18:20:48 PDT 2001 State-Changed-Why: From audit-trail: From: Poul-Henning Kamp To: mux@qualys.com Cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: i386/26272: [PATCH] Adds a sysctl to get the cpu frequency Date: Sun, 01 Apr 2001 23:07:14 +0200 Weeeeelllll... We already have that in machdep.tsc_freq if we trust it to be constant. If we don't trust it to be constant, any reporting is at best a guess and we might as well not report a random number... -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 http://www.FreeBSD.org/cgi/query-pr.cgi?pr=26272 >Unformatted: