aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/sched/fair.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 95d4a3beea1c..2384841c5ceb 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6969,11 +6969,17 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu,
else
select_max_spare_cap_cpus(sd, candidates, pd, p);
- /* Bail out if there is no candidate, or if the only one is prev_cpu */
+ /* Bail out if no candidate was found. */
weight = cpumask_weight(candidates);
- if (!weight || (weight == 1 && cpumask_first(candidates) == prev_cpu))
+ if (!weight)
return prev_cpu;
+ /* If there is only one sensible candidate, select it now. */
+ cpu = cpumask_first(candidates);
+ if (weight == 1 && ((schedtune_prefer_idle(p) && idle_cpu(cpu)) ||
+ (cpu == prev_cpu)))
+ return cpu;
+
if (cpumask_test_cpu(prev_cpu, &p->cpus_allowed))
prev_energy = best_energy = compute_energy(p, prev_cpu, pd);
else