linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Torvald Riegel <triegel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Michael Kerrisk (man-pages)"
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
	Carlos O'Donell <carlos-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Darren Hart <dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>,
	Jakub Jelinek <jakub-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	lkml <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Davidlohr Bueso <davidlohr.bueso-VXdhtT5mjnY@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Steven Rostedt <rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org>,
	Peter Zijlstra <peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Linux API <linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Darren Hart <dvhart-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Anton Blanchard <anton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>,
	Petr Baudis <pasky-AlSwsSmVLrQ@public.gmane.org>,
	Eric Dumazet <edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	bill o gallmeister
	<bgallmeister-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Jan Kiszka <jan.kiszka-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>,
	Daniel Wagner <wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>,
	Rich Felker <dalias-8zAoT0mYgF4@public.gmane.org>
Subject: Re: futex(2) man page update help request
Date: Fri, 23 Jan 2015 19:29:48 +0100	[thread overview]
Message-ID: <1422037788.29655.0.camel@triegel.csb> (raw)
In-Reply-To: <54B7D87C.3090901-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Thu, 2015-01-15 at 16:10 +0100, Michael Kerrisk (man-pages) wrote:
> [Adding a few people to CC that have expressed interest in the 
> progress of the updates of this page, or who may be able to
> provide review feedback. Eventually, you'll all get CCed on
> the new draft of the page.]
> 
> Hello Thomas,
> 
> On 05/15/2014 04:14 PM, Thomas Gleixner wrote:
> > On Thu, 15 May 2014, Michael Kerrisk (man-pages) wrote:
> >> And that universe would love to have your documentation of 
> >> FUTEX_WAKE_BITSET and FUTEX_WAIT_BITSET ;-),
> > 
> > I give you almost the full treatment, but I leave REQUEUE_PI to
> > Darren and FUTEX_WAKE_OP to Jakub. :)
> 
> Thank you for the great effort you put into compiling the
> text below, and apologies for my long delay in following up.
> 
> I've integrated almost all of your suggestions into the 
> manual page. I will shortly send out a new draft of the
> page that contains various FIXMEs for points that remain 
> unclear.

Michael, thanks for working on the draft!  I'll review the draft closely
once you've sent it (or have I missed it?).

There are a few things that I'd like to see covered.

First, we should discuss that users, until they control all code in the
respective process, need to expect futexes to be affected by spurious
futex_wake calls; see https://lkml.org/lkml/2014/11/27/472 for
background and Linus' choice (AFAIU) to just document this.
So, for example, a return code of 0 for FUTEX_WAIT can mean either being
woken up by a FUTEX_WAKE intended for this futex, or a stale one
intended for another futex used by, for example, glibc internally.
(Note that as explained in this thread, this isn't just a glibc
artifact, but a result of the general futex design mixed with
destruction requirements for mutexes and other constructs in C++11 and
POSIX.)
It might also be necessary to further consider this when documenting the
errors, because it does affect how to handle them. See this for a glibc
perspective:
https://sourceware.org/ml/libc-alpha/2014-09/msg00381.html

Second, the current documentation for EINTR is that it can happen due to
receiving a signal *or* due to a spurious wake-up.  This is difficult to
handle when implementing POSIX semaphores, because they require that
EINTR is returned from SEM_WAIT if and only if the interruption was due
to a signal.  Thus, if FUTEX_WAIT returns EINTR, the semaphore
implementation can't return EINTR from sem_wait; see this for more
comments, including some discussion why use cases relying on the POSIX
requirement around EINTR are borderline timing-dependent:
https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/sem_waitcommon.c;h=96848d7ac5b6f8f1f3099b422deacc09323c796a;hb=HEAD#l282
Others have commented that aio_suspend has a similar issue; if EINTR
wouldn't in fact be returned spuriously, the POSIX-implementation-side
would get easier.

Third, I think it would be useful to -- somewhere -- explain which
behavior the futex operations would have conceptually when expressed by
C11 code.  We currently say that they wake up, sleep, etc, and which
values they return.  But we never say how to properly synchronize with
them on the userspace side.  The C11 memory model is probably the best
model to use on the userspace side, so that's why I'm arguing for this.
Basically, I think we need to (1) tell people that they should use
memory_order_relaxed accesses to the futex variable (ie, the memory
location associated with the whole futex construct on the kernel side --
or do we have another name for this?), and (2) give some conceptual
guarantees for the kernel-side synchronization so that one use this to
derive how to use them correctly in userspace.

The man pages might not be the right place for this, and maybe we just
need a revision of "Futexes are tricky".  If you have other suggestions
for where to document this, or on the content, let me know.  (I'm also
willing to spend time on this :) ).


