From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Deacon Subject: Re: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment Date: Mon, 9 Jul 2018 14:07:39 +0100 Message-ID: <20180709130738.GA28336@arm.com> References: <20180709124741.21037-1-abrodkin@synopsys.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20180709124741.21037-1-abrodkin@synopsys.com> Sender: linux-kernel-owner@vger.kernel.org To: Alexey Brodkin Cc: linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arch@vger.kernel.org, Peter Zijlstra , Boqun Feng , Russell King , Arnd Bergmann , Thomas Gleixner , Ingo Molnar , Darren Hart , Shuah Khan , "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , David Laight , Geert Uytterhoeven , Greg Kroah-Hartman List-Id: linux-arch.vger.kernel.org On Mon, Jul 09, 2018 at 03:47:41PM +0300, Alexey Brodkin wrote: > Atomic instructions require data they operate on to be aligned > according to data size. I.e. 32-bit atomic values must be 32-bit > aligned while 64-bit values must be 64-bit aligned. > > Otherwise even if CPU may handle not-aligend normal data access, > still atomic instructions fail and typically raise an exception > leaving us dead in the water. > > This came-up during lengthly discussion here: > http://lists.infradead.org/pipermail/linux-snps-arc/2018-July/004022.html > > Signed-off-by: Alexey Brodkin > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Boqun Feng > Cc: Russell King > Cc: Arnd Bergmann > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Darren Hart > Cc: Shuah Khan > Cc: "Paul E. McKenney" > Cc: Josh Triplett > Cc: Steven Rostedt > Cc: Mathieu Desnoyers > Cc: Lai Jiangshan > Cc: David Laight > Cc: Geert Uytterhoeven > Cc: Greg Kroah-Hartman > --- > arch/arm/include/asm/atomic.h | 2 +- > include/asm-generic/atomic64.h | 2 +- > include/linux/types.h | 4 ++-- > tools/include/linux/types.h | 2 +- > tools/testing/selftests/futex/include/atomic.h | 2 +- > .../rcutorture/formal/srcu-cbmc/include/linux/types.h | 4 ++-- > 6 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h > index 66d0e215a773..2ed6d7cf1407 100644 > --- a/arch/arm/include/asm/atomic.h > +++ b/arch/arm/include/asm/atomic.h > @@ -267,7 +267,7 @@ ATOMIC_OPS(xor, ^=, eor) > > #ifndef CONFIG_GENERIC_ATOMIC64 > typedef struct { > - long long counter; > + u64 __aligned(8) counter; > } atomic64_t; Long long is 8-byte aligned per EABI ARM, and we use the generic atomic64 infrastructure for OABI, so we don't need to change anything here afaict. Will From mboxrd@z Thu Jan 1 00:00:00 1970 From: will.deacon@arm.com (Will Deacon) Date: Mon, 9 Jul 2018 14:07:39 +0100 Subject: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment In-Reply-To: <20180709124741.21037-1-abrodkin@synopsys.com> References: <20180709124741.21037-1-abrodkin@synopsys.com> List-ID: Message-ID: <20180709130738.GA28336@arm.com> To: linux-snps-arc@lists.infradead.org On Mon, Jul 09, 2018@03:47:41PM +0300, Alexey Brodkin wrote: > Atomic instructions require data they operate on to be aligned > according to data size. I.e. 32-bit atomic values must be 32-bit > aligned while 64-bit values must be 64-bit aligned. > > Otherwise even if CPU may handle not-aligend normal data access, > still atomic instructions fail and typically raise an exception > leaving us dead in the water. > > This came-up during lengthly discussion here: > http://lists.infradead.org/pipermail/linux-snps-arc/2018-July/004022.html > > Signed-off-by: Alexey Brodkin > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Boqun Feng > Cc: Russell King > Cc: Arnd Bergmann > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Darren Hart > Cc: Shuah Khan > Cc: "Paul E. McKenney" > Cc: Josh Triplett > Cc: Steven Rostedt > Cc: Mathieu Desnoyers > Cc: Lai Jiangshan > Cc: David Laight > Cc: Geert Uytterhoeven > Cc: Greg Kroah-Hartman > --- > arch/arm/include/asm/atomic.h | 2 +- > include/asm-generic/atomic64.h | 2 +- > include/linux/types.h | 4 ++-- > tools/include/linux/types.h | 2 +- > tools/testing/selftests/futex/include/atomic.h | 2 +- > .../rcutorture/formal/srcu-cbmc/include/linux/types.h | 4 ++-- > 6 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h > index 66d0e215a773..2ed6d7cf1407 100644 > --- a/arch/arm/include/asm/atomic.h > +++ b/arch/arm/include/asm/atomic.h > @@ -267,7 +267,7 @@ ATOMIC_OPS(xor, ^=, eor) > > #ifndef CONFIG_GENERIC_ATOMIC64 > typedef struct { > - long long counter; > + u64 __aligned(8) counter; > } atomic64_t; Long long is 8-byte aligned per EABI ARM, and we use the generic atomic64 infrastructure for OABI, so we don't need to change anything here afaict. Will