diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2011-04-12 23:49:07 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2011-04-12 23:49:07 +0000 |
commit | a7817c7ae522ecd9bd764d88eaf828984a35c719 (patch) | |
tree | cb041d4c6e6195b0da6712efd77550b3d7b2ef9a /sys/amd64 | |
parent | b9e437621416b04899ce90a211c666b31696a7a8 (diff) | |
download | src-a7817c7ae522ecd9bd764d88eaf828984a35c719.tar.gz src-a7817c7ae522ecd9bd764d88eaf828984a35c719.zip |
Reduce errors in effective frequency calculation.
Notes
Notes:
svn path=/head/; revision=220584
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/machdep.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index ace4cdfaa1a4..127b2cf9a825 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); |