Re: [PATCH 5/5] locking/percpu-rwsem: Remove the embedded rwsem

From: Peter Zijlstra
Date: Tue Dec 17 2019 - 05:35:57 EST


On Mon, Nov 18, 2019 at 11:53:04AM -0800, Davidlohr Bueso wrote:
> On Wed, 13 Nov 2019, Peter Zijlstra wrote:
> > @@ -54,23 +52,23 @@ static bool __percpu_down_read_trylock(s
> > * the same CPU as the increment, avoiding the
> > * increment-on-one-CPU-and-decrement-on-another problem.
>
> Nit: Now that you've made read_count more symmetric, maybe this first
> paragraph can be moved down to __percpu_rwsem_trylock() reader side,
> as such:
>
> /*
> * Due to having preemption disabled the decrement happens on
> * the same CPU as the increment, avoiding the
> * increment-on-one-CPU-and-decrement-on-another problem.
> */
> preempt_disable();
> ret = __percpu_down_read_trylock(sem);
> preempt_enable();

There's another callsite for that function too, so I think the current
place still works best.