Skip to content

Commit

Permalink
rcutorture: Occasionally delay readers enough to make RCU force_quies…
Browse files Browse the repository at this point in the history
…cent_state

rcutorture already delays readers, but never for long enough to
make RCU force a quiescent state.  Add an occasional delay of
50ms.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: laijs@cn.fujitsu.com
Cc: dipankar@in.ibm.com
Cc: akpm@linux-foundation.org
Cc: mathieu.desnoyers@polymtl.ca
Cc: josht@linux.vnet.ibm.com
Cc: dvhltc@us.ibm.com
Cc: niv@us.ibm.com
Cc: peterz@infradead.org
LKML-Reference: <12524504772607-git-send-email->
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Josh Triplett authored and Ingo Molnar committed Sep 17, 2009
1 parent b835db1 commit b8d57a7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions kernel/rcutorture.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,17 @@ static int rcu_torture_read_lock(void) __acquires(RCU)

static void rcu_read_delay(struct rcu_random_state *rrsp)
{
long delay;
const long longdelay = 200;
const unsigned long shortdelay_us = 200;
const unsigned long longdelay_ms = 50;

/* We want there to be long-running readers, but not all the time. */
/* We want a short delay sometimes to make a reader delay the grace
* period, and we want a long delay occasionally to trigger
* force_quiescent_state. */

delay = rcu_random(rrsp) % (nrealreaders * 2 * longdelay);
if (!delay)
udelay(longdelay);
if (!(rcu_random(rrsp) % (nrealreaders * 2000 * longdelay_ms)))
mdelay(longdelay_ms);
if (!(rcu_random(rrsp) % (nrealreaders * 2 * shortdelay_us)))
udelay(shortdelay_us);
}

static void rcu_torture_read_unlock(int idx) __releases(RCU)
Expand Down

0 comments on commit b8d57a7

Please sign in to comment.