Torvald




--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-01-23 18:29 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14 10:35 futex(2) man page update help request Michael Kerrisk (man-pages)
     [not found] ` <537346E5.4050407-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-14 16:18   ` Darren Hart
2014-05-14 19:03     ` Michael Kerrisk (man-pages)
     [not found]       ` <CAKgNAkh+PWzT2SByaLk_OtiAXeZSkWoMgu+ivDOt1dTWVtaatQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-14 19:59         ` Darren Hart
2014-05-14 20:23         ` Carlos O'Donell
     [not found]           ` <5373D0CA.2050204-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-05-14 20:44             ` Andy Lutomirski
2014-05-14 23:34             ` Thomas Gleixner
     [not found]               ` <alpine.DEB.2.02.1405150121230.6261-3cz04HxQygjZikZi3RtOZ1XZhhPuCNm+@public.gmane.org>
2014-05-15  3:12                 ` Carlos O'Donell
     [not found]                   ` <537430B5.2060001-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-05-15  4:49                     ` Michael Kerrisk (man-pages)
2014-05-15  4:53                 ` Michael Kerrisk (man-pages)
     [not found]                   ` <CAKgNAkjQ5Dd_U9OojXdgeforpRevvPHNFAw99kBFPCwHgf7Ggg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-15 14:14                     ` Thomas Gleixner
     [not found]                       ` <alpine.DEB.2.02.1405151144390.6261-3cz04HxQygjZikZi3RtOZ1XZhhPuCNm+@public.gmane.org>
2014-05-15 20:19                         ` Michael Kerrisk (man-pages)
     [not found]                           ` <53752157.9070803-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-08-04 14:46                             ` Carlos O'Donell
2014-05-15 20:35                         ` Darren Hart
     [not found]                           ` <CF9A731D.913E6%dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-01-15 15:12                             ` Michael Kerrisk (man-pages)
     [not found]                               ` <54B7D8D4.2070203-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-17  1:33                                 ` Darren Hart
2015-01-17  9:16                                   ` Michael Kerrisk (man-pages)
     [not found]                                     ` <54BA2872.5040003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-17 19:26                                       ` Darren Hart
     [not found]                                         ` <D0DFF430.B7F94%dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-01-18 10:18                                           ` Michael Kerrisk (man-pages)
2015-01-15 15:10                         ` Michael Kerrisk (man-pages)
     [not found]                           ` <54B7D87C.3090901-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-15 22:23                             ` Thomas Gleixner
2015-01-16 15:17                               ` Michael Kerrisk (man-pages)
     [not found]                                 ` <54B92B71.2090509-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-16 15:20                                   ` Thomas Gleixner
2015-01-16 20:54                                     ` Michael Kerrisk (man-pages)
     [not found]                                       ` <54B97A72.2050205-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-17  0:46                                         ` Darren Hart
     [not found]                                           ` <D0DEECA2.B7EAD%dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-01-19 10:45                                             ` Thomas Gleixner
2015-01-19 14:07                                               ` Michael Kerrisk (man-pages)
2015-01-23 18:19                                             ` Torvald Riegel
2015-01-24 10:05                                               ` Thomas Gleixner
2015-01-24 12:58                                                 ` Torvald Riegel
     [not found]                                                   ` <1422104287.29655.13.camel-I2ZjUw8blINjztcc/or7kQ@public.gmane.org>
2015-01-24 16:25                                                     ` Thomas Gleixner
2015-01-17  0:56                                       ` Davidlohr Bueso
     [not found]                                         ` <1421456216.27134.2.camel-h16yJtLeMjHk1uMJSBkQmQ@public.gmane.org>
2015-01-17  1:11                                           ` Darren Hart
2015-01-23 18:29                             ` Torvald Riegel [this message]
     [not found]                               ` <1422037788.29655.0.camel-I2ZjUw8blINjztcc/or7kQ@public.gmane.org>
2015-01-24 11:35                                 ` Thomas Gleixner
2015-01-24 13:12                                   ` Torvald Riegel
     [not found]                                     ` <1422105142.29655.16.camel-I2ZjUw8blINjztcc/or7kQ@public.gmane.org>
2015-01-27  7:48                                       ` Michael Kerrisk (man-pages)
2015-02-05 19:57                                   ` Darren Hart
2014-05-15  8:13             ` Peter Zijlstra
     [not found]               ` <20140515081357.GC11096-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2014-05-15 15:43                 ` Darren Hart
