rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	rcu@vger.kernel.org, urezki@gmail.com, boqun.feng@gmail.com,
	Neeraj Upadhyay <neeraju@codeaurora.org>,
	joel@joelfernandes.org
Subject: Re: [PATCH 2/4] rcu: Remove useless WRITE_ONCE() on rcu_data.exp_deferred_qs
Date: Sat, 18 Sep 2021 00:00:11 +0200	[thread overview]
Message-ID: <20210917220011.GB48873@lothringen> (raw)
In-Reply-To: <20210917181024.GS4156@paulmck-ThinkPad-P17-Gen-1>

On Fri, Sep 17, 2021 at 11:10:24AM -0700, Paul E. McKenney wrote:
> On Thu, Sep 16, 2021 at 11:05:14PM +0200, Frederic Weisbecker wrote:
> > On Thu, Sep 16, 2021 at 09:43:40AM -0700, Paul E. McKenney wrote:
> > > On Thu, Sep 16, 2021 at 02:10:46PM +0200, Frederic Weisbecker wrote:
> > > > This variable is never written nor read remotely. Remove this confusion.
> > > > 
> > > > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> > > > ---
> > > >  kernel/rcu/tree_exp.h | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
> > > > index f3947c49eee7..4266610b4587 100644
> > > > --- a/kernel/rcu/tree_exp.h
> > > > +++ b/kernel/rcu/tree_exp.h
> > > > @@ -255,7 +255,7 @@ static void rcu_report_exp_cpu_mult(struct rcu_node *rnp,
> > > >   */
> > > >  static void rcu_report_exp_rdp(struct rcu_data *rdp)
> > > >  {
> > > > -	WRITE_ONCE(rdp->exp_deferred_qs, false);
> > > > +	rdp->exp_deferred_qs = false;
> > > 
> > > Are you sure that this can never be invoked from an interrupt handler?
> > > And that rdp->exp_deferred_qs is never read from an interrupt handler?
> > > If either can happen, then the WRITE_ONCE() does play a role, right?
> > 
> > Well, the only effect I can imagine is that it can partly prevent from an
> > interrupt to report concurrently the quiescent state during the few
> > instructions before we mask interrupts and lock the node.
> > 
> > That's a micro performance benefit that avoid a second call to
> > rcu_report_exp_cpu_mult() with the extra locking and early exit.
> 
> I am not claiming that current compilers would mess this up, though I
> have learned to have great respect for what future compilers might do...

:)

> 
> > But then that racy interrupt can still happen before we clear exp_deferred_qs.
> > In this case __this_cpu_cmpxchg() would have been more efficient.
> 
> Except that __this_cpu_cmpxchg() would have a possibility of failure,
> and thus an extra branch not needed by WRITE_ONCE().  Or am I missing
> your point here?

Right, but an extra branch that could spare a call to rcu_report_exp_cpu_mult().

Anyway I don't mind the WRITE_ONCE(), but you know how ordering (whether
compiler or CPU) makes me anxious when undocumented or not self-explanatory,
(although arguably the latter can vary depending on the reviewer :)

Thanks.

  reply	other threads:[~2021-09-17 22:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 12:10 [PATCH 0/4] rcu: Unify a bit [non-]PREEMPT expedited quiescent state report Frederic Weisbecker
2021-09-16 12:10 ` [PATCH 1/4] rcu: Ignore rdp.cpu_no_qs.b.exp on premptible RCU's rcu_qs() Frederic Weisbecker
2021-09-16 12:10 ` [PATCH 2/4] rcu: Remove useless WRITE_ONCE() on rcu_data.exp_deferred_qs Frederic Weisbecker
2021-09-16 16:43   ` Paul E. McKenney
2021-09-16 21:05     ` Frederic Weisbecker
2021-09-17 18:10       ` Paul E. McKenney
2021-09-17 22:00         ` Frederic Weisbecker [this message]
2021-09-16 12:10 ` [PATCH 3/4] rcu: Move rcu_data.cpu_no_qs.b.exp reset to rcu_export_exp_rdp() Frederic Weisbecker
2021-09-16 12:10 ` [PATCH 4/4] rcu: Remove rcu_data.exp_deferred_qs and convert to rcu_data.cpu no_qs.b.exp Frederic Weisbecker
2021-09-16 16:40 ` [PATCH 0/4] rcu: Unify a bit [non-]PREEMPT expedited quiescent state report Paul E. McKenney
2021-09-28 18:13 ` Paul E. McKenney

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=20210917220011.GB48873@lothringen \
    --to=frederic@kernel.org \
    --cc=boqun.feng@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neeraju@codeaurora.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=urezki@gmail.com \
    --subject='Re: [PATCH 2/4] rcu: Remove useless WRITE_ONCE() on rcu_data.exp_deferred_qs' \
    /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

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).