[tip: smp/core] smp: Disable preemption explicitly in __csd_lock_wait()

tip-bot2 for Chuyi Zhou posted 1 patch 1 day, 11 hours ago
kernel/smp.c | 2 ++
1 file changed, 2 insertions(+)
[tip: smp/core] smp: Disable preemption explicitly in __csd_lock_wait()
Posted by tip-bot2 for Chuyi Zhou 1 day, 11 hours ago
The following commit has been merged into the smp/core branch of tip:

Commit-ID:     b46883305f26188bf0555d06e77f43ab01d5ec95
Gitweb:        https://git.kernel.org/tip/b46883305f26188bf0555d06e77f43ab01d5ec95
Author:        Chuyi Zhou <zhouchuyi@bytedance.com>
AuthorDate:    Thu, 09 Jul 2026 20:29:20 +08:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Thu, 16 Jul 2026 09:24:55 +02:00

smp: Disable preemption explicitly in __csd_lock_wait()

The CSD lock wait debugging code in __csd_lock_wait() must run with
preemption disabled. The smp function call mechanisms which invoke it
currently keep preemption disabled across the wait, so the debugging code
inherits that guarantee from its callers.

Keeping preemption disabled across the whole smp function call operation
can induce large scheduling latencies. Shortening the caller-side
preemption-disabled region would invoke __csd_lock_wait() with preemption
enabled.

Prepare for that by disabling preemption explicitly around the CSD lock
wait debugging code in __csd_lock_wait().

Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Muchun Song <muchun.song@linux.dev>
Link: https://patch.msgid.link/20260709122933.4021501-2-zhouchuyi@bytedance.com
---
 kernel/smp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/smp.c b/kernel/smp.c
index 8a847a3..f5a4d63 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -335,6 +335,8 @@ static void __csd_lock_wait(call_single_data_t *csd)
 	int bug_id = 0;
 	u64 ts0, ts1;
 
+	guard(preempt)();
+
 	ts1 = ts0 = ktime_get_mono_fast_ns();
 	for (;;) {
 		if (csd_lock_wait_toolong(csd, ts0, &ts1, &bug_id, &nmessages))