Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 27 Aug 2014 12:47:46 -0400
From: Rich Felker <>
Subject: Re: Multi-threaded performance progress

On Wed, Aug 27, 2014 at 11:53:10AM +0200, Jens Gustedt wrote:
> Am Dienstag, den 26.08.2014, 17:36 -0400 schrieb Rich Felker:
> > Fixing it should be trivial via the design I mentioned earlier: don't
> > use a waiter flag like this, but instead offset the initial value of
> > ref by +1 and a_dec it just before waiting. As in other places, of
> > course, a wake to an invalid address is possible either way; this is
> > "fixable" if necessary via FUTEX_WAKE_OP (having the kernel do the
> > atomic dec after acquiring the futex bin locks).
> generally it would be nice to have such a lock functionality that
> takes care of the waiters inside the int itself, this could perhaps be
> used in other places

Yes. My idea was to have a "__wake_store" function or similar that
wraps FUTEX_WAKE_OP and does a fallback to FUTEX_WAKE if the kernel
lacks FUTEX_WAKE_OP (if there are older kernels that lack it; not
sure). Note that this is less powerful that what I mentioned above,
but you can know before the above a_dec if it will write zero since,
if the value is 1, you're the last thread to modify it. I think most
places where FUTEX_WAKE_OP would be used fit this pattern -- you know
in advance that you're not racing with other atomic writers (or if you
are, they're using a_cas and their cas would fail with the value
you're writing and with the value you're overwriting).


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.