Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2b34dfe authored by Hubert Chrzaniuk's avatar Hubert Chrzaniuk Committed by Len Brown
Browse files

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: default avatarHubert Chrzaniuk <hubert.chrzaniuk@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 756357b8
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -71,6 +71,7 @@ unsigned int extra_msr_offset32;
unsigned int extra_msr_offset64;
unsigned int extra_msr_offset64;
unsigned int extra_delta_offset32;
unsigned int extra_delta_offset32;
unsigned int extra_delta_offset64;
unsigned int extra_delta_offset64;
unsigned int aperf_mperf_multiplier = 1;
int do_smi;
int do_smi;
double bclk;
double bclk;
unsigned int show_pkg;
unsigned int show_pkg;
@@ -984,6 +985,8 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
			return -3;
			return -3;
		if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf))
		if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf))
			return -4;
			return -4;
		t->aperf = t->aperf * aperf_mperf_multiplier;
		t->mperf = t->mperf * aperf_mperf_multiplier;
	}
	}


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


unsigned int get_aperf_mperf_multiplier(unsigned int family, unsigned int model)
{
	if (is_knl(family, model))
		return 1024;
	return 1;
}

#define SLM_BCLK_FREQS 5
#define SLM_BCLK_FREQS 5
double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0};
double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0};


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


	if (has_aperf)
		aperf_mperf_multiplier = get_aperf_mperf_multiplier(family, model);

	do_nhm_platform_info = do_nhm_cstates = do_smi = probe_nhm_msrs(family, model);
	do_nhm_platform_info = do_nhm_cstates = do_smi = probe_nhm_msrs(family, model);
	do_snb_cstates = has_snb_msrs(family, model);
	do_snb_cstates = has_snb_msrs(family, model);
	do_pc2 = do_snb_cstates && (pkg_cstate_limit >= PCL__2);
	do_pc2 = do_snb_cstates && (pkg_cstate_limit >= PCL__2);