Skip to content

Commit e26fd28

Browse files
qais-yousefPeter Zijlstra
authored andcommitted
sched/uclamp: Fix a uninitialized variable warnings
Addresses the following warnings: > config: riscv-randconfig-m031-20221111 > compiler: riscv64-linux-gcc (GCC) 12.1.0 > > smatch warnings: > kernel/sched/fair.c:7263 find_energy_efficient_cpu() error: uninitialized symbol 'util_min'. > kernel/sched/fair.c:7263 find_energy_efficient_cpu() error: uninitialized symbol 'util_max'. Fixes: 2442260 ("sched/uclamp: Fix fits_capacity() check in feec()") Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Qais Yousef (Google) <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Vincent Guittot <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9a5418b commit e26fd28

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

kernel/sched/fair.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7229,10 +7229,10 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
72297229
eenv_task_busy_time(&eenv, p, prev_cpu);
72307230

72317231
for (; pd; pd = pd->next) {
7232+
unsigned long util_min = p_util_min, util_max = p_util_max;
72327233
unsigned long cpu_cap, cpu_thermal_cap, util;
72337234
unsigned long cur_delta, max_spare_cap = 0;
72347235
unsigned long rq_util_min, rq_util_max;
7235-
unsigned long util_min, util_max;
72367236
unsigned long prev_spare_cap = 0;
72377237
int max_spare_cap_cpu = -1;
72387238
unsigned long base_energy;
@@ -7251,6 +7251,8 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
72517251
eenv.pd_cap = 0;
72527252

72537253
for_each_cpu(cpu, cpus) {
7254+
struct rq *rq = cpu_rq(cpu);
7255+
72547256
eenv.pd_cap += cpu_thermal_cap;
72557257

72567258
if (!cpumask_test_cpu(cpu, sched_domain_span(sd)))
@@ -7269,24 +7271,19 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
72697271
* much capacity we can get out of the CPU; this is
72707272
* aligned with sched_cpu_util().
72717273
*/
7272-
if (uclamp_is_used()) {
7273-
if (uclamp_rq_is_idle(cpu_rq(cpu))) {
7274-
util_min = p_util_min;
7275-
util_max = p_util_max;
7276-
} else {
7277-
/*
7278-
* Open code uclamp_rq_util_with() except for
7279-
* the clamp() part. Ie: apply max aggregation
7280-
* only. util_fits_cpu() logic requires to
7281-
* operate on non clamped util but must use the
7282-
* max-aggregated uclamp_{min, max}.
7283-
*/
7284-
rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN);
7285-
rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MAX);
7286-
7287-
util_min = max(rq_util_min, p_util_min);
7288-
util_max = max(rq_util_max, p_util_max);
7289-
}
7274+
if (uclamp_is_used() && !uclamp_rq_is_idle(rq)) {
7275+
/*
7276+
* Open code uclamp_rq_util_with() except for
7277+
* the clamp() part. Ie: apply max aggregation
7278+
* only. util_fits_cpu() logic requires to
7279+
* operate on non clamped util but must use the
7280+
* max-aggregated uclamp_{min, max}.
7281+
*/
7282+
rq_util_min = uclamp_rq_get(rq, UCLAMP_MIN);
7283+
rq_util_max = uclamp_rq_get(rq, UCLAMP_MAX);
7284+
7285+
util_min = max(rq_util_min, p_util_min);
7286+
util_max = max(rq_util_max, p_util_max);
72907287
}
72917288
if (!util_fits_cpu(util, util_min, util_max, cpu))
72927289
continue;

0 commit comments

Comments
 (0)