[PATCH] sched/fair: Clear target from cpus to scan in select_idle_cpu

From: Yicong Yang
Date: Wed Nov 24 2021 - 03:56:57 EST


Commit 56498cfb045d noticed that "When select_idle_cpu starts scanning for
an idle CPU, it starts with a target CPU that has already been checked
by select_idle_sibling. This patch starts with the next CPU instead."
It only changed the scanning start cpu to target + 1 but still leave
the target in the scanning cpumask. The target still have a chance to be
checked in the last turn. Fix this by clear the target from the cpus
to scan.

Fixes: 56498cfb045d ("sched/fair: Avoid a second scan of target in select_idle_cpu")
Signed-off-by: Yicong Yang <yangyicong@xxxxxxxxxxxxx>
---
kernel/sched/fair.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6e476f6d9435..e1031e0da231 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6249,6 +6249,7 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool
return -1;

cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
+ cpumask_clear_cpu(target, cpus);

if (sched_feat(SIS_PROP) && !has_idle_core) {
u64 avg_cost, avg_idle, span_avg;
--
2.33.0