[PATCH 00/11] x86: WARN() hackery

From: Peter Zijlstra
Date: Sat Jun 07 2025 - 06:05:13 EST


Hi,

Slightly less mad this time :-)

The primary purpose of all this is to get the WARN() printk() and
__warn() calls into the same context. Notably the current state is that
WARN() ends up doing printk() in-place, then takes an exception and has
the exception do the __warn().

The problem with all this is the ONCE logic. Normal WARN_ON_ONCE()
(without the printk) has the ONCE logic in the exception
(__report_bug()). But because WARN() essentially results in two distinct
actions (printk + trap) this cannot work. With the result that
additional ONCE logic is sprinkled around for each such site.

Current proposals look to make this worse by adding KUnit checks for all
this, including regular WARN. Making the per-instance code overhead even
worse.

As such, by moving the printk() into the exception, and having the
exception (__report_bug() in fact) do everything, we get rid of the
external ONCE logic and provide a cental place for additional conditions
without need to litter all the instances.