summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorDave Jones <davej@redhat.com>2009-10-26 17:21:55 -0400
committerDave Jones <davej@redhat.com>2009-10-26 17:21:55 -0400
commit5e58066bba0e390c0dc60bdf1e242554b6f93826 (patch)
treeb340790a0e5ce684f9ff45e3194ce334568b357e /bench
parent3aa21b5d657644980e5acd1ae87461b46bb24790 (diff)
handle rdtsc wrapping.
Diffstat (limited to 'bench')
-rw-r--r--bench/MHz.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bench/MHz.c b/bench/MHz.c
index 34cac39..874658c 100644
--- a/bench/MHz.c
+++ b/bench/MHz.c
@@ -51,7 +51,12 @@ void estimate_MHz(struct cpudata *cpu)
cycles[1] = rdtsc();
- cpu->MHz = (cycles[1] - cycles[0]) / 1000000;
+ /* Check to see if rdtsc wrapped */
+ if (cycles[1] < cycles[0])
+ /* yes we did. */
+ cpu->MHz = ((-1ULL - cycles[0]) + cycles[1]) / 1000000;
+ else
+ cpu->MHz = (cycles[1] - cycles[0]) / 1000000;
if ((cpu->MHz % 50) > 15)
cpu->MHz = ((cpu->MHz / 50) * 50) + 50;