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

Peter Zijlstra
2019-10-30T16:09:15Z

On Wed, Oct 30, 2019 at 03:21:10PM +0100, Oleg Nesterov wrote:
> On 10/29, Peter Zijlstra wrote:
> >
> > I like that symmetry, but see below ...
>
> ...
>
> > > void __percpu_up_read(struct percpu_rw_semaphore *sem)
> > > {
> > > smp_mb();
> > >
> > > __this_cpu_dec(*sem->read_count);
> > >
> > preempt_enable();
> > > wake_up(&sem->waiters);
> > preempt_disable()
> >
> > and this (sadly) means there's a bunch of back-to-back
> > preempt_disable()+preempt_enable() calls.
>
> Hmm. Where did these enable+disable come from?
>
> void __percpu_up_read(struct percpu_rw_semaphore *sem)
> {
> smp_mb();
>
> __this_cpu_dec(*sem->read_count);
>
> wake_up(&sem->waiters);
> }
>
> should work just fine?

Not on PREEMPT_RT, because wake_up() will take wait_queue_head::lock,
which is spin_lock_t and turns into a pi_mutex, which we cannot take
with preemption disabled.