Re: [PATCH 1/2] bug: Provide WARN_ON.*DEFERRED() macros for console deferred output
From: Breno Leitao <leitao@debian.org>
Date: 2026-06-24 08:38:05
Also in:
linux-arch, lkml, sched-ext
Hello Sebastian, First of all thanks for working on it. On Tue, Jun 23, 2026 at 04:26:49PM +0200, Sebastian Andrzej Siewior wrote:
Provide a deferred version of the WARN_ON() macro. It will delay flushing the console until a later context. It is needed in a context where the caller holds locks which can lead to a deadlock content is flushed to the console driver. An example would from a warning from within the scheduler resulting in a wake-up of a task. Deferring the output works by using printk_deferred_enter/ exit() around the printing output. This must be used in a context where the task can't migrate to another CPU. This should be the case usually, since the scheduler would acquire the rq lock whith disabled interrupts, but to be safe preemption is disabled to guarantee this. In order not to bloat the code on architectures which provide an optimized __WARN_FLAGS() define BUGFLAG_DEFERRED which is handled by __report_bug() and does not increase the code size. Provide the DEFERRED macros based on __WARN_FLAGS and __WARN_FLAGS macros. Extend __report_bug() to handle the deferred case.
Have you considered an approach similar to printk_deferred_enter(), where you mark the code region that needs deferral and all WARN() calls within that region are automatically deferred? The current proposal requires changing individual WARN() call sites, but whether they need deferral might depend on the calling context. This means you'd need to convert many call sites and ensure all nested warnings are also converted to the deferred variant. Thanks, --breno