[PATCH] sched/fair: Make is_core_idle() check all cpus in a core
From: Mete Durlu
Date: Thu Aug 06 2026 - 14:22:21 EST
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@xxxxxxxxxxxxx>
---
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@xxxxxxxxxxxxx>