From: Mark Rutland <mark.rutland@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Juergen Gross <jgross@suse.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] lockdep: report broken irq restoration
Date: Mon, 4 Jan 2021 10:14:02 +0000 [thread overview]
Message-ID: <20210104101402.GA1482@C02TD0UTHF1T.local> (raw)
In-Reply-To: <20201217143640.GZ3040@hirez.programming.kicks-ass.net>
On Thu, Dec 17, 2020 at 03:36:40PM +0100, Peter Zijlstra wrote:
> On Wed, Dec 09, 2020 at 06:33:37PM +0000, Mark Rutland wrote:
> > This means that a seuence such as:
>
> +q
>
> > 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)
> > +#else
> > +#define check_bogus_irq_restore() do { } while (0)
> > +#endif
> > +
> > #define local_irq_enable() do { raw_local_irq_enable(); } while (0)
> > #define local_irq_disable() do { raw_local_irq_disable(); } while (0)
> > #define local_irq_save(flags) do { raw_local_irq_save(flags); } while (0)
> > -#define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
> > +#define local_irq_restore(flags) \
> > + do { \
> > + check_bogus_irq_restore(); \
> > + raw_local_irq_restore(flags); \
> > + } while (0)
>
> Shouldn't that be in raw_local_irq_restore() ?
Yup, that'd be preferable. Note that will require a refactoring here if
we want the warning to be available regardless of CONFIG_TRACE_IRQFLAGS.
I'd intended to rejig that for v2, but I didn't get the chance before
finishing work for the year, and had only done some basic rework in my
WIP (e.g. removing the per-instance bool as per Andy's comments):
https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/commit/?h=fuzzing/5.10-rc7&id=61336e25d1415a4ac3aaf8cf75105c2ec2eb95e7
I'll try to respin that in the next few days if I get the chance.
Thanks,
Mark.
>
> > #define safe_halt() do { raw_safe_halt(); } while (0)
> >
> > #endif /* CONFIG_TRACE_IRQFLAGS */
>
> --- a/include/linux/irqflags.h
> +++ b/include/linux/irqflags.h
> @@ -162,6 +162,7 @@ do { \
> #define raw_local_irq_restore(flags) \
> do { \
> typecheck(unsigned long, flags); \
> + check_bogus_irq_restore(); \
> arch_local_irq_restore(flags); \
> } while (0)
> #define raw_local_save_flags(flags) \
> @@ -235,11 +236,7 @@ extern void warn_bogus_irq_restore(bool
> #define local_irq_enable() do { raw_local_irq_enable(); } while (0)
> #define local_irq_disable() do { raw_local_irq_disable(); } while (0)
> #define local_irq_save(flags) do { raw_local_irq_save(flags); } while (0)
> -#define local_irq_restore(flags) \
> - do { \
> - check_bogus_irq_restore(); \
> - raw_local_irq_restore(flags); \
> - } while (0)
> +#define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
> #define safe_halt() do { raw_safe_halt(); } while (0)
>
> #endif /* CONFIG_TRACE_IRQFLAGS */
prev parent reply other threads:[~2021-01-04 10:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 18:33 [PATCH] lockdep: report broken irq restoration Mark Rutland
2020-12-09 19:05 ` Andy Lutomirski
2020-12-10 11:03 ` Mark Rutland
2020-12-17 14:36 ` Peter Zijlstra
2021-01-04 10:14 ` Mark Rutland [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210104101402.GA1482@C02TD0UTHF1T.local \
--to=mark.rutland@arm.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).