Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Dec 2009 04:31:18 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r201014 - stable/8/sys/sparc64/sparc64
Message-ID:  <200912260431.nBQ4VIjb082087@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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++;
 }



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