lkml.org 
[lkml]   [2016]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex()
On Mon, 03 Oct 2016, Peter Zijlstra wrote:

>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>
>---
> kernel/futex.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>--- a/kernel/futex.c
>+++ b/kernel/futex.c
>@@ -1288,8 +1288,7 @@ static void mark_wake_futex(struct wake_
> * 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);
> }

Hmm, what if we relied on the implicit barrier in the wake_q_add()
above and got rid of the smp_wmb altogether? We'd obviously have to
move up __unqueue_futex(), but all we care about is the publishing
store to lock_ptr being the last operation, or at least the plist_del,
such that the wakeup order is respected; ie:

__unqueue_futex(q);
wake_q_add(wake_q, p);
q->lock_ptr = NULL;

Thanks,
Davidlohr

\
 
 \ /
  Last update: 2016-10-05 05:58    [W:0.209 / U:2.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site