From: Yury Norov <ynorov@nvidia.com>
To: linux-kernel@vger.kernel.org, "Oleg Nesterov" <oleg@redhat.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Phil Auld" <pauld@redhat.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Shrikanth Hegde" <sshegde@linux.ibm.com>,
"Tejun Heo" <tj@kernel.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Valentin Schneider" <vschneid@redhat.com>
Cc: Yury Norov <ynorov@nvidia.com>, Yury Norov <yury.norov@gmail.com>
Subject: [PATCH] stop_machine: Make stop_one_cpu_nowait() return void
Date: Fri, 24 Jul 2026 19:23:24 -0400 [thread overview]
Message-ID: <20260724232325.594212-1-ynorov@nvidia.com> (raw)
No caller checks the return value from stop_one_cpu_nowait(). All
callers require the callback to run and arrange for the target CPU's
stopper to remain enabled while queuing the work. In particular, commit
f0498d2a54e7 ("sched: Fix stop_one_cpu_nowait() vs hotplug") added
preemption protection to the scheduler callers so that queuing must
succeed once the target CPU has been observed online.
Therefore, a failure is an unrecoverable violation rather than a condition
individual callers can recover from. Diagnose it with WARN_ON_ONCE() in
stop_one_cpu_nowait(). A check in the common helper covers current and
future callers consistently, while individual checks would duplicate
the same non-recoverable handling at every call site.
Make the function return void because there is no longer a meaningful
result for callers to consume.
On UP, warn if the supplied CPU is not the current CPU because the work
cannot be scheduled in that case.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
include/linux/stop_machine.h | 20 +++++++++-----------
kernel/stop_machine.c | 10 +++-------
2 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
index 01011113d226..604ab4d103a8 100644
--- a/include/linux/stop_machine.h
+++ b/include/linux/stop_machine.h
@@ -31,7 +31,7 @@ struct cpu_stop_work {
int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg);
int stop_two_cpus(unsigned int cpu1, unsigned int cpu2, cpu_stop_fn_t fn, void *arg);
-bool stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
+void stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
struct cpu_stop_work *work_buf);
void stop_machine_park(int cpu);
void stop_machine_unpark(int cpu);
@@ -68,19 +68,17 @@ static void stop_one_cpu_nowait_workfn(struct work_struct *work)
preempt_enable();
}
-static inline bool stop_one_cpu_nowait(unsigned int cpu,
+static inline void stop_one_cpu_nowait(unsigned int cpu,
cpu_stop_fn_t fn, void *arg,
struct cpu_stop_work *work_buf)
{
- if (cpu == smp_processor_id()) {
- INIT_WORK(&work_buf->work, stop_one_cpu_nowait_workfn);
- work_buf->fn = fn;
- work_buf->arg = arg;
- schedule_work(&work_buf->work);
- return true;
- }
-
- return false;
+ if (WARN_ON_ONCE(cpu != smp_processor_id()))
+ return;
+
+ INIT_WORK(&work_buf->work, stop_one_cpu_nowait_workfn);
+ work_buf->fn = fn;
+ work_buf->arg = arg;
+ schedule_work(&work_buf->work);
}
static inline void print_stop_info(const char *log_lvl, struct task_struct *task) { }
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 773d8e9ae30c..a8a91b1e62f1 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -377,16 +377,12 @@ int stop_two_cpus(unsigned int cpu1, unsigned int cpu2, cpu_stop_fn_t fn, void *
*
* CONTEXT:
* Don't care.
- *
- * RETURNS:
- * true if cpu_stop_work was queued successfully and @fn will be called,
- * false otherwise.
*/
-bool stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
- struct cpu_stop_work *work_buf)
+void stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
+ struct cpu_stop_work *work_buf)
{
*work_buf = (struct cpu_stop_work){ .fn = fn, .arg = arg, .caller = _RET_IP_, };
- return cpu_stop_queue_work(cpu, work_buf);
+ WARN_ON_ONCE(!cpu_stop_queue_work(cpu, work_buf));
}
static bool queue_stop_cpus_work(const struct cpumask *cpumask,
--
2.53.0
next reply other threads:[~2026-07-24 23:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 23:23 Yury Norov [this message]
2026-07-25 11:45 ` Bradley Morgan
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=20260724232325.594212-1-ynorov@nvidia.com \
--to=ynorov@nvidia.com \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=pauld@redhat.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=sshegde@linux.ibm.com \
--cc=thomas.weissschuh@linutronix.de \
--cc=tj@kernel.org \
--cc=vschneid@redhat.com \
--cc=yury.norov@gmail.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®