rcu: Make rcu_start_this_gp() check for out-of-range requests
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Thu, 19 Apr 2018 19:23:34 +0000 (12:23 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Tue, 15 May 2018 17:30:48 +0000 (10:30 -0700)
If rcu_start_this_gp() is invoked with a requested grace period more
than three in the future, then either the ->need_future_gp[] array
needs to be bigger or the caller needs to be repaired.  This commit
therefore adds a WARN_ON_ONCE() checking for this condition.

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

index d3c7695029292113ac19dbf79a1f9a2da23a4a20..07bccb1f0c8777e87fc5c69310e3a6edd0bdd2ba 100644 (file)
@@ -1698,6 +1698,8 @@ static bool rcu_start_this_gp(struct rcu_node *rnp, struct rcu_data *rdp,
        for (rnp_root = rnp; 1; rnp_root = rnp_root->parent) {
                if (rnp_root != rnp)
                        raw_spin_lock_rcu_node(rnp_root);
+               WARN_ON_ONCE(ULONG_CMP_LT(rnp_root->gpnum +
+                                         need_future_gp_mask(), c));
                if (need_future_gp_element(rnp_root, c) ||
                    ULONG_CMP_GE(rnp_root->gpnum, c) ||
                    (rnp != rnp_root &&