Hang in FUTEX_WAKE_PRIVATE after clock_gettime

valdis.kletnieks at vt.edu valdis.kletnieks at vt.edu
Sat Mar 24 15:07:27 EDT 2018


On Sat, 24 Mar 2018 04:43:42 -0400, Jeffrey Walton said:

> My question is, is a futex with a 2147483647 or -1 expected? Where
> should I be looking to begin to narrow the problem down?

'man 7 futex' says:

   Semantics
       Any futex operation starts in user space, but it may  be  necessary  to
       communicate with the kernel using the futex(2) system call.

       To  "up"  a  futex, execute the proper assembler instructions that will
       cause the host CPU to atomically  increment  the  integer.   Afterward,
       check  if  it has in fact changed from 0 to 1, in which case there were
       no waiters and the operation is done.  This is  the  noncontended  case
       which is fast and should be common.

       In the contended case, the atomic increment changed the counter from -1
       (or some other negative number).  If this is detected, there are  wait-
       ers.   User space should now set the counter to 1 and instruct the ker-
       nel to wake up any waiters using the FUTEX_WAKE operation.

       Waiting on a futex, to "down" it, is the reverse operation.  Atomically
       decrement  the  counter and check if it changed to 0, in which case the
       operation is done and the futex was uncontended.  In all other  circum-
       stances,  the process should set the counter to -1 and request that the
       kernel wait for another process to up the futex.  This  is  done  using
       the FUTEX_WAIT operation.

       The  futex(2) system call can optionally be passed a timeout specifying
       how long the kernel should wait for the futex to  be  upped.   In  this
       case,  semantics  are  more  complex  and the programmer is referred to
       futex(2) for more details.  The same holds for asynchronous futex waiting.

which pretty much says that a negative value means there's somebody waiting
on the futex.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180324/cf28d388/attachment.sig>


More information about the Kernelnewbies mailing list