[PATCH] locking/refcounts: Change WARN() to WARN_ONCE()

From: Ingo Molnar
Date: Wed Mar 01 2017 - 03:40:29 EST



* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Mon, Feb 27, 2017 at 11:57 PM, Ingo Molnar <mingo@xxxxxxxxxx> wrote:
> >
> > Note that the uninlining allowed us to enable the underflow/overflow warnings
> > unconditionally and remove the debug Kconfig switch: this might trigger new
> > warnings in buggy code and turn crashes/use-after-free bugs into less harmful
> > memory leaks.
>
> I'm ok with this, but that WARN() really needs to be a WARN_ON_ONCE().
>
> Because once an underflow (or overflow) is happening, it tends to
> _keep_ happening. And you may just have essentially DoS'ed the machine
> that is now spending all its time writing those logs to disk.
>
> Yes, yes, quiet independently of this we should limit WARN printouts
> (and do the reverse: turn a "once" to mean "once in a blue moon"
> rather than actually just once), but particularly for this kind of
> "never happens" thing, it really is better to just warn once.

Good point - I've done this in the attached patch.

Thanks,

Ingo

=================>