Re: [PATCH 4/5] futex: Avoid taking hb lock if nothing to wakeup

Thomas Gleixner
2013-11-26T13:53:36Z

On Mon, 25 Nov 2013, Darren Hart wrote:
> On Mon, 2013-11-25 at 20:47 +0100, Thomas Gleixner wrote:
> > So now your code melts down to:
> >
> > write(hb->waiters) | write(uaddr)
> > mb | read(hb->waiters)
> > read(uaddr)
> >
> > I fear you simply managed to make the window small enough that your
> > testing was not longer able expose it.
>
> Does seem to be the case.

Actually not. It's protected by an atomic_inc() between the
write(uaddr) and read(hb->waiters) on the waker side.

It took me a while to realize, that get_futex_key_refs() is providing
the protection inadvertently. But as I explained we cannot rely on
that for all architectures.

Thanks,

tglx