Skip to content

Commit b2b34df

Browse files
Hubert Chrzaniuklenb
authored andcommitted
tools/power turbostat: KNL workaround for %Busy and Avg_MHz
KNL increments APERF and MPERF every 1024 clocks. This is compliant with the architecture specification, which requires that only the ratio of APERF/MPERF need be valid. However, turbostat takes advantage of the fact that these two MSRs increment every un-halted clock at the actual and base frequency: AVG_MHz = APERF_delta/measurement_interval %Busy = MPERF_delta/TSC_delta This quirk is needed for these calculations to also work on KNL, which would otherwise show a value 1024x smaller than expected. Signed-off-by: Hubert Chrzaniuk <hubert.chrzaniuk@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 756357b commit b2b34df

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ unsigned int extra_msr_offset32;
7171
unsigned int extra_msr_offset64;
7272
unsigned int extra_delta_offset32;
7373
unsigned int extra_delta_offset64;
74+
unsigned int aperf_mperf_multiplier = 1;
7475
int do_smi;
7576
double bclk;
7677
unsigned int show_pkg;
@@ -984,6 +985,8 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
984985
return -3;
985986
if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf))
986987
return -4;
988+
t->aperf = t->aperf * aperf_mperf_multiplier;
989+
t->mperf = t->mperf * aperf_mperf_multiplier;
987990
}
988991

989992
if (do_smi) {
@@ -2541,6 +2544,13 @@ int is_knl(unsigned int family, unsigned int model)
25412544
return 0;
25422545
}
25432546

2547+
unsigned int get_aperf_mperf_multiplier(unsigned int family, unsigned int model)
2548+
{
2549+
if (is_knl(family, model))
2550+
return 1024;
2551+
return 1;
2552+
}
2553+
25442554
#define SLM_BCLK_FREQS 5
25452555
double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0};
25462556

@@ -2742,6 +2752,9 @@ void process_cpuid()
27422752
}
27432753
}
27442754

2755+
if (has_aperf)
2756+
aperf_mperf_multiplier = get_aperf_mperf_multiplier(family, model);
2757+
27452758
do_nhm_platform_info = do_nhm_cstates = do_smi = probe_nhm_msrs(family, model);
27462759
do_snb_cstates = has_snb_msrs(family, model);
27472760
do_pc2 = do_snb_cstates && (pkg_cstate_limit >= PCL__2);

0 commit comments

Comments
 (0)