Skip to content

Commit f4291df

Browse files
gghhPeter Zijlstra
authored andcommitted
x86, sched: Bail out of frequency invariance if turbo_freq/base_freq gives 0
Be defensive against the case where the processor reports a base_freq larger than turbo_freq (the ratio would be zero). Fixes: 1567c3e ("x86, sched: Add support for frequency invariance") Signed-off-by: Giovanni Gherdovich <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 51beea8 commit f4291df

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

arch/x86/kernel/smpboot.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,7 @@ static bool core_set_max_freq_ratio(u64 *base_freq, u64 *turbo_freq)
19771977
static bool intel_set_max_freq_ratio(void)
19781978
{
19791979
u64 base_freq, turbo_freq;
1980+
u64 turbo_ratio;
19801981

19811982
if (slv_set_max_freq_ratio(&base_freq, &turbo_freq))
19821983
goto out;
@@ -2010,9 +2011,15 @@ static bool intel_set_max_freq_ratio(void)
20102011
return false;
20112012
}
20122013

2013-
arch_turbo_freq_ratio = div_u64(turbo_freq * SCHED_CAPACITY_SCALE,
2014-
base_freq);
2014+
turbo_ratio = div_u64(turbo_freq * SCHED_CAPACITY_SCALE, base_freq);
2015+
if (!turbo_ratio) {
2016+
pr_debug("Non-zero turbo and base frequencies led to a 0 ratio.\n");
2017+
return false;
2018+
}
2019+
2020+
arch_turbo_freq_ratio = turbo_ratio;
20152021
arch_set_max_freq_ratio(turbo_disabled());
2022+
20162023
return true;
20172024
}
20182025

0 commit comments

Comments
 (0)