From: Sven Schnelle <svens@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>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Valentin Schneider <vschneid@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] sched/core: Test online status in available_idle_cpu()
Date: Mon, 29 Apr 2024 07:54:15 +0200 [thread overview]
Message-ID: <20240429055415.3278672-1-svens@linux.ibm.com> (raw)
The current implementation of available_idle_cpu() doesn't test
whether a possible cpu is offline. On s390 this dereferences a
NULL pointer in arch_vcpu_is_preempted() because lowcore is not
allocated for offline cpus. On x86, tracing also shows calls to
available_idle_cpu() after a cpu is disabled, but it looks like
this isn't causing any (obvious) issue. Nevertheless, add a check
and return early if the cpu isn't online.
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
kernel/sched/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7019a40457a6..1d9b80411594 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7434,6 +7434,9 @@ int idle_cpu(int cpu)
*/
int available_idle_cpu(int cpu)
{
+ if (!cpu_online(cpu))
+ return 0;
+
if (!idle_cpu(cpu))
return 0;
--
2.40.1
next reply other threads:[~2024-04-29 5:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 5:54 Sven Schnelle [this message]
2024-05-02 15:57 ` [PATCH] sched/core: Test online status in available_idle_cpu() Valentin Schneider
2024-05-08 7:31 ` Sven Schnelle
2024-05-16 16:38 ` Sven Schnelle
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=20240429055415.3278672-1-svens@linux.ibm.com \
--to=svens@linux.ibm.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=hca@linux.ibm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).