Re: Warning from swake_up_all in 4.14.15-rt13 non-RT

From: Sebastian Andrzej Siewior
Date: Mon Mar 12 2018 - 10:11:17 EST


On 2018-03-12 14:27:29 [+0100], Peter Zijlstra wrote:
> On Mon, Mar 12, 2018 at 11:51:13AM +0100, Sebastian Andrzej Siewior wrote:
> > On 2018-03-09 23:26:43 [+0100], Peter Zijlstra wrote:
> > > On Fri, Mar 09, 2018 at 09:25:50PM +0100, Sebastian Andrzej Siewior wrote:
> > > > Is it just about the irqsave() usage or something else? I doubt it is
> > > > the list walk. It is still unbound if not called from irq-off region.
> > >
> > > The current list walk is preemptible. You put the entire iteration (of
> > > unbound length) inside a single critical section which destroy RT.
> >
> > I considered that list walk as cheap. We don't do any wake ups with the
> > list walk - just mark the task for a later wake up. But if it is not I
> > could add an upper limit of 20 iterations or so.
>
> So the problem is that as soon as this is exposed to userspace you've
> lost.

I know. We had this very same problem with clock_nanosleep() which got
solved after timer rework.

> If a user can stack like 10000 tasks on the completion before triggering
> it, you've got yourself a giant !preempt section. Yes the wake_q stuff
> is cheaper, but unbound is still unbound.
>
> wake_all must not be used from !preemptible (IRQ or otherwise) sections.
> And I'm not seeing how waking just the top 20 helps.

I assumed you complained about the unbounded list-walk with interrupts
disabled (which is cheap but unbound is unbound). So here I suggested I
move 20 entries off that list a time and enable interrupts again so an
interrupt could set need_resched.
But if we get invoked !preemptible then nothing changes.

> > > Why isn't this a problem on RT?
> > So we remain in the preempt_disable() section due to RCU-sched so we
> > have this, yes. But the "disabled interrupts" part is due to
> > spin_lock_irqsave() which is a non-issue on RT. So if we managed to get
> > rid of the rcu-sched then the swait can go and we can stick with the
> > wake_up_all() on RT, too.
>
> OK, so for RT we simply loose the IRQ-disable thing, but its still a
> !preemptible section.

exactly. The irqsafe() was to guard non-RT config which uses the same
code.
So do I understand you correctly that irqsafe may remain for !RT config
but that invocation with disabled preemption due to sched_rcu (on RT,
too) must go?

Sebastian