Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Apr 2011 23:49:07 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
Message-ID:  <201104122349.p3CNn7kK039179@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Tue Apr 12 23:49:07 2011
New Revision: 220584
URL: http://svn.freebsd.org/changeset/base/220584

Log:
  Reduce errors in effective frequency calculation.

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/i386/i386/machdep.c

Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c	Tue Apr 12 23:04:01 2011	(r220583)
+++ head/sys/amd64/amd64/machdep.c	Tue Apr 12 23:49:07 2011	(r220584)
@@ -546,7 +546,7 @@ int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
 	uint64_t tsc1, tsc2;
-	uint64_t acnt, mcnt;
+	uint64_t acnt, mcnt, perf;
 	register_t reg;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
@@ -579,7 +579,8 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 		acnt = rdmsr(MSR_APERF);
 		tsc2 = rdtsc();
 		intr_restore(reg);
-		*rate = (tsc2 - tsc1) / 1000 * acnt / mcnt * 1000000;
+		perf = 1000 * acnt / mcnt;
+		*rate = (tsc2 - tsc1) * perf;
 	} else {
 		tsc1 = rdtsc();
 		DELAY(1000);

Modified: head/sys/i386/i386/machdep.c
==============================================================================
--- head/sys/i386/i386/machdep.c	Tue Apr 12 23:04:01 2011	(r220583)
+++ head/sys/i386/i386/machdep.c	Tue Apr 12 23:49:07 2011	(r220584)
@@ -1137,7 +1137,7 @@ int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
 	uint64_t tsc1, tsc2;
-	uint64_t acnt, mcnt;
+	uint64_t acnt, mcnt, perf;
 	register_t reg;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
@@ -1172,7 +1172,8 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 		acnt = rdmsr(MSR_APERF);
 		tsc2 = rdtsc();
 		intr_restore(reg);
-		*rate = (tsc2 - tsc1) / 1000 * acnt / mcnt * 1000000;
+		perf = 1000 * acnt / mcnt;
+		*rate = (tsc2 - tsc1) * perf;
 	} else {
 		tsc1 = rdtsc();
 		DELAY(1000);



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