srcu: Prevent sdp->srcu_gp_seq_needed_exp counter wrap
authorIldar Ismagilov <devix84@gmail.com>
Wed, 31 Jan 2018 19:39:53 +0000 (22:39 +0300)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Wed, 21 Feb 2018 00:21:11 +0000 (16:21 -0800)
SRCU checks each srcu_data structure's grace-period number for counter
wrap four times per cycle by default.  This frequency guarantees that
normal comparisons will detect potential wrap.  However, the expedited
grace-period number is not checked.  The consquences are not too horrible
(a failure to expedite a grace period when requested), but it would be
good to avoid such things.  This commit therefore adds this check to
the expedited grace-period number.

Signed-off-by: Ildar Ismagilov <devix84@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
kernel/rcu/srcutree.c

index 01f4a8bf0e03e7d64d15b25a699a975cef268112..bb9607baad9bdefac88cffaa7a3ff21e9f1a4390 100644 (file)
@@ -579,6 +579,9 @@ static void srcu_gp_end(struct srcu_struct *sp)
                                if (ULONG_CMP_GE(gpseq,
                                                 sdp->srcu_gp_seq_needed + 100))
                                        sdp->srcu_gp_seq_needed = gpseq;
+                               if (ULONG_CMP_GE(gpseq,
+                                                sdp->srcu_gp_seq_needed_exp + 100))
+                                       sdp->srcu_gp_seq_needed_exp = gpseq;
                                spin_unlock_irqrestore_rcu_node(sdp, flags);
                        }
        }