Skip to contentSkip to conversation

futex: Clarify mark_wake_futex memory barrier usage

PATCH New Darren Hart (VMware) 2 participants 2 messages Apr 14, 2017 – Apr 15, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 futex: Clarify mark_wake_futex memory barrier usage

Clarify the scenario described in mark_wake_futex requiring the smp_store_release(). Update the comment to explicitly refer to the plist_del now under __unqueue_futex() (previously plist_del was in the same function as the comment).

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/futex.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/futex.c +5 -4
index ede2f1e..357348a 100644
@@ -1380,10 +1380,11 @@ static void mark_wake_futex(struct wake_q_head *wake_q, struct futex_q *q)
 	wake_q_add(wake_q, p);
 	__unqueue_futex(q);
 	/*
-	 * The waiting task can free the futex_q as soon as
-	 * q->lock_ptr = NULL is written, without taking any locks. A
-	 * memory barrier is required here to prevent the following
-	 * store to lock_ptr from getting ahead of the plist_del.
+	 * The waiting task can free the futex_q as soon as q->lock_ptr = NULL
+	 * is written, without taking any locks. This is possible in the event
+	 * of a spurious wakeup, for example. A memory barrier is required here
+	 * to prevent the following store to lock_ptr from getting ahead of the
+	 * plist_del in __unqueue_futex().
 	 */
 	smp_store_release(&q->lock_ptr, NULL);
 }
Signature · 6 lines
2.9.3


-- 
Darren Hart
VMware Open Source Technology Center
#1 lore raw
futex: Clarify mark_wake_futex memory barrier usage
Commit-ID:  38fcd06e9b7f6855db1f3ebac5e18b8fdb467ffd
Gitweb:     http://git.kernel.org/tip/38fcd06e9b7f6855db1f3ebac5e18b8fdb467ffd
Author:     Darren Hart (VMware) <[email protected]>
AuthorDate: Fri, 14 Apr 2017 15:31:38 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sat, 15 Apr 2017 16:03:46 +0200

futex: Clarify mark_wake_futex memory barrier usage

Clarify the scenario described in mark_wake_futex requiring the smp_store_release(). Update the comment to explicitly refer to the plist_del now under __unqueue_futex() (previously plist_del was in the same function as the comment).

---
 kernel/futex.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/futex.c +5 -4
index ede2f1e..357348a 100644
@@ -1380,10 +1380,11 @@ static void mark_wake_futex(struct wake_q_head *wake_q, struct futex_q *q)
 	wake_q_add(wake_q, p);
 	__unqueue_futex(q);
 	/*
-	 * The waiting task can free the futex_q as soon as
-	 * q->lock_ptr = NULL is written, without taking any locks. A
-	 * memory barrier is required here to prevent the following
-	 * store to lock_ptr from getting ahead of the plist_del.
+	 * The waiting task can free the futex_q as soon as q->lock_ptr = NULL
+	 * is written, without taking any locks. This is possible in the event
+	 * of a spurious wakeup, for example. A memory barrier is required here
+	 * to prevent the following store to lock_ptr from getting ahead of the
+	 * plist_del in __unqueue_futex().
 	 */
 	smp_store_release(&q->lock_ptr, NULL);
 }