]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rcu/exp: Remove redundant full memory barrier at the end of GP
authorFrederic Weisbecker <frederic@kernel.org>
Wed, 15 May 2024 12:53:32 +0000 (14:53 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Fri, 28 Jun 2024 13:44:12 +0000 (06:44 -0700)
A full memory barrier is necessary at the end of the expedited grace
period to order:

1) The grace period completion (pictured by the GP sequence
   number) with all preceding accesses. This pairs with rcu_seq_end()
   performed by the concurrent kworker.

2) The grace period completion and subsequent post-GP update side
   accesses. Pairs again against rcu_seq_end().

This full barrier is already provided by the final sync_exp_work_done()
test, making the subsequent explicit one redundant. Remove it and
improve comments.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
kernel/rcu/tree_exp.h

index 1dbad2442e8decb47fe4cca11253f103d73c4a95..4acd29d16fdb999af51ef5cf65e6998640c4e221 100644 (file)
@@ -265,7 +265,12 @@ static bool sync_exp_work_done(unsigned long s)
 {
        if (rcu_exp_gp_seq_done(s)) {
                trace_rcu_exp_grace_period(rcu_state.name, s, TPS("done"));
-               smp_mb(); /* Ensure test happens before caller kfree(). */
+               /*
+                * Order GP completion with preceding accesses. Order also GP
+                * completion with post GP update side accesses. Pairs with
+                * rcu_seq_end().
+                */
+               smp_mb();
                return true;
        }
        return false;
@@ -967,7 +972,6 @@ void synchronize_rcu_expedited(void)
        rnp = rcu_get_root();
        wait_event(rnp->exp_wq[rcu_seq_ctr(s) & 0x3],
                   sync_exp_work_done(s));
-       smp_mb(); /* Work actions happen before return. */
 
        /* Let the next expedited grace period start. */
        mutex_unlock(&rcu_state.exp_mutex);