On Tue, 13 Apr 2021 09:56:40 +0200 Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote: > Thanks for looking into this. > If this is not a kernel bug, then it must not use WARN_ON[_ONCE]. It > makes the kernel untestable for both automated systems and humans: > > https://lwn.net/Articles/769365/ > > <quote> > Greg Kroah-Hartman raised the problem of core kernel API code that > will use WARN_ON_ONCE() to complain about bad usage; that will not > generate the desired result if WARN_ON_ONCE() is configured to crash > the machine. He was told that the code should just call pr_warn() > instead, and that the called function should return an error in such > situations. It was generally agreed that any WARN_ON() or > WARN_ON_ONCE() calls that can be triggered from user space need to be > fixed. > </quote> I agree. WARN_ON(_ONCE) should be reserved for anomalies that should not happen ever. Anything that the user could trigger, should not trigger a WARN_ON. A WARN_ON is perfectly fine for detecting an accounting error inside the kernel. I have them scattered all over my code, but they should never be hit, even if something in user space tries to hit it. (with an exception of an interface I want to deprecate, where I want to know if it's still being used ;-) Of course, that wouldn't help bots testing the code. And I haven't done that in years) Any anomaly that can be triggered by user space doing something it should not be doing really needs a pr_warn(). Thanks, -- Steve