mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
	eupm90@gmail.com, linux-kernel@vger.kernel.org, x86@kernel.org,
	Andy Lutomirski <luto@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: #PF from NMI
Date: Fri, 13 Nov 2020 17:05:26 -0800	[thread overview]
Message-ID: <20201114010526.GK3249@paulmck-ThinkPad-P72> (raw)
In-Reply-To: <87ima8luix.fsf@nanos.tec.linutronix.de>

On Sat, Nov 14, 2020 at 12:13:58AM +0100, Thomas Gleixner wrote:
> On Fri, Nov 13 2020 at 13:53, Peter Zijlstra wrote:
> > [  139.226724] WARNING: CPU: 9 PID: 2290 at kernel/rcu/tree.c:932 __rcu_irq_enter_check_tick+0x84/0xd0
> > [  139.226753]  irqentry_enter+0x25/0x40
> > [  139.226753]  exc_page_fault+0x38/0x4c0
> > [  139.226753]  asm_exc_page_fault+0x1e/0x30
> 
> ...
> 
> > [  139.226757]  perf_callchain_user+0xf4/0x280
> >
> > Which is a #PF from NMI context, which is perfectly fine. However
> > __rcu_irq_enter_check_tick() is triggering WARN.
> >
> > AFAICT the right thing is to simply remove the warn like so.
> >
> > ---
> > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > index 430ba58d8bfe..9bda92d8b914 100644
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -928,8 +928,8 @@ void __rcu_irq_enter_check_tick(void)
> >  {
> >  	struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
> >  
> > -	 // Enabling the tick is unsafe in NMI handlers.
> > -	if (WARN_ON_ONCE(in_nmi()))
> > +	// if we're here from NMI, there's nothing to do.
> > +	if (in_nmi())
> >  		return;
> >  
> >  	RCU_LOCKDEP_WARN(rcu_dynticks_curr_cpu_in_eqs(),
> 
> Yes. That's right.
> 
> To answer Pauls question:
> 
> > But is a corresponding change required on return-from-NMI side?
> > Looks OK to me at first glance, but I could be missing something.
> 
> No. The corresponding issue is not return from NMI. The corresponding
> problem is the return from the page fault handler, but there is nothing
> to worry about. That part is NMI safe already.

In that case:

Reviewed-by: Paul E. McKenney <paulmck@kernel.org>

Or let me know (and get me a Signed-off-by) if you want me to take it.

							Thanx, Paul

> And Luto's as well:
> 
> > with the following caveat that has nothing to do with NMI: the rest of
> > irqentry_enter() has tracing calls in it. Does anything prevent
> > infinite recursion if one of those tracing calls causes a page fault?
> 
> nmi:
>   ...
>   trace_hardirqs_off_finish() {
>     if (!this_cpu_read(tracing_irq_cpu)) {
>            this_cpu_write(tracing_irq_cpu, 1);
>            ...
>   }
>   ...
>   perf()
> 
> #PF
>   save_cr2()
>   
>   irqentry_enter()
>      trace_hardirqs_off_finish()
>         if (!this_cpu_read(tracing_irq_cpu)) {
> 
> So yes, it is recursion protected unless I'm missing something.
> 
> Thanks,
> 
>         tglx

  reply	other threads:[~2020-11-14  1:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 12:53 Peter Zijlstra
2020-11-13 17:16 ` Paul E. McKenney
2020-11-13 17:23 ` Andy Lutomirski
2020-11-13 23:13 ` Thomas Gleixner
2020-11-14  1:05   ` Paul E. McKenney [this message]
2020-11-16 12:10     ` [PATCH] rcu: Allow rcu_irq_enter_check_tick() " Peter Zijlstra
2020-11-16 17:24       ` Thomas Gleixner
2020-11-16 20:00         ` Paul E. McKenney
2020-11-16 16:46   ` #PF " Steven Rostedt

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=20201114010526.GK3249@paulmck-ThinkPad-P72 \
    --to=paulmck@kernel.org \
    --cc=eupm90@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®