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

From: Thomas Gleixner
Date: Tue Nov 26 2013 - 08:53:40 EST


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








--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/