Re: [PATCH v6 02/11] locking/rwsem: Implement a new locking scheme

From: Peter Zijlstra
Date: Wed Oct 11 2017 - 15:36:43 EST


On Wed, Oct 11, 2017 at 02:58:02PM -0400, Waiman Long wrote:
> On 10/11/2017 02:40 PM, Peter Zijlstra wrote:
> > So I implemented rwsem-mutex (also qrwlock based) that puts
> >
> > (unsigned long)current | RWSEM_WRITER
> >
> > in the atomic_long_t rw_semaphore::owner field. The down-side is that
> > you can't do fetch_add based __down_read, because that would clobber the
> > pointer. The up-side is that we have a stable owner pointer (which is
> > what I needed for PI like things).
>
> Without fetch_add for readers, it could lead to reduced performance for
> reader heavy workloads.

Yeah I know.. :-)

> Are you trying to do a PI version of rwsem? It can work when the lock is
> writer owned, but not when it is reader owned.

Not classical PI; there's one of those in -rt btw:

https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/tree/kernel/locking/rwsem-rt.c?h=linux-4.11.y-rt

I'm implementing proxy-execution (or rather, playing with it in a few
spare moments here and there). But yes, it will only be able to boost
write owners. But in order to make that happen I need the lock state and
owner thing in the same field, like mutex.


In any case, I'll try and have a look at these patches.