From: peterz@infradead.org (Peter Zijlstra)
To: linux-snps-arc@lists.infradead.org
Subject: NMI for ARC
Date: Wed, 28 Sep 2016 22:37:48 +0200 [thread overview]
Message-ID: <20160928203748.GU5012@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <CALCETrXJCGMW7DcAVw5mkfiOce4u+3OM3_QLkE117ewU_Hzpsg@mail.gmail.com>
On Wed, Sep 28, 2016@12:25:11PM -0700, Andy Lutomirski wrote:
> > Yes. If the NMI returns to kernel space you must not attempt preemption
> > for reasons you found :-),
>
> Last time I looked at this, I decided that there was no reason that
> NMIs would ever need to handle preemption. Even if the NMI hit
> interruptible kernel code, anything that would cause preemption to be
> needed would either send an IPI (and thus cause preemption) right
> after the NMI fiinished. NMI handlers themselves have no business
> setting TIF_NEED_RESCHED or similar.
Good point, they don't and therefore you need not bother.
> > if the NMI returns to userspace you should do
> > the normal return to user bits, I think.
>
> x86 does this for simplicity. There was a really nasty corner case
> that I could only figure out how to solve by special casing NMIs from
> user space. I'm not sure that it's actually necessary from a
> non-arch-specific POV to handle all the usual return-to-userspace work
> on NMI. But maybe perf NMIs can send signals?
No it cannot. It uses irq_work (which sends a self-IPI) when it wants to
do signals.
> >> 2. The low level return code, resume_user_mode_begin and/or resume_kernel_mode
> >> require interrupt safety, does that need to be NMI safe as well. We ofcourse want
> >> the very late register restore parts to be non-interruptible, but is this required
> >> before we call prrempt_schedule_irq() off of asm code.
> >
> > Urgh, I'm never quite sure on the details here, I've Cc'ed Andy who
> > might actually know this off the top of his head. I'll try and dig
> > through x86 to see what it does.
>
> On x86, it's quite simple. IRQs are *always* off during the final
> register restore, and we don't re-check for preemption there. x86
> handles preemption after turning off IRQs, and IRQs are guaranteed to
> stay off until we actually return to userspace.
>
> The code is almost entirely in C in arch/x86/entry/common.c. There
> isn't anything particularly x86-speficic in there.
Right, so what I think Vineet is asking is if we need to disable NMIs as
well, we cannot on x86 disable NMIs so no.
WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Vineet Gupta <Vineet.Gupta1@synopsys.com>,
arcml <linux-snps-arc@lists.infradead.org>,
Alexey Brodkin <Alexey.Brodkin@synopsys.com>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: NMI for ARC
Date: Wed, 28 Sep 2016 22:37:48 +0200 [thread overview]
Message-ID: <20160928203748.GU5012@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <CALCETrXJCGMW7DcAVw5mkfiOce4u+3OM3_QLkE117ewU_Hzpsg@mail.gmail.com>
On Wed, Sep 28, 2016 at 12:25:11PM -0700, Andy Lutomirski wrote:
> > Yes. If the NMI returns to kernel space you must not attempt preemption
> > for reasons you found :-),
>
> Last time I looked at this, I decided that there was no reason that
> NMIs would ever need to handle preemption. Even if the NMI hit
> interruptible kernel code, anything that would cause preemption to be
> needed would either send an IPI (and thus cause preemption) right
> after the NMI fiinished. NMI handlers themselves have no business
> setting TIF_NEED_RESCHED or similar.
Good point, they don't and therefore you need not bother.
> > if the NMI returns to userspace you should do
> > the normal return to user bits, I think.
>
> x86 does this for simplicity. There was a really nasty corner case
> that I could only figure out how to solve by special casing NMIs from
> user space. I'm not sure that it's actually necessary from a
> non-arch-specific POV to handle all the usual return-to-userspace work
> on NMI. But maybe perf NMIs can send signals?
No it cannot. It uses irq_work (which sends a self-IPI) when it wants to
do signals.
> >> 2. The low level return code, resume_user_mode_begin and/or resume_kernel_mode
> >> require interrupt safety, does that need to be NMI safe as well. We ofcourse want
> >> the very late register restore parts to be non-interruptible, but is this required
> >> before we call prrempt_schedule_irq() off of asm code.
> >
> > Urgh, I'm never quite sure on the details here, I've Cc'ed Andy who
> > might actually know this off the top of his head. I'll try and dig
> > through x86 to see what it does.
>
> On x86, it's quite simple. IRQs are *always* off during the final
> register restore, and we don't re-check for preemption there. x86
> handles preemption after turning off IRQs, and IRQs are guaranteed to
> stay off until we actually return to userspace.
>
> The code is almost entirely in C in arch/x86/entry/common.c. There
> isn't anything particularly x86-speficic in there.
Right, so what I think Vineet is asking is if we need to disable NMIs as
well, we cannot on x86 disable NMIs so no.
next prev parent reply other threads:[~2016-09-28 20:37 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1445286926.3913.13.camel@synopsys.com>
2015-11-17 9:14 ` local64_cmpxchg() in arc_perf_event_update() Vineet Gupta
2015-11-17 9:14 ` Vineet Gupta
2015-11-17 11:07 ` Peter Zijlstra
2015-11-17 11:07 ` Peter Zijlstra
2015-11-17 11:23 ` Vineet Gupta
2015-11-17 11:23 ` Vineet Gupta
2015-11-17 12:24 ` Peter Zijlstra
2015-11-17 12:24 ` Peter Zijlstra
2015-11-17 12:25 ` Peter Zijlstra
2015-11-17 12:25 ` Peter Zijlstra
2015-11-17 12:53 ` NMI for ARC Vineet Gupta
2015-11-17 12:53 ` Vineet Gupta
2015-11-17 13:15 ` Peter Zijlstra
2015-11-17 13:15 ` Peter Zijlstra
2016-09-28 0:22 ` Vineet Gupta
2016-09-28 0:22 ` Vineet Gupta
2016-09-28 7:16 ` Peter Zijlstra
2016-09-28 7:16 ` Peter Zijlstra
2016-09-28 17:58 ` Vineet Gupta
2016-09-28 17:58 ` Vineet Gupta
2016-09-28 19:25 ` Andy Lutomirski
2016-09-28 19:25 ` Andy Lutomirski
2016-09-28 20:37 ` Peter Zijlstra [this message]
2016-09-28 20:37 ` Peter Zijlstra
2016-09-28 22:26 ` Andy Lutomirski
2016-09-28 22:26 ` Andy Lutomirski
2016-09-28 22:44 ` Vineet Gupta
2016-09-28 22:44 ` Vineet Gupta
2016-09-28 22:47 ` Andy Lutomirski
2016-09-28 22:47 ` Andy Lutomirski
2016-09-29 1:20 ` Vineet Gupta
2016-09-29 1:20 ` Vineet Gupta
2016-09-29 6:43 ` Peter Zijlstra
2016-09-29 6:43 ` Peter Zijlstra
2016-09-29 16:47 ` Vineet Gupta
2016-09-29 16:47 ` Vineet Gupta
2016-09-29 18:54 ` Andy Lutomirski
2016-09-29 18:54 ` Andy Lutomirski
2016-09-29 19:48 ` Vineet Gupta
2016-09-29 19:48 ` Vineet Gupta
2016-09-30 10:49 ` Peter Zijlstra
2016-09-30 10:49 ` Peter Zijlstra
2016-09-29 17:30 ` Andy Lutomirski
2016-09-29 17:30 ` Andy Lutomirski
2015-11-17 13:24 ` local64_cmpxchg() in arc_perf_event_update() Vineet Gupta
2015-11-17 13:24 ` Vineet Gupta
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=20160928203748.GU5012@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=linux-snps-arc@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.