rcu: Add random PROVE_RCU_DELAY to grace-period initialization
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Sat, 7 Jul 2012 12:57:03 +0000 (05:57 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Sun, 23 Sep 2012 14:41:55 +0000 (07:41 -0700)
Preemption greatly raised the probability of certain types of race
conditions, so this commit adds an anti-heisenbug to greatly increase
the collision cross section, also known as the probability of occurrence.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
kernel/rcutree.c

index 145f27fe3a1fc8d393dcd8c0b0274ec8f4c88514..f0f3a18c0a2049458f98b10f1ebb3a7d04677b5a 100644 (file)
@@ -52,6 +52,7 @@
 #include <linux/prefetch.h>
 #include <linux/delay.h>
 #include <linux/stop_machine.h>
+#include <linux/random.h>
 
 #include "rcutree.h"
 #include <trace/events/rcu.h>
@@ -1087,6 +1088,10 @@ static int rcu_gp_init(struct rcu_state *rsp)
                                            rnp->level, rnp->grplo,
                                            rnp->grphi, rnp->qsmask);
                raw_spin_unlock_irq(&rnp->lock);
+#ifdef CONFIG_PROVE_RCU_DELAY
+               if ((random32() % (rcu_num_nodes * 8)) == 0)
+                       schedule_timeout_uninterruptible(2);
+#endif /* #ifdef CONFIG_PROVE_RCU_DELAY */
                cond_resched();
        }