From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933270AbbELO7y (ORCPT ); Tue, 12 May 2015 10:59:54 -0400 Received: from casper.infradead.org ([85.118.1.10]:36899 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932488AbbELO7w (ORCPT ); Tue, 12 May 2015 10:59:52 -0400 Date: Tue, 12 May 2015 16:59:39 +0200 From: Peter Zijlstra To: doug.hatch@hp.com, tglx@linutronix.de, mingo@kernel.org, Waiman.Long@hp.com, linux-kernel@vger.kernel.org, scott.norton@hp.com, torvalds@linux-foundation.org, hpa@zytor.com Cc: linux-tip-commits@vger.kernel.org Subject: Re: [tip:locking/core] locking/pvqspinlock: Replace xchg() by the more descriptive set_mb() Message-ID: <20150512145939.GG16478@twins.programming.kicks-ass.net> References: <20150511145408.GU27504@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150511145408.GU27504@twins.programming.kicks-ass.net> 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 Mon, May 11, 2015 at 04:54:08PM +0200, Peter Zijlstra wrote: > +++ b/arch/arm/include/asm/barrier.h > @@ -81,7 +81,7 @@ do { \ > #define read_barrier_depends() do { } while(0) > #define smp_read_barrier_depends() do { } while(0) > > -#define set_mb(var, value) do { var = value; smp_mb(); } while (0) > +#define set_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0) > > #define smp_mb__before_atomic() smp_mb() > #define smp_mb__after_atomic() smp_mb() Which triggered a massive compile fail and requires the same union trickery we already had for READ_ONCE(). Added the below bit to the patch to aid compiling. --- diff --git a/include/linux/compiler.h b/include/linux/compiler.h index a7c0941d10da..03e227ba481c 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -250,7 +250,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) #define WRITE_ONCE(x, val) \ - ({ typeof(x) __val = (val); __write_once_size(&(x), &__val, sizeof(__val)); __val; }) + ({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; __write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) #endif /* __KERNEL__ */