This is a note to let you know that I've just added the patch titled sched/uclamp: Make select_idle_capacity() use util_fits_cpu() to the 5.10-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: sched-uclamp-make-select_idle_capacity-use-util_fits_cpu.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From qyousef@xxxxxxxxxxx Tue Apr 18 16:10:03 2023 From: Qais Yousef <qyousef@xxxxxxxxxxx> Date: Tue, 18 Apr 2023 15:09:36 +0100 Subject: sched/uclamp: Make select_idle_capacity() use util_fits_cpu() To: stable@xxxxxxxxxxxxxxx, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Vincent Guittot <vincent.guittot@xxxxxxxxxx>, Dietmar Eggemann <dietmar.eggemann@xxxxxxx>, Qais Yousef <qais.yousef@xxxxxxx> Message-ID: <20230418140943.90621-4-qyousef@xxxxxxxxxxx> From: Qais Yousef <qais.yousef@xxxxxxx> commit b759caa1d9f667b94727b2ad12589cbc4ce13a82 upstream. Use the new util_fits_cpu() to ensure migration margin and capacity pressure are taken into account correctly when uclamp is being used otherwise we will fail to consider CPUs as fitting in scenarios where they should. Fixes: b4c9c9f15649 ("sched/fair: Prefer prev cpu in asymmetric wakeup path") Signed-off-by: Qais Yousef <qais.yousef@xxxxxxx> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20220804143609.515789-5-qais.yousef@xxxxxxx (cherry picked from commit b759caa1d9f667b94727b2ad12589cbc4ce13a82) Signed-off-by: Qais Yousef (Google) <qyousef@xxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- kernel/sched/fair.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6394,21 +6394,23 @@ static int select_idle_cpu(struct task_s static int select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) { - unsigned long task_util, best_cap = 0; + unsigned long task_util, util_min, util_max, best_cap = 0; int cpu, best_cpu = -1; struct cpumask *cpus; cpus = this_cpu_cpumask_var_ptr(select_idle_mask); cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr); - task_util = uclamp_task_util(p); + task_util = task_util_est(p); + util_min = uclamp_eff_value(p, UCLAMP_MIN); + util_max = uclamp_eff_value(p, UCLAMP_MAX); for_each_cpu_wrap(cpu, cpus, target) { unsigned long cpu_cap = capacity_of(cpu); if (!available_idle_cpu(cpu) && !sched_idle_cpu(cpu)) continue; - if (fits_capacity(task_util, cpu_cap)) + if (util_fits_cpu(task_util, util_min, util_max, cpu)) return cpu; if (cpu_cap > best_cap) { Patches currently in stable-queue which might be from qyousef@xxxxxxxxxxx are queue-5.10/sched-fair-detect-capacity-inversion.patch queue-5.10/sched-uclamp-make-cpu_overutilized-use-util_fits_cpu.patch queue-5.10/sched-uclamp-make-select_idle_capacity-use-util_fits_cpu.patch queue-5.10/sched-uclamp-fix-fits_capacity-check-in-feec.patch queue-5.10/sched-fair-consider-capacity-inversion-in-util_fits_cpu.patch queue-5.10/sched-fair-fixes-for-capacity-inversion-detection.patch queue-5.10/sched-uclamp-make-asym_fits_capacity-use-util_fits_cpu.patch queue-5.10/sched-uclamp-fix-a-uninitialized-variable-warnings.patch queue-5.10/sched-uclamp-make-task_fits_capacity-use-util_fits_cpu.patch queue-5.10/sched-uclamp-cater-for-uclamp-in-find_energy_efficient_cpu-s-early-exit-condition.patch