Skip to content

Commit 5f5cc9e

Browse files
Yair PodemskyIngo Molnar
authored andcommitted
x86/aperfmperf: Erase stale arch_freq_scale values when disabling frequency invariance readings
Once disable_freq_invariance_work is called the scale_freq_tick function will not compute or update the arch_freq_scale values. However the scheduler will still read these values and use them. The result is that the scheduler might perform unfair decisions based on stale values. This patch adds the step of setting the arch_freq_scale values for all cpus to the default (max) value SCHED_CAPACITY_SCALE, Once all cpus have the same arch_freq_scale value the scaling is meaningless. Signed-off-by: Yair Podemsky <ypodemsk@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20230110160206.75912-1-ypodemsk@redhat.com
1 parent 5657c11 commit 5f5cc9e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/x86/kernel/cpu/aperfmperf.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,16 @@ static void __init bp_init_freq_invariance(void)
330330

331331
static void disable_freq_invariance_workfn(struct work_struct *work)
332332
{
333+
int cpu;
334+
333335
static_branch_disable(&arch_scale_freq_key);
336+
337+
/*
338+
* Set arch_freq_scale to a default value on all cpus
339+
* This negates the effect of scaling
340+
*/
341+
for_each_possible_cpu(cpu)
342+
per_cpu(arch_freq_scale, cpu) = SCHED_CAPACITY_SCALE;
334343
}
335344

336345
static DECLARE_WORK(disable_freq_invariance_work,

0 commit comments

Comments
 (0)