Skip to contentSkip to conversation

Allow rcutorture to handle synchronize_sched()

RFC PATCH In review Paul E. McKenney 2 participants 2 messages Aug 3, 2007

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Allow rcutorture to handle synchronize_sched()

The rcutorture module uses a random-number generator that periodically calls get_random_bytes() to add entropy. This random-number generator is invoked from within the RCU read-side critical section, which, in the case of the synchronize_sched() variant of RCU, has preeemption disabled. Unfortunately, get_random_bytes() ends up acquiring normal spinlocks, which can block in -rt, resulting in very large numbers of "scheduling while atomic" messages.

This patch takes a very crude approach, simply substituting the time of day for get_random_bytes().

---

 rcutorture.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/rcutorture.c +2 -5
diff -urpNa -X dontdiff linux-2.6.22.1-rt4/kernel/rcutorture.c linux-2.6.22.1-rt4-rcutorturesched/kernel/rcutorture.c
@@ -165,16 +165,13 @@ struct rcu_random_state {
 
 /*
  * Crude but fast random-number generator.  Uses a linear congruential
- * generator, with occasional help from get_random_bytes().
+ * generator, with occasional help from the time-of-day clock.
  */
 static unsigned long
 rcu_random(struct rcu_random_state *rrsp)
 {
-	long refresh;
-
 	if (--rrsp->rrs_count < 0) {
-		get_random_bytes(&refresh, sizeof(refresh));
-		rrsp->rrs_state += refresh;
+		rrsp->rrs_state += xtime.tv_nsec;
 		rrsp->rrs_count = RCU_RANDOM_REFRESH;
 	}
 	rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD;
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Paul E. McKenney

The rcutorture module uses a random-number generator that periodically calls get_random_bytes() to add entropy. This random-number generator is invoked from within the RCU read-side critical section, which, in the case of the synchronize_sched() variant of RCU, has preeemption disabled. Unfortunately, get_random_bytes() ends up acquiring normal spinlocks, which can block in -rt, resulting in very large numbers of "scheduling while atomic" messages.

Quoted 4 lines

This patch takes a very crude approach, simply substituting the time of day for get_random_bytes().