public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC -rt] Allow rcutorture to handle synchronize_sched()
@ 2007-08-03 18:44 Paul E. McKenney
  2007-08-03 22:38 ` Josh Triplett
  0 siblings, 1 reply; 2+ messages in thread
From: Paul E. McKenney @ 2007-08-03 18:44 UTC (permalink / raw)
  To: linux-rt-users; +Cc: linux-kernel, mingo, dipankar, ego, vatsa, josht

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().

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---

 rcutorture.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff -urpNa -X dontdiff linux-2.6.22.1-rt4/kernel/rcutorture.c linux-2.6.22.1-rt4-rcutorturesched/kernel/rcutorture.c
--- linux-2.6.22.1-rt4/kernel/rcutorture.c	2007-07-21 16:58:22.000000000 -0700
+++ linux-2.6.22.1-rt4-rcutorturesched/kernel/rcutorture.c	2007-08-02 16:38:09.000000000 -0700
@@ -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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH RFC -rt] Allow rcutorture to handle synchronize_sched()
  2007-08-03 18:44 [PATCH RFC -rt] Allow rcutorture to handle synchronize_sched() Paul E. McKenney
@ 2007-08-03 22:38 ` Josh Triplett
  0 siblings, 0 replies; 2+ messages in thread
From: Josh Triplett @ 2007-08-03 22:38 UTC (permalink / raw)
  To: paulmck; +Cc: linux-rt-users, linux-kernel, mingo, dipankar, ego, vatsa

On Fri, 2007-08-03 at 11:44 -0700, Paul E. McKenney wrote:
> 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().
> 
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Acked-by: Josh Triplett <josh@kernel.org>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-03 22:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-03 18:44 [PATCH RFC -rt] Allow rcutorture to handle synchronize_sched() Paul E. McKenney
2007-08-03 22:38 ` Josh Triplett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox