Re: [PATCH] lockdep: report broken irq restoration
From: Mark Rutland
Date: Thu Dec 10 2020 - 06:04:56 EST
On Wed, Dec 09, 2020 at 11:05:21AM -0800, Andy Lutomirski wrote:
> On Wed, Dec 9, 2020 at 10:33 AM Mark Rutland <mark.rutland@xxxxxxx> wrote:
> > diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h
> > index 3ed4e8771b64..bca3c6fa8270 100644
> > --- a/include/linux/irqflags.h
> > +++ b/include/linux/irqflags.h
> > @@ -220,10 +220,26 @@ do { \
> >
> > #else /* !CONFIG_TRACE_IRQFLAGS */
> >
> > +#ifdef CONFIG_DEBUG_IRQFLAGS
> > +extern void warn_bogus_irq_restore(bool *warned);
> > +#define check_bogus_irq_restore() \
> > + do { \
> > + static bool __section(".data.once") __warned; \
> > + if (unlikely(!raw_irqs_disabled())) \
> > + warn_bogus_irq_restore(&__warned); \
> > + } while (0)
>
> What's the benefit of having a per-caller __warned instead of just
> having a single global one in warn_bogus_irq_restore()?
I'd copied that from the previous proposal, and had assumed that if we
had several distinct violations we'd want to report all of them in one
boot session. I'm perfectly happy to get rid of that and make
warn_bogus_irq_restore() use WARN_ONCE() directly.
I'm using this with a local Syzkaller instance, and as that will kill
the kernel on the first WARN() anyway, it makes no difference to me. I
guess in the field having a single warning is likely to be good enough
too.
Thanks,
Mark.