Created
October 31, 2016 03:28
-
-
Save thestinger/8915e39ee2da39574606fd8c1b01e029 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 90af9982190cc4ff4d4a8d5c1e3eac53b67ac27c Mon Sep 17 00:00:00 2001 | |
From: Daniel Micay <danielmicay@gmail.com> | |
Date: Thu, 27 Oct 2016 22:25:21 -0400 | |
Subject: [PATCH] turbostat: add support for printing Vcore values | |
--- | |
tools/power/x86/turbostat/turbostat.c | 17 +++++++++++++++++ | |
1 file changed, 17 insertions(+) | |
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c | |
index 3e199b5..b8aa2e5 100644 | |
--- a/tools/power/x86/turbostat/turbostat.c | |
+++ b/tools/power/x86/turbostat/turbostat.c | |
@@ -91,6 +91,7 @@ unsigned int show_core_only; | |
char *output_buffer, *outp; | |
unsigned int do_rapl; | |
unsigned int do_dts; | |
+unsigned int do_vcore; | |
unsigned int do_ptm; | |
unsigned int do_gfx_rc6_ms; | |
unsigned long long gfx_cur_rc6_ms; | |
@@ -174,6 +175,7 @@ struct core_data { | |
unsigned long long c6; | |
unsigned long long c7; | |
unsigned int core_temp_c; | |
+ double core_vcore; | |
unsigned int core_id; | |
} *core_even, *core_odd; | |
@@ -367,6 +369,8 @@ void print_header(void) | |
if (do_dts) | |
outp += sprintf(outp, " CoreTmp"); | |
+ if (do_vcore) | |
+ outp += sprintf(outp, " Vcore"); | |
if (do_ptm) | |
outp += sprintf(outp, " PkgTmp"); | |
@@ -462,6 +466,7 @@ int dump_counters(struct thread_data *t, struct core_data *c, | |
outp += sprintf(outp, "c6: %016llX\n", c->c6); | |
outp += sprintf(outp, "c7: %016llX\n", c->c7); | |
outp += sprintf(outp, "DTS: %dC\n", c->core_temp_c); | |
+ outp += sprintf(outp, "Vcore: %fV\n", c->core_vcore); | |
} | |
if (p) { | |
@@ -614,6 +619,9 @@ int format_counters(struct thread_data *t, struct core_data *c, | |
if (do_dts) | |
outp += sprintf(outp, "%8d", c->core_temp_c); | |
+ if (do_vcore) | |
+ outp += sprintf(outp, "%8.2f", c->core_vcore); | |
+ | |
/* print per-package data only for 1st core in package */ | |
if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) | |
goto done; | |
@@ -797,6 +805,7 @@ delta_core(struct core_data *new, struct core_data *old) | |
old->c6 = new->c6 - old->c6; | |
old->c7 = new->c7 - old->c7; | |
old->core_temp_c = new->core_temp_c; | |
+ old->core_vcore = new->core_vcore; | |
} | |
/* | |
@@ -921,6 +930,7 @@ void clear_counters(struct thread_data *t, struct core_data *c, struct pkg_data | |
c->c6 = 0; | |
c->c7 = 0; | |
c->core_temp_c = 0; | |
+ c->core_vcore = 0; | |
p->pkg_wtd_core_c0 = 0; | |
p->pkg_any_core_c0 = 0; | |
@@ -972,6 +982,7 @@ int sum_counters(struct thread_data *t, struct core_data *c, | |
average.cores.c7 += c->c7; | |
average.cores.core_temp_c = MAX(average.cores.core_temp_c, c->core_temp_c); | |
+ average.cores.core_vcore = MAX(average.cores.core_vcore, c->core_vcore); | |
/* sum per-pkg values only for 1st core in pkg */ | |
if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) | |
@@ -1197,6 +1208,11 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |
c->core_temp_c = tcc_activation_temp - ((msr >> 16) & 0x7F); | |
} | |
+ if (do_vcore) { | |
+ if (get_msr(cpu, MSR_IA32_PERF_STATUS, &msr)) | |
+ return -9; | |
+ c->core_vcore = ((msr >> 32) & 0x7FFF) / 8192.0; | |
+ } | |
/* collect package counters only for 1st core in package */ | |
if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) | |
@@ -3247,6 +3263,7 @@ void process_cpuid() | |
__cpuid(0x6, eax, ebx, ecx, edx); | |
has_aperf = ecx & (1 << 0); | |
do_dts = eax & (1 << 0); | |
+ do_vcore = 1; | |
do_ptm = eax & (1 << 6); | |
has_hwp = eax & (1 << 7); | |
has_hwp_notify = eax & (1 << 8); | |
-- | |
2.10.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment