svn commit: r201014 - stable/8/sys/sparc64/sparc64
Marcel Moolenaar
marcel at FreeBSD.org
Sat Dec 26 04:31:18 UTC 2009
Author: marcel
Date: Sat Dec 26 04:31:18 2009
New Revision: 201014
URL: http://svn.freebsd.org/changeset/base/201014
Log:
MFC rev 200891:
Calculate the average CPU clock frequency and export that through
the hw.freq.cpu sysctl variable.
Modified:
stable/8/sys/sparc64/sparc64/identcpu.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/sparc64/sparc64/identcpu.c
==============================================================================
--- stable/8/sys/sparc64/sparc64/identcpu.c Sat Dec 26 04:29:38 2009 (r201013)
+++ stable/8/sys/sparc64/sparc64/identcpu.c Sat Dec 26 04:31:18 2009 (r201014)
@@ -27,6 +27,13 @@ static char cpu_model[128];
SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
cpu_model, 0, "Machine model");
+SYSCTL_NODE(_hw, OID_AUTO, freq, CTLFLAG_RD, 0, "");
+
+static u_int cpu_count;
+static u_int cpu_freq;
+SYSCTL_UINT(_hw_freq, OID_AUTO, cpu, CTLFLAG_RD, &cpu_freq, 0,
+ "CPU clock frequency");
+
int cpu_impl;
void
@@ -104,4 +111,11 @@ cpu_identify(u_long vers, u_int freq, u_
printf(" mask=0x%lx maxtl=%ld maxwin=%ld\n", VER_MASK(vers),
VER_MAXTL(vers), VER_MAXWIN(vers));
}
+
+ /*
+ * Calculate the average CPU frequency.
+ */
+ freq = (freq + 500000ul) / 1000000ul;
+ cpu_freq = (cpu_freq * cpu_count + freq) / (cpu_count + 1);
+ cpu_count++;
}
More information about the svn-src-stable-8
mailing list