Skip to contentSkip to conversation

softirq: add detail info to WARN in do_softirq_post_smp_call_flush()

PATCH New [email protected] 1 participant 1 message Mar 5

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 softirq: add detail info to WARN in do_softirq_post_smp_call_flush()

From: Wen Yang <[email protected]>

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.

---
 kernel/softirq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/softirq.c +3 -1
index 5f435c1e48d8..45f9647df5eb 100644
@@ -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();
 	}
 }
Signature · 1 line
2.25.1