Skip to content

Commit

Permalink
x86/aperfmperf: Erase stale arch_freq_scale values when disabling fre…
Browse files Browse the repository at this point in the history
…quency invariance readings

[ Upstream commit 5f5cc9e ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yair Podemsky authored and gregkh committed Feb 9, 2023
1 parent f6c8f68 commit fcf8b1a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions arch/x86/kernel/cpu/aperfmperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,16 @@ static void __init bp_init_freq_invariance(void)

static void disable_freq_invariance_workfn(struct work_struct *work)
{
int cpu;

static_branch_disable(&arch_scale_freq_key);

/*
* Set arch_freq_scale to a default value on all cpus
* This negates the effect of scaling
*/
for_each_possible_cpu(cpu)
per_cpu(arch_freq_scale, cpu) = SCHED_CAPACITY_SCALE;
}

static DECLARE_WORK(disable_freq_invariance_work,
Expand Down

0 comments on commit fcf8b1a

Please sign in to comment.