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: Fri, 12 Feb 2021 23:00:39 +0000	[thread overview]
Message-ID: <24e0652b3afa48cdbf7c83287e43c087@hisilicon.com> (raw)
In-Reply-To: <CAK8P3a2adJsz5hRT_eMzSoHnUBC+aK9HZ18=oAYCZ-gisEkd1w@mail.gmail.com>



> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@kernel.org]
> Sent: Saturday, February 13, 2021 11:34 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 Fri, Feb 12, 2021 at 2:18 AM Song Bao Hua (Barry Song)
> <song.bao.hua@hisilicon.com> wrote:
> 
> > So I am requesting comments on:
> > 1. are we expecting all interrupts except NMI to be disabled in irq handler,
> > or do we actually allow some high-priority interrupts between low and NMI
> to
> > come in some platforms?
> 
> I tried to come to an answer but this does not seem particularly well-defined.
> There are a few things I noticed:
> 
> - going through the local_irq_save()/restore() implementations on all
>   architectures, I did not find any other ones besides m68k that leave
>   high-priority interrupts enabled. I did see that at least alpha and openrisc
>   are designed to support that in hardware, but the code just leaves the
>   interrupts disabled.

The case is a little different. Explicit local_irq_save() does disable all
high priority interrupts on m68k. The only difference is arch_irqs_disabled()
of m68k will return true while low-priority interrupts are masked and high
-priority are still open. M68k's hardIRQ also runs in this context with high
priority interrupts enabled.

> 
> - The generic code is clearly prepared to handle nested hardirqs, and
>    the irq_enter()/irq_exit() functions have a counter in preempt_count
>    for the nesting level, using a 4-bit number for hardirq, plus another
>    4-bit number for NMI.

Yes, I understand nested interrupts are supported by an explicit 
local_irq_enable_in_hardirq(). Mk68k's case is different, nested
interrupts can come with arch_irqs_disabled() is true and while
nobody has called local_irq_enable_in_hardirq() in the previous
hardIRQ because hardIRQ keeps high-priority interrupts open.

> 
> - There are a couple of (ancient) drivers that enable interrupts in their
>    interrupt handlers, see the four callers of local_irq_enable_in_hardirq()
>    (all in the old drivers/ide stack) and arch/ia64/kernel/time.c, which
>    enables interupts in its timer function (I recently tried removing this
>    and my patch broke ia64 timers, but I'm not sure if the cause was
>    the local_irq_enable() or something else).
> 
> - The local_irq_enable_in_hardirq() function itself turns into a nop
>   when lockdep is enabled, since d7e9629de051 ("[PATCH] lockdep:
>   add local_irq_enable_in_hardirq() API"). According to the comment
>   in there, lockdep already enforces the behavior you suggest. Note that
>   lockdep support is missing on m68k (and also alpha, h8300, ia64, nios2,
>   and parisc).
> 
> > 2. If either side is true, I think we need to document it somewhere as there
> > is always confusion about this.
> >
> > Personally, I would expect all interrupts to be disabled and I like the way
> > of ARM64 to only use high-priority interrupt as pseudo NMI:
> > https://lwn.net/Articles/755906/
> > Though Finn argued that this will contribute to lose hardware feature of m68k.
> 
> Regardless of what is documented, I would argue that any platform
> that relies on this is at the minimum doing something risky because at
> the minimum this runs into hard to debug code paths that are not
> exercised on any of the common architectures.
> 
>         Arnd


Thanks
Barry


  reply	other threads:[~2021-02-12 23:01 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) [this message]
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)
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=24e0652b3afa48cdbf7c83287e43c087@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).