public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* cond_resched() and RCU CPU stall warnings
@ 2014-03-16  1:59 Paul E. McKenney
  2014-03-16  6:09 ` Mike Galbraith
  2014-03-17 10:13 ` Peter Zijlstra
  0 siblings, 2 replies; 14+ messages in thread
From: Paul E. McKenney @ 2014-03-16  1:59 UTC (permalink / raw)
  To: peterz, mingo, josh, laijs; +Cc: linux-kernel

So I have been tightening up rcutorture a bit over the past year.
The other day, I came across what looked like a great opportunity for
further tightening, namely the schedule() in rcu_torture_reader().
Why not turn this into a cond_resched(), speeding up the readers a bit
and placing more stress on RCU?

And boy does it increase stress!

Unfortunately, this increased stress sometimes shows up in the form of
lots of RCU CPU stall warnings.  These can appear when an instance of
rcu_torture_reader() gets a CPU to itself, in which case it won't ever
enter the scheduler, and RCU will never see a quiescent state from that
CPU, which means the grace period never ends.

So I am taking a more measured approach to cond_resched() in
rcu_torture_reader() for the moment.

But longer term, should cond_resched() imply a set of RCU
quiescent states?  One way to do this would be to add calls to
rcu_note_context_switch() in each of the various cond_resched() functions.
Easy change, but of course adds some overhead.  On the other hand,
there might be more than a few of the 500+ calls to cond_resched() that
expect that RCU CPU stalls will be prevented (to say nothing of
might_sleep() and cond_resched_lock()).

Thoughts?

(Untested patch below, FWIW.)

							Thanx, Paul

------------------------------------------------------------------------

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b46131ef6aab..994d2b0fd0b2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4075,6 +4075,9 @@ int __sched _cond_resched(void)
 		__cond_resched();
 		return 1;
 	}
+	preempt_disable();
+	rcu_note_context_switch(smp_processor_id());
+	preempt_enable();
 	return 0;
 }
 EXPORT_SYMBOL(_cond_resched);


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

end of thread, other threads:[~2014-03-18 15:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-16  1:59 cond_resched() and RCU CPU stall warnings Paul E. McKenney
2014-03-16  6:09 ` Mike Galbraith
2014-03-16  6:14   ` Mike Galbraith
2014-03-16  6:27     ` Paul E. McKenney
2014-03-16  6:25   ` Paul E. McKenney
2014-03-16  7:30     ` Mike Galbraith
2014-03-17 10:13 ` Peter Zijlstra
2014-03-17 16:58   ` Paul E. McKenney
2014-03-17 17:14     ` Peter Zijlstra
2014-03-18  2:17       ` Paul E. McKenney
2014-03-18  8:51         ` Peter Zijlstra
2014-03-18 12:49           ` Paul E. McKenney
2014-03-18 13:45             ` Peter Zijlstra
2014-03-18 15:15               ` Paul E. McKenney

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