Re: [PATCH v2] kcsan: Don't enter an nbcon emergency section for verbose reports
From: John Ogness
Date: Wed Nov 04 2026 - 07:46:48 EST
On 2026-11-04, Breno Leitao <leitao@xxxxxxxxxx> wrote:
> Since commit 59cd94ef8009 ("lockdep: Mark emergency sections in lockdep
> splats"), print_irqtrace_events() runs inside an nbcon emergency
> section. It is not only used by lockdep splats, though: verbose KCSAN
> reports call it too, and a data race report is not an emergency. Yet in
> an emergency section, every printk() flushes all pending records to the
> nbcon consoles from the calling context, instead of leaving them to the
> printk threads.
Wouldn't the below diff be the proper fix?
John
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index c3dc84a7cef26..71f1b4b8f06d5 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -4245,8 +4245,6 @@ void print_irqtrace_events(struct task_struct *curr)
{
const struct irqtrace_events *trace = &curr->irqtrace;
- nbcon_cpu_emergency_enter();
-
printk("irq event stamp: %u\n", trace->irq_events);
printk("hardirqs last enabled at (%u): [<%px>] %pS\n",
trace->hardirq_enable_event, (void *)trace->hardirq_enable_ip,
@@ -4260,8 +4258,6 @@ void print_irqtrace_events(struct task_struct *curr)
printk("softirqs last disabled at (%u): [<%px>] %pS\n",
trace->softirq_disable_event, (void *)trace->softirq_disable_ip,
(void *)trace->softirq_disable_ip);
-
- nbcon_cpu_emergency_exit();
}
static int HARDIRQ_verbose(struct lock_class *class)
@@ -5797,8 +5793,11 @@ static noinstr void check_flags(unsigned long flags)
}
#endif
- if (!debug_locks)
+ if (!debug_locks) {
+ nbcon_cpu_emergency_enter();
print_irqtrace_events(current);
+ nbcon_cpu_emergency_exit();
+ }
instrumentation_end();
#endif