mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Multi-threaded performance progress
Date: Wed, 27 Aug 2014 12:47:46 -0400	[thread overview]
Message-ID: <20140827164746.GP12888@brightrain.aerifal.cx> (raw)
In-Reply-To: <1409133190.4476.28.camel@eris.loria.fr>

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).

Rich


      reply	other threads:[~2014-08-27 16:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26  3:43 Rich Felker
2014-08-26  7:04 ` Jens Gustedt
2014-08-26 10:44   ` Szabolcs Nagy
2014-08-26 11:09     ` Jens Gustedt
2014-08-26 16:35   ` Jens Gustedt
2014-08-26 17:32     ` Rich Felker
2014-08-26 17:53     ` Rich Felker
2014-08-26 18:30       ` Jens Gustedt
2014-08-26 19:05         ` Rich Felker
2014-08-26 19:34           ` Jens Gustedt
2014-08-26 20:26             ` Rich Felker
2014-08-26 21:15               ` Jens Gustedt
2014-08-26 21:36                 ` Rich Felker
2014-08-27  9:53                   ` Jens Gustedt
2014-08-27 16:47                     ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140827164746.GP12888@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).