Re: [PATCH tip/sched/core] Add comments to aid in safer usage of swake_up.

Paul E. McKenney
2017-06-16T03:09:21Z

On Fri, Jun 16, 2017 at 09:07:57AM +0800, Boqun Feng wrote:
> On Thu, Jun 15, 2017 at 10:56:29AM -0700, Paul E. McKenney wrote:
> [...]
> > > >
> > > > FWLIW, I agree. There was a smb_mb() in RT-linux's equivalent of
> > > > swait_activate().
> > > >
> > > > https://www.spinics.net/lists/linux-rt-users/msg10340.html
> > > >
> > > > If the barrier goes in swait_active() then we don't have to require all
> > > > of the callers of swait_active and swake_up to issue the barrier
> > > > instead. Handling this in swait_active is likely to be less error
> > > > prone. Though, we could also do something like wq_has_sleeper() and use
> > > > that preferentially in swake_up and its variants.
> > > >
> > >
> > > I think it makes more sense that we delete the swait_active() in
> > > swake_up()? Because we seems to encourage users to do the quick check on
> > > wait queue on their own, so why do the check again in swake_up()?
> > > Besides, wake_up() doesn't call waitqueue_activie() outside the lock
> > > critical section either.
> > >
> > > So how about the patch below(Testing is in progress)? Peter?
> >
> > It is quite possible that a problem I am seeing is caused by this, but
> > there are reasons to believe otherwise. And in any case, the problem is
> > quite rare, taking tens or perhaps even hundreds of hours of rcutorture
> > to reproduce.
> >
> > So, would you be willing to create a dedicated swait torture test to check
> > this out? The usual approach would be to create a circle of kthreads,
> > with each waiting on the previous kthread and waking up the next one.
> > Each kthread, after being awakened, checks a variable that its waker
> > sets just before the wakeup. Have another kthread check for hangs.
> >
> > Possibly introduce timeouts and random delays to stir things up a bit.
> >
> > But maybe such a test already exists. Does anyone know of one? I don't
> > see anything obvious.
> >
>
> Your waketorture patchset[1] seems to be something similar, at least a
> good start ;-)

Glad I could help! ;-)

> As we don't know which kind of scenario will trigger the problem easily,
> I will play around with different ones, and hopefully we can find a way.

Makes sense, please let me know how it goes!

Thanx, Paul

> Regards,
> Boqun
>
> [1]: https://marc.info/?l=linux-kernel&m=146602969518960
>
> > Interested?
> >
> > Thanx, Paul
> >
> …