* [PATCH] rcutorture: add random preemption
@ 2010-06-21 8:57 Lai Jiangshan
2010-06-21 16:43 ` Paul E. McKenney
0 siblings, 1 reply; 5+ messages in thread
From: Lai Jiangshan @ 2010-06-21 8:57 UTC (permalink / raw)
To: Paul E. McKenney, Ingo Molnar, Peter Zijlstra, LKML
Add random preemption to help we to torture the preemptable rcu.
srcu_read_delay() also calls rcu_read_delay() for shorter delays.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index 2e2726d..7c81d07 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -303,6 +303,10 @@ static void rcu_read_delay(struct rcu_random_state *rrsp)
mdelay(longdelay_ms);
if (!(rcu_random(rrsp) % (nrealreaders * 2 * shortdelay_us)))
udelay(shortdelay_us);
+#ifdef CONFIG_PREEMPT
+ if (!preempt_count() && !(rcu_random(rrsp) % (nrealreaders * 20000)))
+ preempt_schedule();
+#endif
}
static void rcu_torture_read_unlock(int idx) __releases(RCU)
@@ -536,6 +540,8 @@ static void srcu_read_delay(struct rcu_random_state *rrsp)
delay = rcu_random(rrsp) % (nrealreaders * 2 * longdelay * uspertick);
if (!delay)
schedule_timeout_interruptible(longdelay);
+ else
+ rcu_read_delay(rrsp);
}
static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] rcutorture: add random preemption
2010-06-21 8:57 [PATCH] rcutorture: add random preemption Lai Jiangshan
@ 2010-06-21 16:43 ` Paul E. McKenney
2010-06-21 16:50 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Paul E. McKenney @ 2010-06-21 16:43 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: Ingo Molnar, Peter Zijlstra, LKML
On Mon, Jun 21, 2010 at 04:57:42PM +0800, Lai Jiangshan wrote:
> Add random preemption to help we to torture the preemptable rcu.
>
> srcu_read_delay() also calls rcu_read_delay() for shorter delays.
I do like the change to srcu_read_delay(), good to fall back to the
normal rcu_read_delay() behavior when a long delay is not selected.
The change to rcu_read_delay() looks promising as well, but please see
below for some comments on the other change.
And the big question: did you find any failures when testing with this
change? ;-)
Thanx, Paul
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
> diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
> index 2e2726d..7c81d07 100644
> --- a/kernel/rcutorture.c
> +++ b/kernel/rcutorture.c
> @@ -303,6 +303,10 @@ static void rcu_read_delay(struct rcu_random_state *rrsp)
> mdelay(longdelay_ms);
> if (!(rcu_random(rrsp) % (nrealreaders * 2 * shortdelay_us)))
> udelay(shortdelay_us);
> +#ifdef CONFIG_PREEMPT
> + if (!preempt_count() && !(rcu_random(rrsp) % (nrealreaders * 20000)))
> + preempt_schedule();
> +#endif
This one scared me for a bit -- then I realized that preempt_schedule()
won't actually schedule if preemption is in any way disabled. So the
above really is OK, because Classic RCU and RCU-bh disable preemption.
So, should we have a comment to this effect, or is my hypersensitivity to
RCU semantics unique to me?
> }
>
> static void rcu_torture_read_unlock(int idx) __releases(RCU)
> @@ -536,6 +540,8 @@ static void srcu_read_delay(struct rcu_random_state *rrsp)
> delay = rcu_random(rrsp) % (nrealreaders * 2 * longdelay * uspertick);
> if (!delay)
> schedule_timeout_interruptible(longdelay);
> + else
> + rcu_read_delay(rrsp);
> }
>
> static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rcutorture: add random preemption
2010-06-21 16:43 ` Paul E. McKenney
@ 2010-06-21 16:50 ` Peter Zijlstra
2010-06-21 17:05 ` Paul E. McKenney
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2010-06-21 16:50 UTC (permalink / raw)
To: paulmck; +Cc: Lai Jiangshan, Ingo Molnar, LKML
On Mon, 2010-06-21 at 09:43 -0700, Paul E. McKenney wrote:
> > +#ifdef CONFIG_PREEMPT
> > + if (!preempt_count() && !(rcu_random(rrsp) % (nrealreaders * 20000)))
> > + preempt_schedule();
> > +#endif
>
> This one scared me for a bit -- then I realized that preempt_schedule()
> won't actually schedule if preemption is in any way disabled. So the
> above really is OK, because Classic RCU and RCU-bh disable preemption.
>
> So, should we have a comment to this effect, or is my hypersensitivity to
> RCU semantics unique to me?
Well it seems to do a !preempt_count() test too, so I wouldn't worry too
much about it, still using preempt_schedule() doesn't seem right, why
not use cond_resched()?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rcutorture: add random preemption
2010-06-21 16:50 ` Peter Zijlstra
@ 2010-06-21 17:05 ` Paul E. McKenney
2010-06-21 17:06 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Paul E. McKenney @ 2010-06-21 17:05 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Lai Jiangshan, Ingo Molnar, LKML
On Mon, Jun 21, 2010 at 06:50:11PM +0200, Peter Zijlstra wrote:
> On Mon, 2010-06-21 at 09:43 -0700, Paul E. McKenney wrote:
> > > +#ifdef CONFIG_PREEMPT
> > > + if (!preempt_count() && !(rcu_random(rrsp) % (nrealreaders * 20000)))
> > > + preempt_schedule();
> > > +#endif
> >
> > This one scared me for a bit -- then I realized that preempt_schedule()
> > won't actually schedule if preemption is in any way disabled. So the
> > above really is OK, because Classic RCU and RCU-bh disable preemption.
> >
> > So, should we have a comment to this effect, or is my hypersensitivity to
> > RCU semantics unique to me?
>
> Well it seems to do a !preempt_count() test too, so I wouldn't worry too
> much about it, still using preempt_schedule() doesn't seem right, why
> not use cond_resched()?
My guess is that Lai wants to force a call to rcu_sched_qs() even if
!need_resched(). One reason for doing this would be to put more stress
on preemptible RCU's handling of context switches in RCU read-side
critical sections.
Another approach would be to have some high-priority threads that wake up
periodically, as I plan to make rcutorture do for RCU priority boosting.
Of course, this is not necessarily mutually exclusive with Lai's approach.
Thanx, Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rcutorture: add random preemption
2010-06-21 17:05 ` Paul E. McKenney
@ 2010-06-21 17:06 ` Peter Zijlstra
0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2010-06-21 17:06 UTC (permalink / raw)
To: paulmck; +Cc: Lai Jiangshan, Ingo Molnar, LKML
On Mon, 2010-06-21 at 10:05 -0700, Paul E. McKenney wrote:
> On Mon, Jun 21, 2010 at 06:50:11PM +0200, Peter Zijlstra wrote:
> > On Mon, 2010-06-21 at 09:43 -0700, Paul E. McKenney wrote:
> > > > +#ifdef CONFIG_PREEMPT
> > > > + if (!preempt_count() && !(rcu_random(rrsp) % (nrealreaders * 20000)))
> > > > + preempt_schedule();
> > > > +#endif
> > >
> > > This one scared me for a bit -- then I realized that preempt_schedule()
> > > won't actually schedule if preemption is in any way disabled. So the
> > > above really is OK, because Classic RCU and RCU-bh disable preemption.
> > >
> > > So, should we have a comment to this effect, or is my hypersensitivity to
> > > RCU semantics unique to me?
> >
> > Well it seems to do a !preempt_count() test too, so I wouldn't worry too
> > much about it, still using preempt_schedule() doesn't seem right, why
> > not use cond_resched()?
>
> My guess is that Lai wants to force a call to rcu_sched_qs() even if
> !need_resched().
Ah, d'0h yeah, I'm not having the best of days.. monday or something :-)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-21 17:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-21 8:57 [PATCH] rcutorture: add random preemption Lai Jiangshan
2010-06-21 16:43 ` Paul E. McKenney
2010-06-21 16:50 ` Peter Zijlstra
2010-06-21 17:05 ` Paul E. McKenney
2010-06-21 17:06 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox