linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Song Bao Hua (Barry Song)" <song.bao.hua@hisilicon.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: "tglx@linutronix.de" <tglx@linutronix.de>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"geert@linux-m68k.org" <geert@linux-m68k.org>,
	"funaho@jurai.org" <funaho@jurai.org>,
	"philb@gnu.org" <philb@gnu.org>,
	"corbet@lwn.net" <corbet@lwn.net>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"linux-m68k@lists.linux-m68k.org"
	<linux-m68k@lists.linux-m68k.org>,
	"fthain@telegraphics.com.au" <fthain@telegraphics.com.au>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [RFC] IRQ handlers run with some high-priority interrupts(not NMI) enabled on some platform
Date: Sat, 13 Feb 2021 22:18:31 +0000	[thread overview]
Message-ID: <5961c215d36244a6ad5854ee17f2f496@hisilicon.com> (raw)
In-Reply-To: <CAK8P3a2ZnKeeZ-zEWO+vHogs0DdLuDrZet61cSmJe_UMYhtaWQ@mail.gmail.com>



> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@kernel.org]
> Sent: Sunday, February 14, 2021 5:32 AM
> To: Song Bao Hua (Barry Song) <song.bao.hua@hisilicon.com>
> Cc: tglx@linutronix.de; gregkh@linuxfoundation.org; arnd@arndb.de;
> geert@linux-m68k.org; funaho@jurai.org; philb@gnu.org; corbet@lwn.net;
> mingo@redhat.com; linux-m68k@lists.linux-m68k.org;
> fthain@telegraphics.com.au; linux-kernel@vger.kernel.org
> Subject: Re: [RFC] IRQ handlers run with some high-priority interrupts(not NMI)
> enabled on some platform
> 
> On Sat, Feb 13, 2021 at 12:50 AM Song Bao Hua (Barry Song)
> <song.bao.hua@hisilicon.com> wrote:
> 
> > So I was actually trying to warn this unusual case - interrupts
> > get nested while both in_hardirq() and irqs_disabled() are true.
> >
> > diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
> > index 7c9d6a2d7e90..b8ca27555c76 100644
> > --- a/include/linux/hardirq.h
> > +++ b/include/linux/hardirq.h
> > @@ -32,6 +32,7 @@ static __always_inline void rcu_irq_enter_check_tick(void)
> >   */
> >  #define __irq_enter()                                  \
> >         do {                                            \
> > +               WARN_ONCE(in_hardirq() && irqs_disabled(), "nested
> > interrupts\n"); \
> >                 preempt_count_add(HARDIRQ_OFFSET);      \
> 
> That seems to be a rather heavyweight change in a critical path.
> 
> A more useful change might be to implement lockdep support for m68k
> and see if that warns about any actual problems. I'm not sure
> what is actually missing for that, but these are the commits that
> added it for other architectures in the past:
> 
> 3c4697982982 ("riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT")
> 000591f1ca33 ("csky: Enable LOCKDEP_SUPPORT")
> 78cdfb5cf15e ("openrisc: enable LOCKDEP_SUPPORT and irqflags tracing")
> 8f371c752154 ("xtensa: enable lockdep support")
> bf2d80966890 ("microblaze: Lockdep support")
> 

Yes. M68k lacks lockdep support which might be added.

> > And I also think it is better for m68k's arch_irqs_disabled() to
> > return true only when both low and high priority interrupts are
> > disabled rather than try to mute this warn in genirq by a weaker
> > condition:
> >              if (WARN_ONCE(!irqs_disabled(),"irq %u handler %pS enabled
> interrupts\n",
> >                              irq, action->handler))
> >                        local_irq_disable();
> > }
> >
> > This warn is not activated on m68k because its arch_irqs_disabled() return
> > true though its high-priority interrupts are still enabled.
> 
> Then it would just end up always warning when a nested hardirq happens,
> right? That seems no different to dropping support for nested hardirqs
> on m68k altogether, which of course is what you suggested already.

This won't end up a warning on other architectures like arm,arm64, x86 etc
as interrupts won't come while arch_irqs_disabled() is true in hardIRQ.
For example, I_BIT of CPSR of ARM is set:
static inline int arch_irqs_disabled_flags(unsigned long flags)
{
	return flags & IRQMASK_I_BIT;
}

So it would only give a backtrace on platforms whose arch_irqs_disabled()
return true while only some interrupts are disabled and some others
are still open, thus nested interrupts can come without any explicit
code to enable interrupts.

This warn seems to give consistent interpretation on what's "Run irq
handlers with interrupts disabled" in commit e58aa3d2d0cc (" genirq:
Run irq handlers with interrupts disabled")

> 
>        Arnd

Thanks
Barry

  reply	other threads:[~2021-02-13 22:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-12  1:18 [RFC] IRQ handlers run with some high-priority interrupts(not NMI) enabled on some platform Song Bao Hua (Barry Song)
2021-02-12 22:34 ` Arnd Bergmann
2021-02-12 23:00   ` Song Bao Hua (Barry Song)
2021-02-12 23:05     ` Arnd Bergmann
2021-02-12 23:46       ` Song Bao Hua (Barry Song)
2021-02-13 16:32         ` Arnd Bergmann
2021-02-13 22:18           ` Song Bao Hua (Barry Song) [this message]
2021-02-13 23:18           ` Song Bao Hua (Barry Song)
2021-02-14  5:10             ` Finn Thain
2021-02-15 13:06               ` Andy Shevchenko
2021-02-15 22:22                 ` Finn Thain
2021-02-17 22:41               ` Song Bao Hua (Barry Song)
2021-02-18  5:30                 ` Finn Thain
2021-02-18 11:19                   ` Arnd Bergmann
2021-02-18 12:30                     ` Geert Uytterhoeven
2021-02-18 13:59                       ` Arnd Bergmann
2021-02-18 15:38                         ` Geert Uytterhoeven
2021-02-18 22:11                     ` Michael Schmitz
2021-02-19  8:10                       ` Geert Uytterhoeven
2021-02-19 22:30                         ` Brad Boyer
2021-02-20  6:32                     ` Finn Thain
2021-02-20  7:08                       ` Brad Boyer

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=5961c215d36244a6ad5854ee17f2f496@hisilicon.com \
    --to=song.bao.hua@hisilicon.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=corbet@lwn.net \
    --cc=fthain@telegraphics.com.au \
    --cc=funaho@jurai.org \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=mingo@redhat.com \
    --cc=philb@gnu.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).