mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev
Cc: Thomas Gleixner <tglx@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 3/3] smpboot: Don't park the thread if work is pending
Date: Fri, 11 Sep 2026 16:38:14 +0200	[thread overview]
Message-ID: <20260911143815.997254-4-bigeasy@linutronix.de> (raw)
In-Reply-To: <20260911143815.997254-1-bigeasy@linutronix.de>

Once a smpboot thread gets work assigned it receives a wake up. If the
thread had no chance to run and receives a parking requesst during a
CPU-hotplug event then it is parked without running the callback first.
As a result the enqueued work remains stuck until the CPU gets back
online.

There is nothing wrong with invoking the thread function first and
parking in the following iteration. This would ensure that the callbacks
are processed before the shutdown.

Honor the park request once thread function does not need to run.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 kernel/smpboot.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/smpboot.c b/kernel/smpboot.c
index 4503b60ce9bd2..3f60e8c6dd301 100644
--- a/kernel/smpboot.c
+++ b/kernel/smpboot.c
@@ -103,6 +103,7 @@ static int smpboot_thread_fn(void *data)
 {
 	struct smpboot_thread_data *td = data;
 	struct smp_hotplug_thread *ht = td->ht;
+	bool should_run;
 
 	while (1) {
 		set_current_state(TASK_INTERRUPTIBLE);
@@ -117,7 +118,8 @@ static int smpboot_thread_fn(void *data)
 			return 0;
 		}
 
-		if (kthread_should_park()) {
+		should_run = td->status == HP_THREAD_ACTIVE && ht->thread_should_run(td->cpu);
+		if (kthread_should_park() && !should_run) {
 			__set_current_state(TASK_RUNNING);
 			preempt_enable();
 			if (ht->park && td->status == HP_THREAD_ACTIVE) {
@@ -151,7 +153,7 @@ static int smpboot_thread_fn(void *data)
 			continue;
 		}
 
-		if (!ht->thread_should_run(td->cpu)) {
+		if (!should_run) {
 			preempt_enable_no_resched();
 			schedule();
 		} else {
-- 
2.55.0


  parent reply	other threads:[~2026-09-11 14:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 14:38 [PATCH 0/3] irq_work: CPU-hotplug improvements on PREEMPT_RT Sebastian Andrzej Siewior
2026-09-11 14:38 ` [PATCH 1/3] irq_work: Update a comment regarding CPU hotplug invocation Sebastian Andrzej Siewior
2026-10-02  9:33   ` [tip: sched/core] " tip-bot2 for Sebastian Andrzej Siewior
2026-09-11 14:38 ` [PATCH 2/3] irq_work: Flush lazy work CPU down on PREEMPT_RT Sebastian Andrzej Siewior
2026-09-11 14:55   ` sashiko-bot
2026-09-14  7:26     ` Sebastian Andrzej Siewior
2026-10-02  9:33   ` [tip: sched/core] " tip-bot2 for Sebastian Andrzej Siewior
2026-09-11 14:38 ` Sebastian Andrzej Siewior [this message]
2026-10-02  9:33   ` [tip: sched/core] smpboot: Don't park the thread if work is pending tip-bot2 for Sebastian Andrzej Siewior
2026-09-14 13:16 ` [PATCH 0/3] irq_work: CPU-hotplug improvements on PREEMPT_RT Sebastian Andrzej Siewior

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=20260911143815.997254-4-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    /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®