Re: [PATCH] Support resetting WARN_ONCE for all architectures

From: Andrew Morton
Date: Fri Nov 03 2017 - 13:48:00 EST


On Fri, 03 Nov 2017 20:38:03 +1100 Michael Ellerman <mpe@xxxxxxxxxxxxxx> wrote:

> Hi Andi,
>
> Thanks for making it work with the flag, but ...
>
> Andi Kleen <andi@xxxxxxxxxxxxxx> writes:
> > diff --git a/lib/bug.c b/lib/bug.c
> > index a6a1137d06db..7cb2d41845f7 100644
> > --- a/lib/bug.c
> > +++ b/lib/bug.c
> > @@ -195,3 +195,24 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
> >
> > return BUG_TRAP_TYPE_BUG;
> > }
> > +
> > +static void clear_once_table(struct bug_entry *start, struct bug_entry *end)
> > +{
> > + struct bug_entry *bug;
> > +
> > + for (bug = start; bug < end; bug++)
> > + bug->flags &= ~BUGFLAG_ONCE;
>
> Clearing BUGFLAG_ONCE removes the once-ness permanently. ie. it becomes
> a WARN().
>
> You should be clearing BUGFLAG_DONE, which is the flag that says this
> WARN has already triggered.

This?

--- a/lib/bug.c~support-resetting-warn_once-for-all-architectures-v2-fix-fix-fix
+++ a/lib/bug.c
@@ -202,7 +202,7 @@ static void clear_once_table(struct bug_
struct bug_entry *bug;

for (bug = start; bug < end; bug++)
- bug->flags &= ~BUGFLAG_ONCE;
+ bug->flags &= ~BUGFLAG_DONE;
}

void generic_bug_clear_once(void)


And this is getting a bit nutty:

support-resetting-warn_once.patch
support-resetting-warn_once-checkpatch-fixes.patch
support-resetting-warn_once-for-all-architectures.patch
support-resetting-warn_once-for-all-architectures-v2.patch
support-resetting-warn_once-for-all-architectures-v2-fix.patch
support-resetting-warn_once-for-all-architectures-v2-fix-fix.patch
support-resetting-warn_once-for-all-architectures-v2-fix-fix-fix.patch

I'll push all this at Stephen later today. Someone please tell me
whether this code actually works!