Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty

From: Jan Stancek
Date: Thu Jul 18 2019 - 07:36:54 EST



----- Original Message -----
>
> It's simpler like so:
>
> On Thu, Jul 18, 2019 at 01:04:46PM +0200, Peter Zijlstra wrote:
> > X = 0;
> >
> > rwsem_down_read()
> > for (;;) {
> > set_current_state(TASK_UNINTERRUPTIBLE);
> >
> > X = 1;
> > rwsem_up_write();
> > rwsem_mark_wake()
> > atomic_long_add(adjustment, &sem->count);
> > smp_store_release(&waiter->task, NULL);
> >
> > if (!waiter.task)
> > break;
> >
> > ...
> > }
> >
> > r = X;
> >

I see - it looks possible. Thank you for this example.