[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211126105139.11784-1-21cnbao@gmail.com>
Date: Fri, 26 Nov 2021 18:51:39 +0800
From: Barry Song <21cnbao@...il.com>
To: mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
vincent.guittot@...aro.org, rostedt@...dmis.org,
linux-kernel@...r.kernel.org
Cc: dietmar.eggemann@....com, bsegall@...gle.com, mgorman@...e.de,
bristot@...hat.com, Barry Song <song.bao.hua@...ilicon.com>
Subject: [PATCH v3] sched/fair: Eliminate confusion for the scan number in select_idle_cpu
From: Barry Song <song.bao.hua@...ilicon.com>
Right now, the number of scans is very confusing. For example, if nr==4,
the code is iterating 4 times but scanning 3 times only. Because in the
4th iteration, the code returns directly due to --nr==0. So the code is
wasting time on doing the 4th cpumask_next_wrap() and it is also very
confusing since the actual scan number is nr-1 but not nr. This seems not
to be the original intention.
This patch moves to scan nr times rather than nr-1 times, and it also
makes the last iteration of cpumask_next_wrap() useful.
Signed-off-by: Barry Song <song.bao.hua@...ilicon.com>
---
-v3:
scan nr times instead of nr-1 times with respect to Peter's comments;
rewrite commit log and subject since we have changed the behaviour of
the code;
-v2:
https://lore.kernel.org/lkml/20211124091546.5072-1-21cnbao@gmail.com/
kernel/sched/fair.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6e476f6..5c259aa 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6285,11 +6285,11 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool
return i;
} else {
- if (!--nr)
- return -1;
idle_cpu = __select_idle_cpu(cpu, p);
if ((unsigned int)idle_cpu < nr_cpumask_bits)
break;
+ if (!--nr)
+ return -1;
}
}
--
1.8.3.1
Powered by blists - more mailing lists