diff mbox series

[01/13] futex: Use smp_store_release() in mark_wake_futex()

Message ID YGDp1qJOCUJmE1Ty@decadent.org.uk
State New
Headers show
Series [01/13] futex: Use smp_store_release() in mark_wake_futex() | expand

Commit Message

Ben Hutchings March 28, 2021, 8:40 p.m. UTC
From: Peter Zijlstra <peterz@infradead.org>

commit 1b367ece0d7e696cab1c8501bab282cc6a538b3f upstream.

Since the futex_q can dissapear the instruction after assigning NULL,
this really should be a RELEASE barrier. That stops loads from hitting
dead memory too.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: juri.lelli@arm.com
Cc: bigeasy@linutronix.de
Cc: xlpang@redhat.com
Cc: rostedt@goodmis.org
Cc: mathieu.desnoyers@efficios.com
Cc: jdesfossez@efficios.com
Cc: dvhart@infradead.org
Cc: bristot@redhat.com
Link: http://lkml.kernel.org/r/20170322104151.604296452@infradead.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 kernel/futex.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Greg KH March 29, 2021, 5:50 a.m. UTC | #1
On Sun, Mar 28, 2021 at 10:40:54PM +0200, Ben Hutchings wrote:
> From: Peter Zijlstra <peterz@infradead.org>

> 

> commit 1b367ece0d7e696cab1c8501bab282cc6a538b3f upstream.

> 

> Since the futex_q can dissapear the instruction after assigning NULL,

> this really should be a RELEASE barrier. That stops loads from hitting

> dead memory too.

> 

> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>

> Cc: juri.lelli@arm.com

> Cc: bigeasy@linutronix.de

> Cc: xlpang@redhat.com

> Cc: rostedt@goodmis.org

> Cc: mathieu.desnoyers@efficios.com

> Cc: jdesfossez@efficios.com

> Cc: dvhart@infradead.org

> Cc: bristot@redhat.com

> Link: http://lkml.kernel.org/r/20170322104151.604296452@infradead.org

> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

> ---

>  kernel/futex.c | 3 +--

>  1 file changed, 1 insertion(+), 2 deletions(-)

> 

> diff --git a/kernel/futex.c b/kernel/futex.c

> index 796b1c860839..e112a9d4c84f 100644

> --- a/kernel/futex.c

> +++ b/kernel/futex.c

> @@ -1565,8 +1565,7 @@ static void mark_wake_futex(struct wake_q_head *wake_q, struct futex_q *q)

>  	 * memory barrier is required here to prevent the following

>  	 * store to lock_ptr from getting ahead of the plist_del.

>  	 */

> -	smp_wmb();

> -	q->lock_ptr = NULL;

> +	smp_store_release(&q->lock_ptr, NULL);

>  }

>  

>  /*

> 




All now queued up, thanks.

greg k-h
diff mbox series

Patch

diff --git a/kernel/futex.c b/kernel/futex.c
index 796b1c860839..e112a9d4c84f 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1565,8 +1565,7 @@  static void mark_wake_futex(struct wake_q_head *wake_q, struct futex_q *q)
 	 * memory barrier is required here to prevent the following
 	 * store to lock_ptr from getting ahead of the plist_del.
 	 */
-	smp_wmb();
-	q->lock_ptr = NULL;
+	smp_store_release(&q->lock_ptr, NULL);
 }
 
 /*