lkml.org 
[lkml]   [2021]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3] sched/fair: Eliminate confusion for the scan number in select_idle_cpu
Date
From: Barry Song <song.bao.hua@hisilicon.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@hisilicon.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
\
 
 \ /
  Last update: 2021-11-26 12:33    [W:0.625 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site