OSDN Git Service

rcu: Make rcu_gp_cleanup() write only once to ->gp_flags
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Sun, 22 Apr 2018 22:06:05 +0000 (15:06 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Thu, 12 Jul 2018 21:25:17 +0000 (14:25 -0700)
At the end of rcu_gp_cleanup(), if another grace period is needed, but
not via rcu_accelerate_cbs(), the ->gp_flags field is written twice,
once when making the new grace-period request, and once when clearing
all other types of requests.  This commit therefore adds an else-clause
to avoid this double write.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
kernel/rcu/tree.c

index 6ce82c0..a9a4a26 100644 (file)
@@ -2117,8 +2117,9 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
                rsp->gp_req_activity = jiffies;
                trace_rcu_grace_period(rsp->name, READ_ONCE(rsp->gpnum),
                                       TPS("newreq"));
+       } else {
+               WRITE_ONCE(rsp->gp_flags, rsp->gp_flags & RCU_GP_FLAG_INIT);
        }
-       WRITE_ONCE(rsp->gp_flags, rsp->gp_flags & RCU_GP_FLAG_INIT);
        raw_spin_unlock_irq_rcu_node(rnp);
 }