diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 83ebba03f7f7..83e99e574b06 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7003,9 +7003,18 @@ static void select_cpu_candidates(struct sched_domain *sd, cpumask_t *cpus, if (!cpumask_test_cpu(cpu, &p->cpus_allowed)) continue; - /* Skip CPUs that will be overutilized. */ util = cpu_util_next(cpu, p, cpu); cpu_cap = capacity_of(cpu); + spare_cap = cpu_cap - util; + + /* + * Skip CPUs that cannot satisfy the capacity request. + * IOW, placing the task there would make the CPU + * overutilized. Take uclamp into account to see how + * much capacity we can get out of the CPU; this is + * aligned with schedutil_cpu_util(). + */ + util = uclamp_rq_util_with(cpu_rq(cpu), util, p); if (cpu_cap * 1024 < util * capacity_margin) continue; @@ -7013,7 +7022,6 @@ static void select_cpu_candidates(struct sched_domain *sd, cpumask_t *cpus, * Find the CPU with the maximum spare capacity in * the performance domain */ - spare_cap = cpu_cap - util; if (spare_cap > max_spare_cap) { max_spare_cap = spare_cap; max_spare_cap_cpu = cpu;