summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2011-04-12 23:49:07 +0000
committerjkim <jkim@FreeBSD.org>2011-04-12 23:49:07 +0000
commit11b920013e4acebde8704db71b74a2e80405670c (patch)
treecb041d4c6e6195b0da6712efd77550b3d7b2ef9a /sys/amd64
parent218c7113eda7be885de958c079152f70afe24ad9 (diff)
downloadFreeBSD-src-11b920013e4acebde8704db71b74a2e80405670c.zip
FreeBSD-src-11b920013e4acebde8704db71b74a2e80405670c.tar.gz
Reduce errors in effective frequency calculation.
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/machdep.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index ace4cdf..127b2cf 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -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 *rate)
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);
OpenPOWER on IntegriCloud