From: wen.yang@linux.dev
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Wen Yang <wen.yang@linux.dev>
Subject: [PATCH] softirq: add detail info to WARN in do_softirq_post_smp_call_flush()
Date: Fri, 6 Mar 2026 01:00:08 +0800 [thread overview]
Message-ID: <20260305170008.26261-1-wen.yang@linux.dev> (raw)
From: Wen Yang <wen.yang@linux.dev>
When the following WARNING occasionally occurs during the idle path,
the bare WARN_ON_ONCE() provides no context about what actually changed
in the softirq pending mask, making it hard to diagnose the root cause:
WARNING: CPU: 1 PID: 0 at kernel/softirq.c:297 do_softirq_post_smp_call_flush+0xbc/0xc4
Call trace:
do_softirq_post_smp_call_flush+0xbc/0xc4
flush_smp_call_function_queue+0x98/0xcc
do_idle+0x110/0x15c
cpu_startup_entry+0x3c/0x44
secondary_start_kernel+0x138/0x13c
__secondary_switched+0xb0/0xb4
Replace WARN_ON_ONCE() with WARN_ONCE() to print the before and after
values of the softirq pending mask. This allows us to identify exactly
which softirq bit was raised unexpectedly during flush_smp_call_function_queue,
and determine whether it is causing preemption delays.
Signed-off-by: Wen Yang <wen.yang@linux.dev>
---
kernel/softirq.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 5f435c1e48d8..45f9647df5eb 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -356,7 +356,9 @@ void do_softirq_post_smp_call_flush(unsigned int was_pending)
unsigned int is_pending = local_softirq_pending();
if (unlikely(was_pending != is_pending)) {
- WARN_ON_ONCE(was_pending != (is_pending & ~SCHED_SOFTIRQ_MASK));
+ WARN_ONCE(was_pending != (is_pending & ~SCHED_SOFTIRQ_MASK),
+ "Sirq mask changed(#%x -> #%x) may delay preemption.",
+ was_pending, is_pending);
invoke_softirq();
}
}
--
2.25.1
reply other threads:[~2026-03-05 17:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260305170008.26261-1-wen.yang@linux.dev \
--to=wen.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.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