Re: [PATCH] locking/percpu_rwsem: Rewrite to not use rwsem

Peter Zijlstra
2019-10-30T18:47:34Z

On Wed, Oct 30, 2019 at 06:52:31PM +0100, Peter Zijlstra wrote:
> On Tue, Oct 29, 2019 at 07:47:39PM +0100, Peter Zijlstra wrote:
> > I've made these changes. Now let me go have a play with that second
> > waitqueue.
>
> What I've ended up with is a 'custom' waitqueue and an rcuwait. The
> rcuwait conveniently got around the tedious preempt_enable/disable
> around the __percpu_up_read() wakeup.
>
> I realized that up_read will only ever have to wake a (single) blocked
> writer, never a series of readers.
>
> Compile tested only, I'll build and boot test once i've had dinner.

It seems to boot and build a kernel, it must be perfect ;-)

I think I'll go split this into a number of smaller patches:

- move lockdep_map into percpu_rwsem and stop using the rwsem one
- use bool
- move the __this_cpu_{inc,dec} into the slowpath
- rework __percpu_down_read() as per your earlier suggestion
- replace rwsem with wait_queue + atomic_t

that might help make all this slightly easier to read.