Patch "x86/aperfmperf: Erase stale arch_freq_scale values when disabling frequency invariance readings" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    x86/aperfmperf: Erase stale arch_freq_scale values when disabling frequency invariance readings

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-aperfmperf-erase-stale-arch_freq_scale-values-wh.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f301d10133763f73069e2d213bb72acd10ca191d
Author: Yair Podemsky <ypodemsk@xxxxxxxxxx>
Date:   Tue Jan 10 18:02:06 2023 +0200

    x86/aperfmperf: Erase stale arch_freq_scale values when disabling frequency invariance readings
    
    [ Upstream commit 5f5cc9ed992cbab6361f198966f0edba5fc52688 ]
    
    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@xxxxxxxxxx>
    Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
    Acked-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230110160206.75912-1-ypodemsk@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index 1f60a2b27936..fdbb5f07448f 100644
--- a/arch/x86/kernel/cpu/aperfmperf.c
+++ b/arch/x86/kernel/cpu/aperfmperf.c
@@ -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,



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux