From: Jamie Lokier <jamie@shareable.org>
To: bert hubert <ahu@ds9a.nl>, Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org, rusty@rustcorp.com.au,
mingo@elte.hu, seto.hidetoshi@jp.fujitsu.com
Subject: Re: Futex queue_me/get_user ordering (was: 2.6.10-rc1-mm5 [u])
Date: Mon, 15 Nov 2004 14:12:47 +0000 [thread overview]
Message-ID: <20041115141247.GC25502@mail.shareable.org> (raw)
In-Reply-To: <20041114095051.GA11391@outpost.ds9a.nl>
bert hubert wrote:
> On Sun, Nov 14, 2004 at 09:23:08AM +0000, Jamie Lokier wrote:
>
> > So I don't know if NPTL is buggy, but the pseudo-code given in the bug
> > report is (because of unconditional wake++), and so is the failure
> > example (because it doesn't use a mutex).
>
> Please advise if 'Emergency Services''s update to the manpage is correct
> (two levels up this message thread), if so, I can apply it and forward to
> aeb.
'Emergency Services' was me, if that's what you're asking. I believe
the updates to be correct and I have studied the futex code quite a
lot.
Two more things for the man page. You wrote:
To reiterate, bare futexes are not intended as an easy to use
abstraction for end-users. Implementors are expected to be
assembly literate and to have read the sources of the futex
userspace library referenced below.
I agree they are not intended as an easy to use abstraction. However,
users do not have to be assembly literate, in the sense that it is
possible to write code using futex which is architecture-indepedent.
For mutexes, architecture-dependent locked bus cycles are used, but
some code which uses futex is written in C using counters.
pthread_cond_signal/wait which started this thread is an example. So
I suggest a change to read:
To reiterate, bare futexes are not intended as an easy to use
abstraction for end-users. Implementors are expected to
understand processor memory ordering, barriers and
synchronisation, and to have read the sources of the futex
userspace library referenced below.
Secondly, is it appropriate to add Ulrich Drepper's "Futexes Are
Tricky" paper to SEE ALSO?
"Futexes Are Tricky", Ulrich Drepper, June 2004,
http://people.redhat.com/drepper/futex.pdf
It's a very interesting paper, worth reading. But note that Ulrich's
description of the FUTEX_WAIT operation in that paper is *wrong*:
This means that the operation to wait on a futex is composed of
getting the lock for the futex, checking the current value, if
necessary adding the thread to the wait queue, and releasing the lock.
In fact, waiting does not get the lock for the futex. It relies on
the ordering of (1) adding to the wait queue, (2) checking the current
value, and (3) removing from the wait queue if the value doesn't
match. Among other things, this is necessary because checking the
current value cannot be done with a spinlock held.
The effect is very similar, but not exactly the same.
-- Jamie
next prev parent reply other threads:[~2004-11-15 14:14 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20041113164048.2f31a8dd.akpm@osdl.org>
2004-11-14 9:00 ` Futex queue_me/get_user ordering (was: 2.6.10-rc1-mm5 [u]) Emergency Services Jamie Lokier
2004-11-14 9:09 ` Andrew Morton
2004-11-14 9:23 ` Jamie Lokier
2004-11-14 9:50 ` bert hubert
2004-11-15 14:12 ` Jamie Lokier [this message]
2004-11-16 8:30 ` Futex queue_me/get_user ordering Hidetoshi Seto
2004-11-16 14:58 ` Jamie Lokier
2004-11-18 1:29 ` Hidetoshi Seto
2004-11-15 0:58 ` Hidetoshi Seto
2004-11-15 2:01 ` Jamie Lokier
2004-11-15 3:06 ` Hidetoshi Seto
2004-11-15 13:22 ` Jamie Lokier
2004-11-17 8:47 ` Jakub Jelinek
2004-11-18 2:10 ` Hidetoshi Seto
2004-11-18 7:20 ` Jamie Lokier
2004-11-18 19:47 ` Jakub Jelinek
2005-03-17 10:26 ` Jakub Jelinek
2005-03-17 15:20 ` Jamie Lokier
2005-03-17 15:55 ` Jakub Jelinek
2005-03-18 17:00 ` Ingo Molnar
2005-03-21 2:55 ` Jamie Lokier
2005-03-18 16:53 ` Jakub Jelinek
2004-11-26 17:06 ` Jamie Lokier
2004-11-28 17:36 ` Joe Seigh
2004-11-29 11:24 ` Jakub Jelinek
2004-11-29 21:50 ` Jamie Lokier
2004-11-15 4:24 Futex queue_me/get_user ordering (was: 2.6.10-rc1-mm5 [u]) Chuck Ebbert
2004-11-15 8:08 ` Jamie Lokier
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=20041115141247.GC25502@mail.shareable.org \
--to=jamie@shareable.org \
--cc=ahu@ds9a.nl \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=seto.hidetoshi@jp.fujitsu.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.