lkml.org 
[lkml]   [2013]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC patch 3/5] futex: Split out unlock from queue_me()
Preparatory patch for a lockless empty check of the hash bucket plist
in futex_wake().

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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);
/*



\
 
 \ /
  Last update: 2013-11-25 22:21    [W:1.966 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site