diff --git a/kernel/sched/walt/walt_cfs.c b/kernel/sched/walt/walt_cfs.c index 1e65919138a7..2a06a0c3c19b 100644 --- a/kernel/sched/walt/walt_cfs.c +++ b/kernel/sched/walt/walt_cfs.c @@ -726,17 +726,14 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, /* Bail out if no candidate was found. */ weight = cpumask_weight(candidates); - if (!weight) { - rcu_read_unlock(); - goto done; - } + if (!weight) + goto unlock; max_cap_cpu = cpumask_first(candidates); if (weight == 1) { if (available_idle_cpu(max_cap_cpu) || max_cap_cpu == prev_cpu) { best_energy_cpu = max_cap_cpu; - rcu_read_unlock(); - goto done; + goto unlock; } } @@ -747,8 +744,7 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, if (!energy_eval_needed) { best_energy_cpu = max_cap_cpu; - rcu_read_unlock(); - goto done; + goto unlock; } if (p->state == TASK_WAKING) @@ -781,8 +777,6 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, } } - rcu_read_unlock(); - /* * Pick the prev CPU, if best energy CPU can't saves at least 6% of * the energy used by prev_cpu. @@ -794,6 +788,9 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, (capacity_orig_of(prev_cpu) <= capacity_orig_of(start_cpu))) best_energy_cpu = prev_cpu; +unlock: + rcu_read_unlock(); + done: trace_sched_task_util(p, cpumask_bits(candidates)[0], best_energy_cpu, sync, fbt_env.need_idle, fbt_env.fastpath,