Commit Graph

315 Commits

Author SHA1 Message Date
Michael Kerrisk 1d09c1500f futex.2: Fixes after feedback from Thomas Gleixner
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk ca4e5b2b99 futex.2: Minor wording fixes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk 601399f31f futex.2: Improvements after comments from Darren Hart
Reported-by: Darren Hart <dvhart@infradead.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk adc89a976e futex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk 41b6c6a080 futex.2: srcfix: FIXME
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk c3875d1d3a futex.2: Fixes after review comments from Thomas Gleixner
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk 30239c10a8 futex.2: Various fixes after comments from Thomas Gleixner
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk aab5ca4b64 futex.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk f0a9e8f4ce futex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk 39e9b2e1e4 futex.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk 9cee832c40 futex.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk ac89487996 futex.2: Fixes after review comments from Thomas Gleixner
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk dcb410c3c8 futex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:49 +01:00
Michael Kerrisk 627b50ce7c futex.2: Elaborate on why "requeue" operations can be preferable to FUTEX_WAKE
Cowritten-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 8297383e9e futex.2: Clean-ups and FIXME removeal after feedback from Thomas Gleixner
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 27dd3a6e79 futex.2: Remove warning that FUTEX_REQUEUE is broken
Darren Hart pointed me to the comments from Rich Felker
that there are valid use cases for FUTEX_REQUEUE.

    From: Rich Felker <dalias@libc.org>
    Date: Wed, 29 Oct 2014 22:43:17 -0400
    To: Darren Hart <dvhart@infradead.org>
    Cc: GLIBC Devel <libc-alpha@sourceware.org>, ...
    Subject: Re: Add futex wrapper to glibc?

    On Wed, Oct 29, 2014 at 06:59:15PM -0700, Darren Hart wrote:
    [...]
    > I wonder though... can we not wrap FUTEX_REQUEUE? It's fundamentally
    > broken.  FUTEX_CMP_REQUEUE should *always* be used instead. The glibc
    > wrapper is one way to encourage developers to do the right thing
    > (don't expose the bad op in the header).

    You're mistaken here. There are plenty of valid ways to use
    FUTEX_REQUEUE - for example if the calling thread is requeuing the
    target(s) to a lock that the calling thread owns. Just because it
    doesn't meet the needs of the way glibc was using it internally
    doesn't mean it's useless for other applications.

Reported-by: Darren Hart <dvhart@infradead.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk da56650ae4 futex.2: srcfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk fd1056148b futex.2: Minor wording fixes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 55f9e85ead futex.2: Minor wording fixes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk b0f35fbb09 futex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk c0dc758efd futex.2: Rewrap some source lines (no content changes)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 9d32a39b82 futex.2: Minor wording fixes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk d45f244c6d futex.2: Minor wording fixes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 7e8dcabcb1 futex.2: Reword paragraph describing futex word
Reported-by: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 02f7b623c9 futex.2: NOTES: futexes are also used to implement read-write locks and barriers
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk e0074751c9 futex.2: SEE ALSO: add pthread_mutexattr_getprotocol(3)
Reported-by: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 36a90a75ce futex.2: wfix
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk d6bb5a38db futex.2: Tidy up some FIXMEs
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk cf44281c66 futex.2: Point out that futexes are used to implement higher-level abstractions
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Reported-by: Torvald Riegel <triegel@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 78bbcd9faf futex.2: Remove an obsolete FIXME
Reviewed-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk cabee29d5e futex.2: tfix
Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk e61abc2018 futex.2: tfix
Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk a5c5a06aba futex.2: Clarify return value details
Reporte-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 943ccc5228 futex.2: Remove detail about kernel internals
As commented on by Davidlohr Bueso:

    This to me reads a bit too much into the kernel (fastpath,
    refcnt, vmas). Why not just mention that it avoids overhead
    in the kernel or something? I don't recall any manpage
    mentioning such details, but I could be wrong.

Reported-by: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Heinrich Schuchardt 10022b8e63 futex.2: Casting utime to uint32_t
The kernel uses the following cast:

  if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE ||
      cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP)
    val2 = (u32) (unsigned long) utime;

This ensures that always the least significant four bytes of the
pointer are used, both on ILP32 and LP64 systems.

On a big endian system a simple cast from 64 bit pointer to 32 bit
integer would return the most significant four bytes.

We have to make the reader of the man-page aware of the usage
of the least significant bytes.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Heinrich Schuchardt c6dc40a2c9 futex.2: Use known types
Type u32 is not exposed to the user.  Instead, refer to uint32_t,
which is defined in ISO/IEC 9899:1999.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Heinrich Schuchardt d725ab772e futex.2: tfix
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 78e856927e futex.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Michael Kerrisk 0c3ec26b07 futex.2: Minor wording fixes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Heinrich Schuchardt 8e754e12c5 futex.2: explanation of blocking
Use shorter sentences.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:48 +01:00
Heinrich Schuchardt b80daba225 futex.2: explanation of blocking behavior
Shorten overlong sentence.
Highlight futex().
Tfix.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00
Heinrich Schuchardt 344df36631 futex.2: clarify address mapping
Using the word "physical" address should make the text easier to
make.

Avoid negations like "may not be equal".

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00
Heinrich Schuchardt 594536fb2c futex.2: tfix
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00
Michael Kerrisk 4c8cb0ffe6 futex.2: Rewrap some long source lines
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00
Michael Kerrisk 83e80dda44 futex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00
Heinrich Schuchardt 63ad44cb92 futex.2: simplify example
Do not duplicate coding.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00
Heinrich Schuchardt 92a4669004 futex.2: futex.2: Fix error check in EXAMPLE: fork() fails with -1
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00
Michael Kerrisk 357646628c futex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00
Michael Kerrisk 077981d467 futex.2: Wrap sentences at line boundaries
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00
Michael Kerrisk 74f58a643b futex.2: Explicitly mark FIXMEs added by Torvald Riegel
Mainly so I can keep track of who said what should be fixed/checked

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-15 14:39:47 +01:00