Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753957AbcJED6L (ORCPT ); Tue, 4 Oct 2016 23:58:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:49269 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751634AbcJED6K (ORCPT ); Tue, 4 Oct 2016 23:58:10 -0400 Date: Tue, 4 Oct 2016 20:57:55 -0700 From: Davidlohr Bueso To: Peter Zijlstra Cc: mingo@kernel.org, tglx@linutronix.de, juri.lelli@arm.com, rostedt@goodmis.org, xlpang@redhat.com, bigeasy@linutronix.de, linux-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, jdesfossez@efficios.com, bristot@redhat.com Subject: Re: [RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex() Message-ID: <20161005035755.GC32728@linux-80c1.suse> References: <20161003091234.879763059@infradead.org> <20161003091847.527807466@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20161003091847.527807466@infradead.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1086 Lines: 34 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) >--- > 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