Re: [PATCH] firmware: wake all waiters
From: Peter Zijlstra
Date: Wed Jul 05 2017 - 12:18:21 EST
On Tue, Jun 27, 2017 at 01:30:30AM +0200, Luis R. Rodriguez wrote:
> > But the *only* reason for swait is extreme memory issues and some very
> > special realtime issues, where it saves a couple of bytes in
> > structures that need close packing, and doesn't even use normal
> > spinlocks, so it saves a couple of cycles at wakeup/sleep because it
> > doesn't do a good job in general.
Yes, its about real-time. But it shouldn't be _that_ special purpose.
So swait should be capable of most things people want from a waitqueue.
Things it explicitly does not do are things like:
- custom wake functions
- exclusive mode
- mixing different sleep types on a queue (which I would recommend
against in any case).
But only very few people need those.
> > The "avoid normal spinlocks" is because it is meant for code that is
> > *so* special that it needs the magical low-level raw spinlocks.
> > I think the two valid users are RCU (which needed it for RT), and kvm
> > (which also needed it for similar issues - it needs to be
> > non-preemptible).
Right, so we need the raw_spinlock in order to run from non-preemptible
code on RT. And we then also need bounded runtimes on stuff.
The only function which is affected by that is swake_up_all(), that does
an unbounded list iteration and is therefore required to be called from
the schedulable context (so we can drop the lock and gain bounds on the
preemption latency).
But aside of all that, it should provide 'everything' people want from a
bog standard regular waitqueue. So I don't see why people shouldn't use
it more.
In any case, I'm not seeing why you call it idiotic.