From: Jamie Lokier <jamie@shareable.org>
To: Chuck Ebbert <76306.1226@compuserve.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Futex queue_me/get_user ordering (was: 2.6.10-rc1-mm5 [u])
Date: Mon, 15 Nov 2004 08:08:36 +0000 [thread overview]
Message-ID: <20041115080835.GA22723@mail.shareable.org> (raw)
In-Reply-To: <200411142327_MC3-1-8EB1-E27D@compuserve.com>
Chuck Ebbert wrote:
> On Sun, 14 Nov 2004 at 09:00:23 +0000 Emergency Services Jamie Lokier wrote:
>
> >+ * The basic logical guarantee of a futex is that it blocks ONLY
> >+ * if cond(var) is known to be true at the time of blocking, for
> >+ * any cond. If we queued after testing *uaddr, that would open
> >+ * a race condition where we could block indefinitely with
> >+ * cond(var) false, which would violate the guarantee.
> >+ *
> >+ * A consequence is that futex_wait() can return zero and absorb
> >+ * a wakeup when *uaddr != val on entry to the syscall. This is
> >+ * rare, but normal.
>
> Why can't it absorb a wakeup and still return -EAGAIN when this happens?
> IOW why not apply this patch to the original code?
>
> out_unqueue:
> - /* If we were woken (and unqueued), we succeeded, whatever. */
> - if (!unqueue_me(&q))
> - ret = 0;
> + unqueue_me(&q); /* ignore result from unqueue */
> out_release_sem:
> up_read(¤t->mm->mmap_sem);
> return ret;
Because the number of wakeups reported to FUTEX_WAKE must _exactly_
match the number of wakeups reported to FUTEX_WAIT.
They are like tokens, and for some data structures the return value
mustn't be lost or ignored, because that would break structure
invariants - such as the matching counters in the pthread condvars
which precipitated this thread.
> ...and what is "Emergency Services", BTW?
My little joke, as I wouldn't have known about this if Andrew Morton
hadn't forwarded me the message asking about it (I've been away from l-k).
-- Jamie
next prev parent reply other threads:[~2004-11-15 8:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
[not found] <20041113164048.2f31a8dd.akpm@osdl.org>
2004-11-14 9:00 ` 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
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=20041115080835.GA22723@mail.shareable.org \
--to=jamie@shareable.org \
--cc=76306.1226@compuserve.com \
--cc=linux-kernel@vger.kernel.org \
/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 NNTP newsgroup(s).