Re: [PATCH tip/core/rcu 1/4] sched,rcu: Make cond_resched() provide RCU quiescent state

From: Paul E. McKenney
Date: Thu Oct 05 2017 - 11:11:25 EST


On Thu, Oct 05, 2017 at 12:40:51PM +0200, Peter Zijlstra wrote:
> On Wed, Oct 04, 2017 at 02:50:22PM -0700, Paul E. McKenney wrote:
> > diff --git a/include/linux/sched.h b/include/linux/sched.h
> > index 26a7df4e558c..59688ef3ea23 100644
> > --- a/include/linux/sched.h
> > +++ b/include/linux/sched.h
> > @@ -1565,10 +1565,11 @@ static inline int test_tsk_need_resched(struct task_struct *tsk)
> > * cond_resched_lock() will drop the spinlock before scheduling,
> > * cond_resched_softirq() will enable bhs before scheduling.
> > */
> > +void rcu_all_qs(void);
> > #ifndef CONFIG_PREEMPT
> > extern int _cond_resched(void);
> > #else
> > -static inline int _cond_resched(void) { return 0; }
> > +static inline int _cond_resched(void) { rcu_all_qs(); return 0; }
> > #endif
>
> Why does it need to change PREEMPT? the whole cond_resched() thing
> should be a no-op on PREEMPT.

Let's see... Clearly for RCU-preempt, there is no need. And you are
quite right, if rcu_read_lock_bh() or rcu_read_lock_sched() are preventing
a CPU from context switching, invoking cond_resched() on that CPU would
be a bug anyway.

I will drop this hunk, thank you!

Thanx, Paul