linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Joel Fernandes <joel@joelfernandes.org>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	mingo@kernel.org, gregkh@linuxfoundation.org,
	gustavo@embeddedor.com, tglx@linutronix.de,
	josh@joshtriplett.org, mathieu.desnoyers@efficios.com,
	jiangshanlai@gmail.com
Subject: Re: [PATCH v2 3/9] rcu,tracing: Create trace_rcu_{enter,exit}()
Date: Sat, 15 Feb 2020 06:59:34 -0800	[thread overview]
Message-ID: <20200215145934.GD2935@paulmck-ThinkPad-P72> (raw)
In-Reply-To: <20200214151906.b1354a7ed6b01fc3bf2de862@kernel.org>

On Fri, Feb 14, 2020 at 03:19:06PM +0900, Masami Hiramatsu wrote:
> On Thu, 13 Feb 2020 14:39:18 -0800
> "Paul E. McKenney" <paulmck@kernel.org> wrote:
> 
> > On Thu, Feb 13, 2020 at 05:04:51PM -0500, Steven Rostedt wrote:
> > > On Thu, 13 Feb 2020 13:50:04 -0800
> > > "Paul E. McKenney" <paulmck@kernel.org> wrote:
> > > 
> > > > On Thu, Feb 13, 2020 at 04:38:25PM -0500, Steven Rostedt wrote:
> > > > > [ Added Masami ]
> > > > > 
> > > > > On Thu, 13 Feb 2020 16:19:30 -0500
> > > > > Joel Fernandes <joel@joelfernandes.org> wrote:
> > > > >   
> > > > > > On Thu, Feb 13, 2020 at 12:54:42PM -0800, Paul E. McKenney wrote:  
> > > > > > > On Thu, Feb 13, 2020 at 03:44:44PM -0500, Joel Fernandes wrote:    
> > > > > > > > On Thu, Feb 13, 2020 at 10:56:12AM -0800, Paul E. McKenney wrote:
> > > > > > > > [...]     
> > > > > > > > > > > It might well be that I could make these functions be NMI-safe, but
> > > > > > > > > > > rcu_prepare_for_idle() in particular would be a bit ugly at best.
> > > > > > > > > > > So, before looking into that, I have a question.  Given these proposed
> > > > > > > > > > > changes, will rcu_nmi_exit_common() and rcu_nmi_enter_common() be able
> > > > > > > > > > > to just use in_nmi()?    
> > > > > > > > > > 
> > > > > > > > > > That _should_ already be the case today. That is, if we end up in a
> > > > > > > > > > tracer and in_nmi() is unreliable we're already screwed anyway.    
> > > > > > > > > 
> > > > > > > > > So something like this, then?  This is untested, probably doesn't even
> > > > > > > > > build, and could use some careful review from both Peter and Steve,
> > > > > > > > > at least.  As in the below is the second version of the patch, the first
> > > > > > > > > having been missing a couple of important "!" characters.    
> > > > > > > > 
> > > > > > > > I removed the static from rcu_nmi_enter()/exit() as it is called from
> > > > > > > > outside, that makes it build now. Updated below is Paul's diff. I also added
> > > > > > > > NOKPROBE_SYMBOL() to rcu_nmi_exit() to match rcu_nmi_enter() since it seemed
> > > > > > > > asymmetric.    
> > > > > > > 
> > > > > > > My compiler complained about the static and the __always_inline, so I
> > > > > > > fixed those.  But please help me out on adding the NOKPROBE_SYMBOL()
> > > > > > > to rcu_nmi_exit().  What bad thing happens if we leave this on only
> > > > > > > rcu_nmi_enter()?    
> > > > > > 
> > > > > > It seemed odd to me we were not allowing kprobe on the rcu_nmi_enter() but
> > > > > > allowing it on exit (from a code reading standpoint) so my reaction was to
> > > > > > add it to both, but we could probably keep that as a separate
> > > > > > patch/discussion since it is slightly unrelated to the patch.. Sorry to
> > > > > > confuse the topic.
> > > > > >  
> > > > > 
> > > > > rcu_nmi_enter() was marked NOKPROBE or other reasons. See commit
> > > > > c13324a505c77 ("x86/kprobes: Prohibit probing on functions before
> > > > > kprobe_int3_handler()")
> > > > > 
> > > > > The issue was that we must not allow anything in do_int3() call kprobe
> > > > > code before kprobe_int3_handler() is called. Because ist_enter() (in
> > > > > do_int3()) calls rcu_nmi_enter() it had to be marked NOKPROBE. It had
> > > > > nothing to do with it being RCU nor NMI, but because it was simply
> > > > > called in do_int3().
> > > > > 
> > > > > Thus, there's no reason to make rcu_nmi_exit() NOKPROBE. But a commont
> > > > > to why rcu_nmi_enter() would probably be useful, like below:  
> > > > 
> > > > Thank you, Steve!  Could I please have your Signed-off-by for this?
> > > 
> > > Sure, but it was untested ;-)
> > 
> > No problem!  I will fire up rcutorture on it.  ;-)
> > 
> > But experience indicates that you cannot even make a joke around here.
> > There is probably already someone out there somewhere building a
> > comment-checker based on deep semantic analysis and machine learning.  :-/
> > 
> > > Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > > 
> > > I'd like a Reviewed-by from Masami though.
> > 
> > Sounds good!  Masami, would you be willing to review?
> 
> Yes, the functions before calling kprobe_int3_handler() must not
> be kprobed. It can cause an infinite recursive int3 trapping.
> 
> Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>

