public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: Frederic Weisbecker <frederic@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	Joel Fernandes <joel@joelfernandes.org>,
	Neeraj Upadhyay <neeraj.upadhyay@amd.com>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	Zqiang <qiang.zhang1211@gmail.com>, rcu <rcu@vger.kernel.org>
Subject: Re: [PATCH 2/3] rcu/exp: Remove confusing needless full barrier on task unblock
Date: Tue, 25 Feb 2025 16:59:08 -0500	[thread overview]
Message-ID: <20250225215908.GA1812344@joelnvbox> (raw)
In-Reply-To: <20250213232559.34163-3-frederic@kernel.org>

On Fri, Feb 14, 2025 at 12:25:58AM +0100, Frederic Weisbecker wrote:
> A full memory barrier in the RCU-PREEMPT task unblock path advertizes
> to order the context switch (or rather the accesses prior to
> rcu_read_unlock()) with the expedited grace period fastpath.
> 
> However the grace period can not complete without the rnp calling into
> rcu_report_exp_rnp() with the node locked. This reports the quiescent
> state in a fully ordered fashion against updater's accesses thanks to:
> 
> 1) The READ-SIDE smp_mb__after_unlock_lock() barrier accross nodes
>    locking while propagating QS up to the root.
> 
> 2) The UPDATE-SIDE smp_mb__after_unlock_lock() barrier while holding the
>    the root rnp to wait/check for the GP completion.
> 
> 3) The (perhaps redundant given step 1) and 2)) smp_mb() in rcu_seq_end()
>    before the grace period completes.
> 
> This makes the explicit barrier in this place superflous. Therefore
> remove it as it is confusing.
> 
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> ---
>  kernel/rcu/tree_plugin.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 3c0bbbbb686f..d51cc7a5dfc7 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -534,7 +534,6 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *t, unsigned long flags)
>  		WARN_ON_ONCE(rnp->completedqs == rnp->gp_seq &&
>  			     (!empty_norm || rnp->qsmask));
>  		empty_exp = sync_rcu_exp_done(rnp);
> -		smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */

I was wondering though, this is a slow path and the smp_mb() has been there
since 2009 or so. Not sure if it is super valuable to remove it at this
point. But we/I should definitely understand it.

I was wondering if you could also point to the fastpath that this is racing
with, it is not immediately clear (to me) what this smp_mb() is pairing with :(

thanks,

 - Joel





>  		np = rcu_next_node_entry(t, rnp);
>  		list_del_init(&t->rcu_node_entry);
>  		t->rcu_blocked_node = NULL;
> -- 
> 2.46.0
> 

  reply	other threads:[~2025-02-25 21:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-13 23:25 [PATCH 0/3] rcu/exp updates Frederic Weisbecker
2025-02-13 23:25 ` [PATCH 1/3] rcu/exp: Protect against early QS report Frederic Weisbecker
2025-02-14  9:10   ` Paul E. McKenney
2025-03-13 16:40     ` Frederic Weisbecker
2025-03-13 17:04       ` Paul E. McKenney
2025-02-13 23:25 ` [PATCH 2/3] rcu/exp: Remove confusing needless full barrier on task unblock Frederic Weisbecker
2025-02-25 21:59   ` Joel Fernandes [this message]
2025-02-26  0:08     ` Paul E. McKenney
2025-02-26 12:52     ` Frederic Weisbecker
2025-02-26 15:04       ` Paul E. McKenney
2025-02-26 15:26         ` Joel Fernandes
2025-02-26 15:34           ` Frederic Weisbecker
2025-02-13 23:25 ` [PATCH 3/3] rcu/exp: Remove needless CPU up quiescent state report Frederic Weisbecker
2025-02-14  9:01   ` Paul E. McKenney
2025-02-14 12:10     ` Frederic Weisbecker
2025-02-15 10:38       ` Paul E. McKenney
2025-02-15 22:23         ` Frederic Weisbecker
2025-02-19 14:58           ` Paul E. McKenney
2025-02-19 15:55             ` Paul E. McKenney
2025-02-21 15:31               ` Frederic Weisbecker
2025-02-21 15:52             ` Frederic Weisbecker
2025-02-26  0:00               ` Paul E. McKenney
2025-03-03 20:10   ` Paul E. McKenney
2025-03-14 14:39     ` Frederic Weisbecker
2025-03-18 17:07       ` 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=20250225215908.GA1812344@joelnvbox \
    --to=joelagnelf@nvidia.com \
    --cc=boqun.feng@gmail.com \
    --cc=frederic@kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neeraj.upadhyay@amd.com \
    --cc=paulmck@kernel.org \
    --cc=qiang.zhang1211@gmail.com \
    --cc=rcu@vger.kernel.org \
    --cc=urezki@gmail.com \
    /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