]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
rcu: Make rcu_future_needs_gp() check all ->need_future_gps[] elements
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Wed, 18 Apr 2018 21:14:42 +0000 (14:14 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Tue, 15 May 2018 17:29:41 +0000 (10:29 -0700)
Currently, the rcu_future_needs_gp() function checks only the current
element of the ->need_future_gps[] array, which might miss elements that
were offset from the expected element, for example, due to races with
the start or the end of a grace period.  This commit therefore makes
rcu_future_needs_gp() use the need_any_future_gp() macro to check all
of the elements of this array.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Tested-by: Nicholas Piggin <npiggin@gmail.com>
kernel/rcu/tree.c
kernel/rcu/tree.h

index afc5e32f0da4d4664ee1865233a71e71a53a0c40..b05ab63795621b1fdfb1d180d08ea446d6f04f3b 100644 (file)
@@ -720,7 +720,7 @@ static int rcu_future_needs_gp(struct rcu_state *rsp)
        struct rcu_node *rnp = rcu_get_root(rsp);
 
        lockdep_assert_irqs_disabled();
-       return READ_ONCE(need_future_gp_element(rnp, rnp->completed));
+       return need_any_future_gp(rnp);
 }
 
 /*
index 952cd0c223feb6eed184c212c6dfc63174d9eca2..123c30eac8b5b42323cf8ef32b7e5167bd655729 100644 (file)
@@ -169,7 +169,8 @@ struct rcu_node {
        bool __nonzero = false;                                         \
                                                                        \
        for (__i = 0; __i < ARRAY_SIZE((rnp)->need_future_gp); __i++)   \
-               __nonzero = __nonzero || (rnp)->need_future_gp[__i];    \
+               __nonzero = __nonzero ||                                \
+                           READ_ONCE((rnp)->need_future_gp[__i]);      \
        __nonzero;                                                      \
 })