From: Mete Durlu <meted@linux.ibm.com>
To: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>,
linux-kernel@vger.kernel.org, Mete Durlu <meted@linux.ibm.com>
Subject: [PATCH] sched/fair: Make is_core_idle() check all cpus in a core
Date: Thu, 06 Aug 2026 20:18:56 +0200 [thread overview]
Message-ID: <20260806-fix_is_core_idle-v1-1-605119e55b25@linux.ibm.com> (raw)
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>
next reply other threads:[~2026-08-06 18:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 18:18 Mete Durlu [this message]
2026-08-07 3:42 ` Zhan Xusheng
2026-08-09 10:02 ` Mete Durlu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260806-fix_is_core_idle-v1-1-605119e55b25@linux.ibm.com \
--to=meted@linux.ibm.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=iii@linux.ibm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®