Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc6db4e6 authored by Darren Hart's avatar Darren Hart Committed by Ingo Molnar
Browse files

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: default avatarDarren 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: default avatarIngo Molnar <mingo@elte.hu>
parent a33a052f
Loading
Loading
Loading
Loading
+10 −13
Original line number Original line Diff line number Diff line
@@ -2102,11 +2102,11 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,
 * We call schedule in futex_wait_queue_me() when we enqueue and return there
 * We call schedule in futex_wait_queue_me() when we enqueue and return there
 * via the following:
 * via the following:
 * 1) wakeup on uaddr2 after an atomic lock acquisition by futex_requeue()
 * 1) wakeup on uaddr2 after an atomic lock acquisition by futex_requeue()
 * 2) wakeup on uaddr2 after a requeue and subsequent unlock
 * 2) wakeup on uaddr2 after a requeue
 * 3) signal (before or after requeue)
 * 3) signal
 * 4) timeout (before or after requeue)
 * 4) timeout
 *
 *
 * If 3, we setup a restart_block with futex_wait_requeue_pi() as the function.
 * If 3, cleanup and return -ERESTARTNOINTR.
 *
 *
 * If 2, we may then block on trying to take the rt_mutex and return via:
 * If 2, we may then block on trying to take the rt_mutex and return via:
 * 5) successful lock
 * 5) successful lock
@@ -2114,7 +2114,7 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,
 * 7) timeout
 * 7) timeout
 * 8) other lock acquisition failure
 * 8) other lock acquisition failure
 *
 *
 * If 6, we setup a restart_block with futex_lock_pi() as the function.
 * If 6, return -EWOULDBLOCK (restarting the syscall would do the same).
 *
 *
 * If 4 or 7, we cleanup and return with -ETIMEDOUT.
 * If 4 or 7, we cleanup and return with -ETIMEDOUT.
 *
 *
@@ -2232,14 +2232,11 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,
			rt_mutex_unlock(pi_mutex);
			rt_mutex_unlock(pi_mutex);
	} else if (ret == -EINTR) {
	} else if (ret == -EINTR) {
		/*
		/*
		 * We've already been requeued, but we have no way to
		 * We've already been requeued, but cannot restart by calling
		 * restart by calling futex_lock_pi() directly. We
		 * futex_lock_pi() directly. We could restart this syscall, but
		 * could restart the syscall, but that will look at
		 * it would detect that the user space "val" changed and return
		 * the user space value and return right away. So we
		 * -EWOULDBLOCK.  Save the overhead of the restart and return
		 * drop back with EWOULDBLOCK to tell user space that
		 * -EWOULDBLOCK directly.
		 * "val" has been changed. That's the same what the
		 * restart of the syscall would do in
		 * futex_wait_setup().
		 */
		 */
		ret = -EWOULDBLOCK;
		ret = -EWOULDBLOCK;
	}
	}