From 7bb38803c22019fb2a3ac8e0599d5a9c086dc1ed Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Wed, 28 Jul 2021 12:54:27 -0700 Subject: [PATCH] sched/walt: skip finding max when energy evaluating Currently the code is finding the max_cap_cpu amongst candidates but is unused if we are energy evaluating. Clean up the code. Change-Id: I317ed8328851b69534c375c69387647a94ada659 Signed-off-by: Abhijeet Dharmapurikar --- kernel/sched/walt/walt_cfs.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/kernel/sched/walt/walt_cfs.c b/kernel/sched/walt/walt_cfs.c index f481948772e2..16815a5ebf4e 100644 --- a/kernel/sched/walt/walt_cfs.c +++ b/kernel/sched/walt/walt_cfs.c @@ -688,7 +688,7 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, int task_boost = per_task_boost(p); bool uclamp_boost = walt_uclamp_boosted(p); int start_cpu, order_index, end_index; - int max_cap_cpu = -1; + int first_cpu; bool energy_eval_needed = true; struct compute_energy_output output; @@ -747,25 +747,26 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, if (!weight) goto unlock; - max_cap_cpu = cpumask_first(candidates); + first_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; + if (available_idle_cpu(first_cpu) || first_cpu == prev_cpu) { + best_energy_cpu = first_cpu; goto unlock; } } - if (need_idle && available_idle_cpu(max_cap_cpu)) { - best_energy_cpu = max_cap_cpu; + if (need_idle && available_idle_cpu(first_cpu)) { + best_energy_cpu = first_cpu; goto unlock; } - for_each_cpu(cpu, candidates) { - if (capacity_orig_of(max_cap_cpu) < capacity_orig_of(cpu)) - max_cap_cpu = cpu; - } - if (!energy_eval_needed) { + int max_cap_cpu = first_cpu; + + for_each_cpu(cpu, candidates) { + if (capacity_orig_of(max_cap_cpu) < capacity_orig_of(cpu)) + max_cap_cpu = cpu; + } best_energy_cpu = max_cap_cpu; goto unlock; }