Commit cc6db4e60116c1f76577b6850a35ae7de69a95b6

Authored by Darren Hart
Committed by Ingo Molnar
1 parent a33a052f19

futex: Correct futex_wait_requeue_pi() commentary

The state machine described in the comments wasn't updated with
a follow-on fix.  Address that and cleanup the corresponding
commentary in the function.

Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
LKML-Reference: <4A737C2A.9090001@us.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 1 changed file with 10 additions and 13 deletions Side-by-side Diff

... ... @@ -2102,11 +2102,11 @@
2102 2102 * We call schedule in futex_wait_queue_me() when we enqueue and return there
2103 2103 * via the following:
2104 2104 * 1) wakeup on uaddr2 after an atomic lock acquisition by futex_requeue()
2105   - * 2) wakeup on uaddr2 after a requeue and subsequent unlock
2106   - * 3) signal (before or after requeue)
2107   - * 4) timeout (before or after requeue)
  2105 + * 2) wakeup on uaddr2 after a requeue
  2106 + * 3) signal
  2107 + * 4) timeout
2108 2108 *
2109   - * If 3, we setup a restart_block with futex_wait_requeue_pi() as the function.
  2109 + * If 3, cleanup and return -ERESTARTNOINTR.
2110 2110 *
2111 2111 * If 2, we may then block on trying to take the rt_mutex and return via:
2112 2112 * 5) successful lock
... ... @@ -2114,7 +2114,7 @@
2114 2114 * 7) timeout
2115 2115 * 8) other lock acquisition failure
2116 2116 *
2117   - * If 6, we setup a restart_block with futex_lock_pi() as the function.
  2117 + * If 6, return -EWOULDBLOCK (restarting the syscall would do the same).
2118 2118 *
2119 2119 * If 4 or 7, we cleanup and return with -ETIMEDOUT.
2120 2120 *
... ... @@ -2232,14 +2232,11 @@
2232 2232 rt_mutex_unlock(pi_mutex);
2233 2233 } else if (ret == -EINTR) {
2234 2234 /*
2235   - * We've already been requeued, but we have no way to
2236   - * restart by calling futex_lock_pi() directly. We
2237   - * could restart the syscall, but that will look at
2238   - * the user space value and return right away. So we
2239   - * drop back with EWOULDBLOCK to tell user space that
2240   - * "val" has been changed. That's the same what the
2241   - * restart of the syscall would do in
2242   - * futex_wait_setup().
  2235 + * We've already been requeued, but cannot restart by calling
  2236 + * futex_lock_pi() directly. We could restart this syscall, but
  2237 + * it would detect that the user space "val" changed and return
  2238 + * -EWOULDBLOCK. Save the overhead of the restart and return
  2239 + * -EWOULDBLOCK directly.
2243 2240 */
2244 2241 ret = -EWOULDBLOCK;
2245 2242 }