Thank you both!

Like this?

							Thanx, Paul

------------------------------------------------------------------------

commit 1817fdc8f4e4bd18c76305c9b937fb0dccbb1583
Author: Steven Rostedt <rostedt@goodmis.org>
Date:   Sat Feb 15 06:54:50 2020 -0800

    rcu: Provide comment for NOKPROBE() on rcu_nmi_enter()
    
    The rcu_nmi_enter() function was marked NOKPROBE() by commit
    c13324a505c77 ("x86/kprobes: Prohibit probing on functions before
    kprobe_int3_handler()") because the do_int3() call kprobe code must
    not be invoked before kprobe_int3_handler() is called.  It turns out
    that ist_enter() (in do_int3()) calls rcu_nmi_enter(), hence the
    marking NOKPROBE() being added to rcu_nmi_enter().
    
    This commit therefore adds a comment documenting this line of reasoning.
    
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
    Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 132b53e..4a885af 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -835,6 +835,12 @@ void rcu_nmi_enter(void)
 		   rdp->dynticks_nmi_nesting + incby);
 	barrier();
 }
+/*
+ * On x86, All functions in do_int3() must be marked NOKPROBE before
+ * kprobe_int3_handler() is called. ist_enter() which is called in do_int3()
+ * before kprobe_int3_handle() happens to call rcu_nmi_enter() which means
+ * that rcu_nmi_enter() must be marked NOKRPOBE.
+ */
 NOKPROBE_SYMBOL(rcu_nmi_enter);
 
 /**

  reply	other threads:[~2020-02-15 14:59 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 21:01 [PATCH v2 0/9] tracing vs rcu vs nmi Peter Zijlstra
2020-02-12 21:01 ` [PATCH v2 1/9] rcu: Rename rcu_irq_{enter,exit}_irqson() Peter Zijlstra
2020-02-12 21:01   ` Peter Zijlstra
2020-02-12 22:38   ` Joel Fernandes
2020-02-12 22:38     ` Joel Fernandes
2020-02-12 21:01 ` [PATCH v2 2/9] rcu: Mark rcu_dynticks_curr_cpu_in_eqs() inline Peter Zijlstra
2020-02-12 21:01   ` Peter Zijlstra
2020-02-12 22:38   ` Joel Fernandes
2020-02-13  1:41     ` Steven Rostedt
2020-02-13 14:25       ` Joel Fernandes
2020-02-12 21:01 ` [PATCH v2 3/9] rcu,tracing: Create trace_rcu_{enter,exit}() Peter Zijlstra
2020-02-12 21:01   ` Peter Zijlstra
2020-02-12 23:20   ` Joel Fernandes
2020-02-13  8:27     ` Peter Zijlstra
2020-02-13 13:31       ` Joel Fernandes
2020-02-13 13:51       ` Paul E. McKenney
2020-02-13 16:40         ` Peter Zijlstra
2020-02-13 18:56           ` Paul E. McKenney
2020-02-13 20:44             ` Joel Fernandes
2020-02-13 20:44               ` Joel Fernandes
2020-02-13 20:54               ` Paul E. McKenney
2020-02-13 21:19                 ` Joel Fernandes
2020-02-13 21:38                   ` Steven Rostedt
2020-02-13 21:38                     ` Steven Rostedt
2020-02-13 21:50                     ` Paul E. McKenney
2020-02-13 21:50                       ` Paul E. McKenney
2020-02-13 22:04                       ` Steven Rostedt
2020-02-13 22:39                         ` Paul E. McKenney
2020-02-14  6:19                           ` Masami Hiramatsu
2020-02-15 14:59                             ` Paul E. McKenney [this message]
2020-02-15 14:59                               ` Paul E. McKenney
2020-02-17  8:55                               ` Masami Hiramatsu
2020-02-17 16:31                                 ` Paul E. McKenney
2020-02-18  4:33                                   ` Masami Hiramatsu
2020-02-18 16:12                                     ` Paul E. McKenney
2020-02-18 16:15                                       ` Mathieu Desnoyers
2020-02-18 16:35                                       ` Steven Rostedt
2020-02-18 17:46                                     ` Steven Rostedt
2020-02-18 17:46                                       ` Steven Rostedt
2020-02-18 20:18                                       ` Paul E. McKenney
2020-02-19  2:45                                         ` Masami Hiramatsu
2020-03-06 18:01                                           ` Masami Hiramatsu
2020-03-06 18:01                                             ` Masami Hiramatsu
2020-03-06 18:47                                             ` Joel Fernandes
2020-03-06 18:47                                               ` Joel Fernandes
2020-03-06 19:11                                             ` Joel Fernandes
2020-03-07  1:58                                               ` Masami Hiramatsu
2020-03-07  1:58                                                 ` Masami Hiramatsu
2020-03-06  0:42                     ` Thomas Gleixner
2020-02-13 21:48                   ` Paul E. McKenney
2020-02-13 22:58                     ` Joel Fernandes
2020-02-13 22:58                       ` Joel Fernandes
2020-02-13 23:55                       ` Steven Rostedt
2020-02-18 19:58               ` Peter Zijlstra
2020-02-18 19:58                 ` Peter Zijlstra
2020-02-18 20:17                 ` Paul E. McKenney
2020-02-18 20:40                   ` Peter Zijlstra
2020-02-18 21:39                     ` Paul E. McKenney
2020-02-19  9:57                       ` Peter Zijlstra
2020-02-19 12:46                         ` Paul E. McKenney
2020-02-12 23:27   ` Joel Fernandes
2020-02-12 23:27     ` Joel Fernandes
2020-02-13  8:28     ` Peter Zijlstra
2020-02-13 18:39       ` Joel Fernandes
2020-02-12 21:01 ` [PATCH v2 4/9] sched,rcu,tracing: Avoid tracing before in_nmi() is correct Peter Zijlstra
2020-02-12 21:01   ` Peter Zijlstra
2020-02-12 21:01 ` [PATCH v2 5/9] x86,tracing: Add comments to do_nmi() Peter Zijlstra
2020-02-12 21:01 ` [PATCH v2 6/9] perf,tracing: Prepare the perf-trace interface for RCU changes Peter Zijlstra
2020-02-12 21:01   ` Peter Zijlstra
2020-02-12 23:28   ` Joel Fernandes
2020-02-13  8:29     ` Peter Zijlstra
2020-02-13 18:38       ` Joel Fernandes
2020-02-12 21:01 ` [PATCH v2 7/9] tracing: Employ trace_rcu_{enter,exit}() Peter Zijlstra
2020-02-12 21:01   ` Peter Zijlstra
2020-02-12 21:01 ` [PATCH v2 8/9] tracing: Remove regular RCU context for _rcuidle tracepoints (again) Peter Zijlstra
2020-02-12 21:01 ` [PATCH v2 9/9] perf,tracing: Allow function tracing when !RCU Peter Zijlstra
2020-02-14  2:28   ` Sergey Senozhatsky
2020-02-14  2:42     ` Sergey Senozhatsky
2020-02-14  3:32       ` Steven Rostedt
2020-02-14  3:32         ` Steven Rostedt
2020-02-14 20:38   ` Kim Phillips
2020-02-14 22:48     ` 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=20200215145934.GD2935@paulmck-ThinkPad-P72 \
    --to=paulmck@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavo@embeddedor.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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).