Skip to contentSkip to conversation

futex: add memory barrier commentary to futex_wait_queue_me

PATCH In review Darren Hart 1 participant 2 messages Sep 24, 2009 – Sep 25, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 futex: add memory barrier commentary to futex_wait_queue_me

The memory barrier semantics of futex_wait_queue_me() are non-obvious. Add some commentary to try and clarify it.

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
CC Eric Dumazet <[email protected]>
CC Dinakar Guniguntala <[email protected]>
CC John Stultz <[email protected]>

---

 kernel/futex.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
kernel/futex.c +6 -0
index 463af2e..b911adc 100644
@@ -1656,6 +1656,12 @@ out:
 static void futex_wait_queue_me(struct futex_hash_bucket *hb, struct futex_q *q,
 				struct hrtimer_sleeper *timeout)
 {
+	/*
+	 * The task state is guaranteed to be set before another task can
+	 * wake it. set_current_state() is implemented using set_mb() and
+	 * queue_me() calls spin_unlock() upon completion, both serializing
+	 * access to the hash list and forcing another memory barrier.
+	 */
 	set_current_state(TASK_INTERRUPTIBLE);
 	queue_me(q, hb);
 
#1 lore raw

[tip:core/urgent] futex: Add memory barrier commentary to futex_wait_queue_me()

Commit-ID:  9beba3c54dd180a26a1da2027cfbe9edfaf9c40e
Gitweb:     http://git.kernel.org/tip/9beba3c54dd180a26a1da2027cfbe9edfaf9c40e
Author:     Darren Hart <[email protected]>
AuthorDate: Thu, 24 Sep 2009 11:54:47 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 24 Sep 2009 22:30:10 +0200

futex: Add memory barrier commentary to futex_wait_queue_me()

The memory barrier semantics of futex_wait_queue_me() are non-obvious. Add some commentary to try and clarify it.

Cc Peter Zijlstra <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Dinakar Guniguntala <[email protected]>
Cc John Stultz <[email protected]>

LKML-Reference: <20090924185447.694.38948.stgit@Aeon>

---
 kernel/futex.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
kernel/futex.c +6 -0
index 463af2e..b911adc 100644
@@ -1656,6 +1656,12 @@ out:
 static void futex_wait_queue_me(struct futex_hash_bucket *hb, struct futex_q *q,
 				struct hrtimer_sleeper *timeout)
 {
+	/*
+	 * The task state is guaranteed to be set before another task can
+	 * wake it. set_current_state() is implemented using set_mb() and
+	 * queue_me() calls spin_unlock() upon completion, both serializing
+	 * access to the hash list and forcing another memory barrier.
+	 */
 	set_current_state(TASK_INTERRUPTIBLE);
 	queue_me(q, hb);