From 60e138c1237e0f830c0cd444c9838d384227ee1b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 28 Apr 2023 12:17:26 +0000 Subject: [PATCH] Revert "Revert "sched/uclamp: Fix a uninitialized variable warnings"" This reverts commit be0a0feb8e627f2f2f5324c65e5f91f921d4c1b8. It was perserving the ABI, but that is not needed anymore at this point in time. Change-Id: I8913de3e6e83876a2b2ed4460c935c3adb2a0721 Signed-off-by: Greg Kroah-Hartman --- kernel/sched/fair.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d2643499a671..736407f3febc 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7099,14 +7099,16 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, int sy target_cap = boosted ? 0 : ULONG_MAX; for (; pd; pd = pd->next) { + unsigned long util_min = p_util_min, util_max = p_util_max; unsigned long cur_delta, spare_cap, max_spare_cap = 0; unsigned long rq_util_min, rq_util_max; - unsigned long util_min, util_max; bool compute_prev_delta = false; unsigned long base_energy_pd; int max_spare_cap_cpu = -1; for_each_cpu_and(cpu, perf_domain_span(pd), sched_domain_span(sd)) { + struct rq *rq = cpu_rq(cpu); + if (!cpumask_test_cpu(cpu, p->cpus_ptr)) continue; @@ -7122,24 +7124,19 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, int sy * much capacity we can get out of the CPU; this is * aligned with sched_cpu_util(). */ - if (uclamp_is_used()) { - if (uclamp_rq_is_idle(cpu_rq(cpu))) { - util_min = p_util_min; - util_max = p_util_max; - } else { - /* - * Open code uclamp_rq_util_with() except for - * the clamp() part. Ie: apply max aggregation - * only. util_fits_cpu() logic requires to - * operate on non clamped util but must use the - * max-aggregated uclamp_{min, max}. - */ - rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN); - rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MAX); + if (uclamp_is_used() && !uclamp_rq_is_idle(rq)) { + /* + * Open code uclamp_rq_util_with() except for + * the clamp() part. Ie: apply max aggregation + * only. util_fits_cpu() logic requires to + * operate on non clamped util but must use the + * max-aggregated uclamp_{min, max}. + */ + rq_util_min = uclamp_rq_get(rq, UCLAMP_MIN); + rq_util_max = uclamp_rq_get(rq, UCLAMP_MAX); - util_min = max(rq_util_min, p_util_min); - util_max = max(rq_util_max, p_util_max); - } + util_min = max(rq_util_min, p_util_min); + util_max = max(rq_util_max, p_util_max); } if (!util_fits_cpu(util, util_min, util_max, cpu)) continue;