2014-05-15  8:14             ` Peter Zijlstra
     [not found]               ` <20140515081444.GD11096-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2014-05-15 13:18                 ` Carlos O'Donell
     [not found]                   ` <5374BE9E.8080408-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-05-15 13:22                     ` Peter Zijlstra
     [not found]                       ` <20140515132235.GM30445-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2014-05-15 13:49                         ` Michael Kerrisk (man-pages)
     [not found]                           ` <CAKgNAkjrS8WWMoQzsiOkMVn1_Bf06uFCL6ECU7z=mv0fszg+gQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-15 13:55                             ` Peter Zijlstra
2014-05-15 14:39                             ` Carlos O'Donell
2014-05-15 15:11                               ` Peter Zijlstra
2014-05-14 20:56         ` Davidlohr Bueso
2014-05-14 21:03           ` Darren Hart
     [not found]             ` <CF99279F.907FC%dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-05-14 22:21               ` Paul E. McKenney
     [not found]           ` <1400100977.3865.30.camel-5JQ4ckphU/8SZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
2014-05-15  0:28             ` H. Peter Anvin
2014-05-15  0:35               ` Andy Lutomirski
     [not found]                 ` <CALCETrXzMiS9DwvmZn++wg0x6v-ZR0YP9fAdco4PRST=nTY4nQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-15  0:41                   ` H. Peter Anvin
     [not found]               ` <53740A30.20807-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2014-05-15 19:10                 ` Carlos O'Donell
     [not found]     ` <CF98E3EF.90564%dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-05-14 21:05       ` Davidlohr Bueso
2014-05-15 15:15         ` Joseph S. Myers
2014-05-15  0:18       ` H. Peter Anvin
     [not found]         ` <537407ED.8050606-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2014-05-15  5:21           ` Darren Hart
     [not found]             ` <CF999CD6.90A93%dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-05-15  8:23               ` Peter Zijlstra
2014-05-15 13:46               ` Michael Kerrisk (man-pages)
     [not found]                 ` <5374C54B.7040408-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-15 14:59                   ` H. Peter Anvin
2014-05-15 15:42                 ` chrubis
     [not found]                   ` <20140515154246.GC6926-HSzIOc4LzcM@public.gmane.org>
2014-05-15 15:52                     ` H. Peter Anvin
     [not found]                       ` <5374E2A4.2070408-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2014-05-15 16:01                         ` chrubis-AlSwsSmVLrQ
     [not found]                           ` <20140515160152.GA7529-HSzIOc4LzcM@public.gmane.org>
2014-05-15 16:07                             ` H. Peter Anvin
     [not found]                               ` <5374E653.2080309-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2014-05-15 16:17                                 ` chrubis-AlSwsSmVLrQ
2014-05-15 16:56                                   ` H. Peter Anvin
     [not found]                                     ` <5374F1B3.9080006-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2014-05-15 17:06                                       ` chrubis-AlSwsSmVLrQ
2014-05-15 15:47                 ` Darren Hart
2014-05-15 15:35           ` chrubis-AlSwsSmVLrQ
2014-05-15 15:28       ` chrubis-AlSwsSmVLrQ
     [not found]         ` <20140515152834.GA6926-HSzIOc4LzcM@public.gmane.org>
2014-05-15 15:40           ` Steven Rostedt
2014-05-15 16:14         ` Darren Hart
     [not found]           ` <CF9A3521.90ECC%dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-05-15 16:30             ` chrubis-AlSwsSmVLrQ
     [not found]               ` <20140515163004.GB7959-HSzIOc4LzcM@public.gmane.org>
2014-05-15 18:17                 ` Darren Hart
     [not found]                   ` <CF9A3A75.90F40%dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-05-15 19:05                     ` chrubis-AlSwsSmVLrQ
     [not found]                       ` <20140515190529.GA8887-HSzIOc4LzcM@public.gmane.org>
2014-05-15 19:38                         ` Darren Hart
     [not found]                           ` <CF9A658E.91322%dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-08-11 10:19                             ` chrubis-AlSwsSmVLrQ
2014-11-26 13:41                             ` Cyril Hrubis
2015-02-16 13:14                           ` Cyril Hrubis

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=1422037788.29655.0.camel@triegel.csb \
    --to=triegel-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=anton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=bgallmeister-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=carlos-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dalias-8zAoT0mYgF4@public.gmane.org \
    --cc=davidlohr.bueso-VXdhtT5mjnY@public.gmane.org \
    --cc=dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=dvhart-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=jakub-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jan.kiszka-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mingo-X9Un+BFzKDI@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=pasky-AlSwsSmVLrQ@public.gmane.org \
    --cc=peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org \
    --cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
    --cc=wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.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).