All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Fernandes <joel@joelfernandes.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	rostedt@goodmis.org, mingo@kernel.org,
	gregkh@linuxfoundation.org, gustavo@embeddedor.com,
	tglx@linutronix.de, paulmck@kernel.org, josh@joshtriplett.org,
	mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com
Subject: Re: [PATCH v2 3/9] rcu,tracing: Create trace_rcu_{enter,exit}()
Date: Thu, 13 Feb 2020 08:31:12 -0500	[thread overview]
Message-ID: <20200213133112.GD170680@google.com> (raw)
In-Reply-To: <20200213082716.GI14897@hirez.programming.kicks-ass.net>

On Thu, Feb 13, 2020 at 09:27:16AM +0100, Peter Zijlstra wrote:
> On Wed, Feb 12, 2020 at 06:20:05PM -0500, Joel Fernandes wrote:
> > On Wed, Feb 12, 2020 at 10:01:42PM +0100, Peter Zijlstra wrote:
> 
> > > +#define trace_rcu_enter()					\
> > > +({								\
> > > +	unsigned long state = 0;				\
> > > +	if (!rcu_is_watching())	{				\
> > > +		if (in_nmi()) {					\
> > > +			state = __TR_NMI;			\
> > > +			rcu_nmi_enter();			\
> > > +		} else {					\
> > > +			state = __TR_IRQ;			\
> > > +			rcu_irq_enter_irqsave();		\
> > 
> > I think this can be simplified. You don't need to rely on in_nmi() here. I
> > believe for NMI's, you can just call rcu_irq_enter_irqsave() and that should
> > be sufficient to get RCU watching. Paul can correct me if I'm wrong, but I am
> > pretty sure that would work.
> > 
> > In fact, I think a better naming for rcu_irq_enter_irqsave() pair could be
> > (in the first patch):
> > 
> > rcu_ensure_watching_begin();
> > rcu_ensure_watching_end();
> 
> So I hadn't looked deeply into rcu_irq_enter(), it seems to call
> rcu_nmi_enter_common(), but with @irq=true.
> 
> What exactly is the purpose of that @irq argument, and how much will it
> hurt to lie there? Will it come apart if we have @irq != !in_nmi()
> for example?

At least rcu_dynticks_task_exit() and rcu_cleanup_after_idle() seem to be
safe regardless of IRQ or NMI. If they are safe either way, we should
probably get look into removing @irq. But I'm not fully sure and looking
forward to Paul's thought on that.. I would love for us to simplify that as
well if possible.

> There is a comment in there that says ->dynticks_nmi_nesting ought to be
> odd only if we're in NMI. The only place that seems to care is
> rcu_nmi_exit_common(), and that does indeed do something different for
> IRQs vs NMIs.

I know a bit about the counters. I had previously unified it and it passed
RCU torture testing etc. (Didn't get merge as Paul wanted it done slightly
done differently) : https://lore.kernel.org/patchwork/patch/1120022/ . I am
planning to get back to finishing that soon.

About the comment on dynticks_nmi_nesting and counters, you mean this comment
right? The odd value of '1' is just to catch the outer most handler. We need
to enter/exit the EQS (extended QS) state only from the outermost handler. I
believe that would work regardless whether it is NMI and IRQ that are
nesting. If IRQs could nest within other IRQs in Linux, then that could also
very well have used the odd/ even trick.

	/*
	 * If idle from RCU viewpoint, atomically increment ->dynticks
	 * to mark non-idle and increment ->dynticks_nmi_nesting by one.
	 * Otherwise, increment ->dynticks_nmi_nesting by two.  This means
	 * if ->dynticks_nmi_nesting is equal to one, we are guaranteed
	 * to be in the outermost NMI handler that interrupted an RCU-idle
	 * period (observation due to Andy Lutomirski).
	 */

thanks,

 - Joel


  reply	other threads:[~2020-02-13 13:31 UTC|newest]

Thread overview: 63+ 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 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 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 23:20   ` Joel Fernandes
2020-02-13  8:27     ` Peter Zijlstra
2020-02-13 13:31       ` Joel Fernandes [this message]
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:54               ` Paul E. McKenney
2020-02-13 21:19                 ` Joel Fernandes
2020-02-13 21:38                   ` Steven Rostedt
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
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 20:18                                       ` Paul E. McKenney
2020-02-19  2:45                                         ` Masami Hiramatsu
2020-03-06 18:01                                           ` Masami Hiramatsu
2020-03-06 18:47                                             ` Joel Fernandes
2020-03-06 19:11                                             ` Joel Fernandes
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 23:55                       ` Steven Rostedt
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-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 ` [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 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 ` [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 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=20200213133112.GD170680@google.com \
    --to=joel@joelfernandes.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavo@embeddedor.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=paulmck@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 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.