Commit e26fd28d authored by Qais Yousef's avatar Qais Yousef Committed by Peter Zijlstra

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: 24422603 ("sched/uclamp: Fix fits_capacity() check in feec()")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarQais Yousef (Google) <qyousef@layalina.io>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20230112122708.330667-2-qyousef@layalina.io
parent 9a5418bc
...@@ -7229,10 +7229,10 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) ...@@ -7229,10 +7229,10 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
eenv_task_busy_time(&eenv, p, prev_cpu); eenv_task_busy_time(&eenv, p, prev_cpu);
for (; pd; pd = pd->next) { for (; pd; pd = pd->next) {
unsigned long util_min = p_util_min, util_max = p_util_max;
unsigned long cpu_cap, cpu_thermal_cap, util; unsigned long cpu_cap, cpu_thermal_cap, util;
unsigned long cur_delta, max_spare_cap = 0; unsigned long cur_delta, max_spare_cap = 0;
unsigned long rq_util_min, rq_util_max; unsigned long rq_util_min, rq_util_max;
unsigned long util_min, util_max;
unsigned long prev_spare_cap = 0; unsigned long prev_spare_cap = 0;
int max_spare_cap_cpu = -1; int max_spare_cap_cpu = -1;
unsigned long base_energy; unsigned long base_energy;
...@@ -7251,6 +7251,8 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) ...@@ -7251,6 +7251,8 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
eenv.pd_cap = 0; eenv.pd_cap = 0;
for_each_cpu(cpu, cpus) { for_each_cpu(cpu, cpus) {
struct rq *rq = cpu_rq(cpu);
eenv.pd_cap += cpu_thermal_cap; eenv.pd_cap += cpu_thermal_cap;
if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) 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) ...@@ -7269,24 +7271,19 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
* much capacity we can get out of the CPU; this is * much capacity we can get out of the CPU; this is
* aligned with sched_cpu_util(). * aligned with sched_cpu_util().
*/ */
if (uclamp_is_used()) { if (uclamp_is_used() && !uclamp_rq_is_idle(rq)) {
if (uclamp_rq_is_idle(cpu_rq(cpu))) { /*
util_min = p_util_min; * Open code uclamp_rq_util_with() except for
util_max = p_util_max; * the clamp() part. Ie: apply max aggregation
} else { * only. util_fits_cpu() logic requires to
/* * operate on non clamped util but must use the
* Open code uclamp_rq_util_with() except for * max-aggregated uclamp_{min, max}.
* the clamp() part. Ie: apply max aggregation */
* only. util_fits_cpu() logic requires to rq_util_min = uclamp_rq_get(rq, UCLAMP_MIN);
* operate on non clamped util but must use the rq_util_max = uclamp_rq_get(rq, UCLAMP_MAX);
* max-aggregated uclamp_{min, max}.
*/ util_min = max(rq_util_min, p_util_min);
rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN); util_max = max(rq_util_max, p_util_max);
rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_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)) if (!util_fits_cpu(util, util_min, util_max, cpu))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment