From: tip-bot for Darren Hart <dvhltc@us.ibm.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, dvhltc@us.ibm.com, hpa@zytor.com,
mingo@redhat.com, eric.dumazet@gmail.com, johnstul@us.ibm.com,
peterz@infradead.org, dino@in.ibm.com, rostedt@goodmis.org,
tglx@linutronix.de, mingo@elte.hu
Subject: [tip:core/urgent] futex: Correct queue_me and unqueue_me commentary
Date: Tue, 22 Sep 2009 08:40:46 GMT [thread overview]
Message-ID: <tip-d40d65c8dbdd39f0b64e043f6bd08f8a38f55194@git.kernel.org> (raw)
In-Reply-To: <20090922053015.8717.71713.stgit@Aeon>
Commit-ID: d40d65c8dbdd39f0b64e043f6bd08f8a38f55194
Gitweb: http://git.kernel.org/tip/d40d65c8dbdd39f0b64e043f6bd08f8a38f55194
Author: Darren Hart <dvhltc@us.ibm.com>
AuthorDate: Mon, 21 Sep 2009 22:30:15 -0700
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 22 Sep 2009 10:37:43 +0200
futex: Correct queue_me and unqueue_me commentary
The queue_me/unqueue_me commentary is oddly placed and out of date.
Clean it up and correct the inaccurate bits.
Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Dinakar Guniguntala <dino@in.ibm.com>
Cc: John Stultz <johnstul@us.ibm.com>
LKML-Reference: <20090922053015.8717.71713.stgit@Aeon>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/futex.c | 41 +++++++++++++++++++++++++++++------------
1 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index 6c498b1..cedcd60 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1350,6 +1350,25 @@ static inline struct futex_hash_bucket *queue_lock(struct futex_q *q)
return hb;
}
+static inline void
+queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb)
+{
+ spin_unlock(&hb->lock);
+ drop_futex_key_refs(&q->key);
+}
+
+/**
+ * queue_me() - Enqueue the futex_q on the futex_hash_bucket
+ * @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).
+ */
static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb)
{
int prio;
@@ -1373,19 +1392,17 @@ static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb)
spin_unlock(&hb->lock);
}
-static inline void
-queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb)
-{
- spin_unlock(&hb->lock);
- drop_futex_key_refs(&q->key);
-}
-
-/*
- * queue_me and unqueue_me must be called as a pair, each
- * exactly once. They are called with the hashed spinlock held.
+/**
+ * unqueue_me() - Remove the futex_q from its futex_hash_bucket
+ * @q: The futex_q to unqueue
+ *
+ * The q->lock_ptr must not be held by the caller. A call to unqueue_me() must
+ * be paired with exactly one earlier call to queue_me().
+ *
+ * Returns:
+ * 1 - if the futex_q was still queued (and we removed unqueued it)
+ * 0 - if the futex_q was already removed by the waking thread
*/
-
-/* Return 1 if we were still queued (ie. 0 means we were woken) */
static int unqueue_me(struct futex_q *q)
{
spinlock_t *lock_ptr;
next prev parent reply other threads:[~2009-09-22 8:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-22 5:29 [PATCH 0/5] Futex cleanups and race fix Darren Hart
2009-09-22 5:29 ` [PATCH 1/5] futex: correct futex_wait_requeue_pi() commentary Darren Hart
2009-09-22 8:40 ` [tip:core/urgent] futex: Correct " tip-bot for Darren Hart
2009-09-22 5:30 ` [PATCH 2/5] futex: correct queue_me and unqueue_me commentary Darren Hart
2009-09-22 8:40 ` tip-bot for Darren Hart [this message]
2009-09-22 5:30 ` [PATCH 3/5] futex: make function kernel-doc commentary consistent Darren Hart
2009-09-22 8:41 ` [tip:core/urgent] futex: Make " tip-bot for Darren Hart
2009-09-22 5:30 ` [PATCH 4/5] futex: correct futex_q woken state commentary Darren Hart
2009-09-22 8:41 ` [tip:core/urgent] futex: Correct " tip-bot for Darren Hart
2009-09-22 5:30 ` [PATCH 5/5] futex: fix wakeup race by setting TASK_INTERRUPTIBLE before queue_me Darren Hart
2009-09-22 8:38 ` Eric Dumazet
2009-09-22 9:10 ` Ingo Molnar
2009-09-22 17:21 ` Darren Hart
2009-09-22 19:26 ` Ingo Molnar
2009-09-22 8:41 ` [tip:core/urgent] futex: Fix wakeup race by setting TASK_INTERRUPTIBLE before queue_me() tip-bot for Darren Hart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-d40d65c8dbdd39f0b64e043f6bd08f8a38f55194@git.kernel.org \
--to=dvhltc@us.ibm.com \
--cc=dino@in.ibm.com \
--cc=eric.dumazet@gmail.com \
--cc=hpa@zytor.com \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox