Re: [PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues

From: Oleg Nesterov
Date: Mon Dec 05 2016 - 12:19:42 EST


On 12/05, Peter Zijlstra wrote:
>
> > + for (;;) {
> > + set_current_state(TASK_UNINTERRUPTIBLE);
> > +
> > + if (readers_active_check(sem))
> > + break;
> > +
> > + schedule();
> > + }
> > +
> > + rcu_assign_pointer(sem->writer, NULL);
>
> And this one does not, and the value being NULL this actually reverts to
> WRITE_ONCE().

Do we really care? We do not even need WRITE_ONCE() afaics, this is like
__set_current_state(TASK_RUNNING) after the main loop. We can't avoid the
spurious wakeups anyway after return from percpu_down_write().

Oleg.