mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/fair: Make is_core_idle() check all cpus in a core
@ 2026-08-06 18:18 Mete Durlu
  2026-08-07  3:42 ` Zhan Xusheng
  0 siblings, 1 reply; 3+ messages in thread
From: Mete Durlu @ 2026-08-06 18:18 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, K Prateek Nayak
  Cc: Ilya Leoshkevich, linux-kernel, Mete Durlu

The is_core_idle() function has a misleading name and incorrect behavior.
Despite its name suggesting it checks if a core is idle, it actually skips
checking whether the passed CPU itself is idle. This leads to incorrect
results and has caused confusion among users who assume the function works
as its name implies.

Fix this by removing the check that skips the passed CPU when evaluating
idle_cpu(), ensuring is_core_idle() now correctly determines if the entire
core (including the passed CPU) is idle.

Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
is_core_idle() does not really check if the whole core is idle or not.
Despite its name suggesting it checks if a core is idle, it skips
checking whether the passed CPU itself is idle or not. This is
misleading and can lead to incorrect results and assumptions.

Initially introduced by ff7db0bf24db ("sched/numa: Prefer using an idle
CPU as a migration target instead of comparing tasks") as a numa only
function, is_core_idle() was used along a idle_cpu() call. But after
being moved out from numa code to common code at 8b36d07f1d63
("sched/fair: Move is_core_idle() out of CONFIG_NUMA") new users started
to appear. As the name is misleading, some omitted the prerequired
idle_cpu() check for the CPU passed to is_core_idle() and wrongly
assumed the whole core being idle.

Fix this by removing the check for skipping the passed CPU when
evaluating for idle_cpu() on core siblings.

This could be leading to performance regressions on smt systems but s390
doesn't seem to be showing any impact.

None of the benchmarks show any notable change.
On a 8 core (smt 2) system run;
* stress-ng -M -b 5000000 -t 45 -c 8 --cpu-method int64
* perf bench --format="simple" sched pipe -l 1000000
* hackbench -T -p -l 160000 -g 2
---
 kernel/sched/fair.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d78467ec6ee1..361efd3015e1 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2162,9 +2162,6 @@ static inline bool is_core_idle(int cpu)
 	int sibling;
 
 	for_each_cpu(sibling, cpu_smt_mask(cpu)) {
-		if (cpu == sibling)
-			continue;
-
 		if (!idle_cpu(sibling))
 			return false;
 	}

---
base-commit: 8ba098e6b6ff0db8edf28528d1552be261af30d4
change-id: 20260731-fix_is_core_idle-3f3a9d2b9fea

Best regards,
-- 
Mete Durlu <meted@linux.ibm.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-09 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-06 18:18 [PATCH] sched/fair: Make is_core_idle() check all cpus in a core Mete Durlu
2026-08-07  3:42 ` Zhan Xusheng
2026-08-09 10:02   ` Mete Durlu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®