Skip to content

Commit 23ccee2

Browse files
gghhPeter Zijlstra
authored andcommitted
x86, sched: Account for CPUs with less than 4 cores in freq. invariance
If a CPU has less than 4 physical cores, MSR_TURBO_RATIO_LIMIT will rightfully report that the 4C turbo ratio is zero. In such cases, use the 1C turbo ratio instead for frequency invariance calculations. Fixes: 1567c3e ("x86, sched: Add support for frequency invariance") Reported-by: Like Xu <[email protected]> Reported-by: Neil Rickert <[email protected]> Signed-off-by: Giovanni Gherdovich <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Tested-by: Dave Kleikamp <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 9a6c2c3 commit 23ccee2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

arch/x86/kernel/smpboot.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,18 +1945,23 @@ static bool skx_set_max_freq_ratio(u64 *base_freq, u64 *turbo_freq, int size)
19451945

19461946
static bool core_set_max_freq_ratio(u64 *base_freq, u64 *turbo_freq)
19471947
{
1948+
u64 msr;
19481949
int err;
19491950

19501951
err = rdmsrl_safe(MSR_PLATFORM_INFO, base_freq);
19511952
if (err)
19521953
return false;
19531954

1954-
err = rdmsrl_safe(MSR_TURBO_RATIO_LIMIT, turbo_freq);
1955+
err = rdmsrl_safe(MSR_TURBO_RATIO_LIMIT, &msr);
19551956
if (err)
19561957
return false;
19571958

1958-
*base_freq = (*base_freq >> 8) & 0xFF; /* max P state */
1959-
*turbo_freq = (*turbo_freq >> 24) & 0xFF; /* 4C turbo */
1959+
*base_freq = (*base_freq >> 8) & 0xFF; /* max P state */
1960+
*turbo_freq = (msr >> 24) & 0xFF; /* 4C turbo */
1961+
1962+
/* The CPU may have less than 4 cores */
1963+
if (!*turbo_freq)
1964+
*turbo_freq = msr & 0xFF; /* 1C turbo */
19601965

19611966
return true;
19621967
}

0 commit comments

Comments
 (0)