From 5783aeab9f9b581b8b255e543f4543acc6d11746 Mon Sep 17 00:00:00 2001 From: Vincent Brillault Date: Sat, 23 Aug 2014 08:56:28 +0200 Subject: [PATCH] Turbostat: use MSR_IA32_TSC instead of rdtsc --- src/turbostat.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/turbostat.c b/src/turbostat.c index aef66286..6466d5c6 100644 --- a/src/turbostat.c +++ b/src/turbostat.c @@ -197,6 +197,7 @@ enum return_values { ERR_MSR_PKG_PERF_STATUS, ERR_MSR_DRAM_PERF_STATUS, ERR_MSR_IA32_PACKAGE_THERM_STATUS, + ERR_MSR_IA32_TSC, ERR_CPU_NOT_PRESENT, ERR_NO_MSR, ERR_CANT_OPEN_FILE, @@ -409,17 +410,6 @@ delta_cpu(struct thread_data *t, struct core_data *c, return 0; } -static unsigned long long -rdtsc(void) -{ - unsigned int low, high; - - asm volatile("rdtsc" : "=a" (low), "=d" (high)); - - return low | ((unsigned long long)high) << 32; -} - - /* * get_counters(...) * migrate to cpu @@ -436,7 +426,8 @@ get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) return -ERR_CPU_MIGRATE; } - t->tsc = rdtsc(); /* we are running on local CPU of interest */ + if (get_msr(cpu, MSR_IA32_TSC, &t->tsc)) + return -MSR_IA32_TSC; if (get_msr(cpu, MSR_IA32_APERF, &t->aperf)) return -ERR_MSR_IA32_APERF; -- 2.30.2