From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752429AbbGARSJ (ORCPT ); Wed, 1 Jul 2015 13:18:09 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:47333 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750893AbbGARSD (ORCPT ); Wed, 1 Jul 2015 13:18:03 -0400 Date: Wed, 1 Jul 2015 19:17:55 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Ingo Molnar , Linux Kernel Mailing List , tony.luck@intel.com, benh@kernel.crashing.org, heiko.carstens@de.ibm.com Subject: Re: smp_store_mb() oddity.. Message-ID: <20150701171755.GM3644@twins.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 01, 2015 at 09:39:44AM -0700, Linus Torvalds wrote: > Peter/Ingo, > while resolving a conflict, I noticed that we have the generic > default definition of "smp_store_mb()" be: > > do { WRITE_ONCE(var, value); mb(); } while (0) > > which looks pretty odd. Why? That "mb()" is a full memory barrier even > on UP, yet this is clearly a smp barrier. > > So I think that "mb()" should be "smp_mb()". Looking at other > architecture definitions, most architectures already do that. Agreed. > I think this is just left-over from our previous (badly specified) > "set_mb()", and that commit b92b8b35a2e3 ("locking/arch: Rename > set_mb() to smp_store_mb()") just didn't notice. That commit was a sed script :-). but yes I should've noticed something was up when looking at the result. > Our old set_mb() > was already confused about whether it was a smp barrier or an IO > barrier (eg ARM uses smp_mb, x86 has separate smp/up versions, but > others dop the unconditional memory barrier). > > I didn't change this in the merge, because it's not just the generic > version where the conflict was, there's also powerpc, s390 and ia64 > that still have the non-smp version too. But some locking person > should probably clean this up... Hint hint, A quick git grep for smp_store_mb() users throws up all of 7 users, they all would be fine with smp_mb(). Lemme go do that patch.. git grep -l "smp_store_mb.*\ Cc: Benjamin Herrenschmidt Cc: Heiko Carstens Suggested-by: Linus Torvalds Signed-off-by: Peter Zijlstra (Intel) --- arch/ia64/include/asm/barrier.h | 2 +- arch/powerpc/include/asm/barrier.h | 2 +- arch/s390/include/asm/barrier.h | 2 +- include/asm-generic/barrier.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/ia64/include/asm/barrier.h b/arch/ia64/include/asm/barrier.h index 843ba435e43b..39ed6515415f 100644 --- a/arch/ia64/include/asm/barrier.h +++ b/arch/ia64/include/asm/barrier.h @@ -77,7 +77,7 @@ do { \ ___p1; \ }) -#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); mb(); } while (0) +#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0) /* * The group barrier in front of the rsm & ssm are necessary to ensure diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h index 51ccc7232042..5525268f35c0 100644 --- a/arch/powerpc/include/asm/barrier.h +++ b/arch/powerpc/include/asm/barrier.h @@ -34,7 +34,7 @@ #define rmb() __asm__ __volatile__ ("sync" : : : "memory") #define wmb() __asm__ __volatile__ ("sync" : : : "memory") -#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); mb(); } while (0) +#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0) #ifdef __SUBARCH_HAS_LWSYNC # define SMPWMB LWSYNC diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h index e6f8615a11eb..a4dea6050c77 100644 --- a/arch/s390/include/asm/barrier.h +++ b/arch/s390/include/asm/barrier.h @@ -36,7 +36,7 @@ #define smp_mb__before_atomic() smp_mb() #define smp_mb__after_atomic() smp_mb() -#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); mb(); } while (0) +#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0) #define smp_store_release(p, v) \ do { \ diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h index e6a83d712ef6..d716aa564931 100644 --- a/include/asm-generic/barrier.h +++ b/include/asm-generic/barrier.h @@ -67,7 +67,7 @@ #endif #ifndef smp_store_mb -#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); mb(); } while (0) +#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0) #endif #ifndef smp_mb__before_atomic