Skip to content

Commit 9a6c2c3

Browse files
gghhPeter Zijlstra
authored andcommitted
x86, sched: Bail out of frequency invariance if base frequency is unknown
Some hypervisors such as VMWare ESXi 5.5 advertise support for X86_FEATURE_APERFMPERF but then fill all MSR's with zeroes. In particular, MSR_PLATFORM_INFO set to zero tricks the code that wants to know the base clock frequency of the CPU (highest non-turbo frequency), producing a division by zero when computing the ratio turbo_freq/base_freq necessary for frequency invariant accounting. It is to be noted that even if MSR_PLATFORM_INFO contained the appropriate data, APERF and MPERF are constantly zero on ESXi 5.5, thus freq-invariance couldn't be done in principle (not that it would make a lot of sense in a VM anyway). The real problem is advertising X86_FEATURE_APERFMPERF. This appears to be fixed in more recent versions: ESXi 6.7 doesn't advertise that feature. Fixes: 1567c3e ("x86, sched: Add support for frequency invariance") Signed-off-by: Giovanni Gherdovich <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent ae83d0b commit 9a6c2c3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/x86/kernel/smpboot.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,15 @@ static bool intel_set_max_freq_ratio(void)
19851985
return false;
19861986

19871987
out:
1988+
/*
1989+
* Some hypervisors advertise X86_FEATURE_APERFMPERF
1990+
* but then fill all MSR's with zeroes.
1991+
*/
1992+
if (!base_freq) {
1993+
pr_debug("Couldn't determine cpu base frequency, necessary for scale-invariant accounting.\n");
1994+
return false;
1995+
}
1996+
19881997
arch_turbo_freq_ratio = div_u64(turbo_freq * SCHED_CAPACITY_SCALE,
19891998
base_freq);
19901999
arch_set_max_freq_ratio(turbo_disabled());

0 commit comments

Comments
 (0)