public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Torvald Riegel <triegel@redhat.com>
To: "Ondřej Bílka" <neleai@seznam.cz>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	libc-alpha@sourceware.org,        libc-ports@sourceware.org
Subject: Re: [RFC][BZ #13690] Always read private before lll_unlock.
Date: Wed, 18 Dec 2013 20:43:00 -0000	[thread overview]
Message-ID: <1387399352.23049.11823.camel@triegel.csb> (raw)
In-Reply-To: <20131206194305.GA26401@domone.podge>

On Fri, 2013-12-06 at 20:43 +0100, Ondřej Bílka wrote:
> On Fri, Dec 06, 2013 at 08:01:59PM +0100, Ondřej Bílka wrote:
> > Hi, a related issue to semaphore races is a race in mutex unlocking.
> >
> from bugzilla:
> >
> > On most platforms, lll_unlock() is defined as a macro like this:
> > #define lll_unlock(lock, private) \
> >   ((void) ({						      \
> >     int *__futex = &(lock);				      \
> >     int __val = atomic_exchange_rel (__futex, 0);	      \
> >     if (__builtin_expect (__val > 1, 0))		      \
> >       lll_futex_wake (__futex, 1, private);		      \
> >   }))
> > 
> Which causes this problem that could be avoided by changing macro to
> 
> #define lll_unlock(lock, private) \
>    ((void) ({                                                \
>      int *__futex = &(lock);                                 \
>      int __private = private				     \
> 
> I wrote a prelimitary patch for that, most of lll_unlock macros are
> duplicates so I added a file include/futex_unlock.h with common
> implementation. We should check these for more duplicates and if 
> other functions need similar wrapper.
> 
> Comments?

This needs clarification in POSIX; see my comment on #13690
(https://sourceware.org/bugzilla/show_bug.cgi?id=13690#c24).  Depending
on how the Austin Group decides, this is either not a bug, or we have to
fix the pending load AND investigate whether the pending futex_wake call
is harmless.  The latter might be the case for normal mutexes, but I
wouldn't be surprised to find out that PI or robust mutexes aren't as
simple and need a more complex fix.

Therefore, I think we should wait for the POSIX clarification and then
decide what the next steps should be.

      parent reply	other threads:[~2013-12-18 20:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20131206190159.GA25502@domone.podge>
2013-12-06 19:43 ` Ondřej Bílka
2013-12-06 21:12   ` Mike Frysinger
2013-12-06 21:52     ` Ondřej Bílka
2013-12-18 20:43   ` Torvald Riegel [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=1387399352.23049.11823.camel@triegel.csb \
    --to=triegel@redhat.com \
    --cc=anemo@mba.ocn.ne.jp \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-ports@sourceware.org \
    --cc=neleai@seznam.cz \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).