Preparatory patch for a lockless empty check of the hash bucket plist
in futex_wake().

No functional change.

Signed-off-by: Thomas Gleixner <[email protected]>
---
 kernel/futex.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

Index: linux-2.6/kernel/futex.c
===================================================================
--- linux-2.6.orig/kernel/futex.c
+++ linux-2.6/kernel/futex.c
@@ -1548,15 +1548,14 @@ static inline void queue_unlock(struct f
  * @q: The futex_q to enqueue
  * @hb:        The destination hash bucket
  *
- * The hb->lock must be held by the caller, and is released here. A call to
- * queue_me() is typically paired with exactly one call to unqueue_me().  The
- * exceptions involve the PI related operations, which may use unqueue_me_pi()
- * or nothing if the unqueue is done as part of the wake process and the 
unqueue
- * state is implicit in the state of woken task (see futex_wait_requeue_pi() 
for
- * an example).
+ * The hb->lock must be held by the caller. A call to queue_me() is
+ * typically paired with exactly one call to unqueue_me(). The
+ * exceptions involve the PI related operations, which may use
+ * unqueue_me_pi() or nothing if the unqueue is done as part of the
+ * wake process and the unqueue state is implicit in the state of
+ * woken task (see futex_wait_requeue_pi() for an example).
  */
 static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb)
-       __releases(&hb->lock)
 {
        int prio;
 
@@ -1573,7 +1572,6 @@ static inline void queue_me(struct futex
        plist_node_init(&q->list, prio);
        plist_add(&q->list, &hb->chain);
        q->task = current;
-       spin_unlock(&hb->lock);
 }
 
 /**
@@ -1834,6 +1832,11 @@ static void futex_wait_queue_me(struct f
         */
        set_current_state(TASK_INTERRUPTIBLE);
        queue_me(q, hb);
+       /*
+        * Unlock _AFTER_ we queued ourself. See the comment describing
+        * the futex ordering guarantees on top of this file.
+        */
+       queue_unlock(hb);
 
        /* Arm the timer */
        if (timeout) {
@@ -2085,6 +2088,11 @@ retry_private:
         * Only actually queue now that the atomic ops are done:
         */
        queue_me(&q, hb);
+       /*
+        * Unlock _AFTER_ we queued ourself. See the comment describing
+        * the futex ordering guarantees on top of this file.
+        */
+       queue_unlock(hb);
 
        WARN_ON(!q.pi_state);
        /*


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to