Skip to contentSkip to conversation

futex: futex_wait_requeue_pi commentary corrections

PATCH Superseded Darren Hart 1 participant 2 messages Jul 31, 2009

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 futex: futex_wait_requeue_pi commentary corrections

futex: futex_wait_requeue_pi commentary corrections

From: Darren Hart <[email protected]>

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.

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>

---

kernel/futex.c | 23 ++++++++++-------------

1 files changed, 10 insertions(+), 13 deletions(-)
kernel/futex.c +5 -5
index 0672ff8..18752ae 100644
@@ -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
 * via the following:
 * 1) wakeup on uaddr2 after an atomic lock acquisition by futex_requeue()
- * 2) wakeup on uaddr2 after a requeue and subsequent unlock
- * 3) signal (before or after requeue)
- * 4) timeout (before or after requeue)
+ * 2) wakeup on uaddr2 after a requeue
+ * 3) signal
+ * 4) timeout
 *
- * If 3, we setup a restart_block with futex_wait_requeue_pi() as the function.
+ * If 3, we setup a restart_block and return -ERESTARTNOINTR.
 *
 * If 2, we may then block on trying to take the rt_mutex and return via:
 * 5) successful lock
@@ -2114,7 +2114,7 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,
 * 7) timeout
 * 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.
 *
@@ -2232,14 +2232,11 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,
			rt_mutex_unlock(pi_mutex);
	} else if (ret == -EINTR) {
		/*

- * We've already been requeued, but we have no way to
- * restart by calling futex_lock_pi() directly. We
- * could restart the syscall, but that will look at
- * the user space value and return right away. So we
- * drop back with EWOULDBLOCK to tell user space that
- * "val" has been changed. That's the same what the
- * restart of the syscall would do in
- * futex_wait_setup().
+ * We've already been requeued, but cannot restart by calling
+ * futex_lock_pi() directly. We could restart this syscall, but
+ * it would detect that the user space "val" changed and return
+ * -EWOULDBLOCK. Save the overhead of the restart and return
+ * -EWOULDBLOCK directly.

		 */
		ret = -EWOULDBLOCK;
	}
Signature · 3 lines
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team
author Nacked-by on v1 1/1 NAK
#1 lore raw
Quoted 30 lines · Darren Hart

futex: futex_wait_requeue_pi commentary corrections

From: Darren Hart <[email protected]>

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.

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>

---

kernel/futex.c | 23 ++++++++++-------------

1 files changed, 10 insertions(+), 13 deletions(-)
kernel/futex.c +0 -0
index 0672ff8..18752ae 100644
@@ -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
* via the following:
* 1) wakeup on uaddr2 after an atomic lock acquisition by futex_requeue()
- * 2) wakeup on uaddr2 after a requeue and subsequent unlock
- * 3) signal (before or after requeue)

Quoted 8 lines

- * 4) timeout (before or after requeue)
+ * 2) wakeup on uaddr2 after a requeue
+ * 3) signal
+ * 4) timeout
*
- * If 3, we setup a restart_block with futex_wait_requeue_pi() as the function.
+ * If 3, we setup a restart_block and return -ERESTARTNOINTR.

Gah, not we don't. We removed the restart block altogether. Sorry. V2 en route.

Signature · 3 lines
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team