From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751998AbcEQLKO (ORCPT ); Tue, 17 May 2016 07:10:14 -0400 Received: from merlin.infradead.org ([205.233.59.134]:36858 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750758AbcEQLKK (ORCPT ); Tue, 17 May 2016 07:10:10 -0400 Date: Tue, 17 May 2016 13:09:06 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Jason Low , Ingo Molnar , Linux Kernel Mailing List , Andrew Morton , Richard Henderson , Ivan Kokshaysky , Matt Turner , Tony Luck , Fenghua Yu , Martin Schwidefsky , Terry Rudd , Heiko Carstens , Thomas Gleixner , Arnd Bergmann , Christoph Lameter , Davidlohr Bueso , Waiman Long , Tim Chen , Peter Hurley , Jason Low Subject: Re: [RFC][PATCH 0/7] locking/rwsem: Convert rwsem count to atomic_long_t Message-ID: <20160517110906.GW3193@twins.programming.kicks-ass.net> References: <1463445486-16078-1-git-send-email-jason.low2@hpe.com> 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 Mon, May 16, 2016 at 06:12:25PM -0700, Linus Torvalds wrote: > On Mon, May 16, 2016 at 5:37 PM, Jason Low wrote: > > > > This rest of the series converts the rwsem count variable to an atomic_long_t > > since it is used it as an atomic variable. This allows us to also remove > > the rwsem_atomic_{add,update} abstraction and reduce 100+ lines of code. > > I would suggest you merge all the "remove rwsem_atomic_{add,update}" > patches into a single patch. > > I don't see the advantage to splitting those up by architecture, and > it does add noise to the series. > > Other than that it all looks fine to me. OK, done. --- Subject: locking,rwsem: Remove rwsem_atomic_add() and rwsem_atomic_update() From: Jason Low Date: Mon, 16 May 2016 17:38:02 -0700 The rwsem-xadd count has been converted to an atomic variable and the rwsem code now directly uses atomic_long_add() and atomic_long_add_return(), so we can remove the arch implementations of rwsem_atomic_add() and rwsem_atomic_update(). Cc: Waiman Long Cc: Heiko Carstens Cc: Jason Low Cc: Richard Henderson Cc: Ingo Molnar Cc: Fenghua Yu Cc: Andrew Morton Cc: Martin Schwidefsky Cc: Linus Torvalds Cc: Tim Chen Cc: Christoph Lameter Cc: Thomas Gleixner Cc: Arnd Bergmann Cc: Terry Rudd Cc: Peter Hurley Cc: Davidlohr Bueso Cc: Ivan Kokshaysky Cc: Tony Luck Cc: Matt Turner Signed-off-by: Jason Low Signed-off-by: Peter Zijlstra (Intel) --- arch/alpha/include/asm/rwsem.h | 42 ----------------------------------------- arch/ia64/include/asm/rwsem.h | 7 ------ arch/s390/include/asm/rwsem.h | 37 ------------------------------------ arch/x86/include/asm/rwsem.h | 18 ----------------- include/asm-generic/rwsem.h | 16 --------------- 5 files changed, 120 deletions(-) --- a/arch/alpha/include/asm/rwsem.h +++ b/arch/alpha/include/asm/rwsem.h @@ -191,47 +191,5 @@ static inline void __downgrade_write(str rwsem_downgrade_wake(sem); } -static inline void rwsem_atomic_add(long val, struct rw_semaphore *sem) -{ -#ifndef CONFIG_SMP - sem->count += val; -#else - long temp; - __asm__ __volatile__( - "1: ldq_l %0,%1\n" - " addq %0,%2,%0\n" - " stq_c %0,%1\n" - " beq %0,2f\n" - ".subsection 2\n" - "2: br 1b\n" - ".previous" - :"=&r" (temp), "=m" (sem->count) - :"Ir" (val), "m" (sem->count)); -#endif -} - -static inline long rwsem_atomic_update(long val, struct rw_semaphore *sem) -{ -#ifndef CONFIG_SMP - sem->count += val; - return sem->count; -#else - long ret, temp; - __asm__ __volatile__( - "1: ldq_l %0,%1\n" - " addq %0,%3,%2\n" - " addq %0,%3,%0\n" - " stq_c %2,%1\n" - " beq %2,2f\n" - ".subsection 2\n" - "2: br 1b\n" - ".previous" - :"=&r" (ret), "=m" (sem->count), "=&r" (temp) - :"Ir" (val), "m" (sem->count)); - - return ret; -#endif -} - #endif /* __KERNEL__ */ #endif /* _ALPHA_RWSEM_H */ --- a/arch/ia64/include/asm/rwsem.h +++ b/arch/ia64/include/asm/rwsem.h @@ -151,11 +151,4 @@ __downgrade_write (struct rw_semaphore * rwsem_downgrade_wake(sem); } -/* - * Implement atomic add functionality. These used to be "inline" functions, but GCC v3.1 - * doesn't quite optimize this stuff right and ends up with bad calls to fetchandadd. - */ -#define rwsem_atomic_add(delta, sem) atomic64_add(delta, (atomic64_t *)(&(sem)->count)) -#define rwsem_atomic_update(delta, sem) atomic64_add_return(delta, (atomic64_t *)(&(sem)->count)) - #endif /* _ASM_IA64_RWSEM_H */ --- a/arch/s390/include/asm/rwsem.h +++ b/arch/s390/include/asm/rwsem.h @@ -207,41 +207,4 @@ static inline void __downgrade_write(str rwsem_downgrade_wake(sem); } -/* - * implement atomic add functionality - */ -static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem) -{ - signed long old, new; - - asm volatile( - " lg %0,%2\n" - "0: lgr %1,%0\n" - " agr %1,%4\n" - " csg %0,%1,%2\n" - " jl 0b" - : "=&d" (old), "=&d" (new), "=Q" (sem->count) - : "Q" (sem->count), "d" (delta) - : "cc", "memory"); -} - -/* - * implement exchange and add functionality - */ -static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem) -{ - signed long old, new; - - asm volatile( - " lg %0,%2\n" - "0: lgr %1,%0\n" - " agr %1,%4\n" - " csg %0,%1,%2\n" - " jl 0b" - : "=&d" (old), "=&d" (new), "=Q" (sem->count) - : "Q" (sem->count), "d" (delta) - : "cc", "memory"); - return new; -} - #endif /* _S390_RWSEM_H */ --- a/arch/x86/include/asm/rwsem.h +++ b/arch/x86/include/asm/rwsem.h @@ -215,23 +215,5 @@ static inline void __downgrade_write(str : "memory", "cc"); } -/* - * implement atomic add functionality - */ -static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem) -{ - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0" - : "+m" (sem->count) - : "er" (delta)); -} - -/* - * implement exchange and add functionality - */ -static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem) -{ - return delta + xadd(&sem->count, delta); -} - #endif /* __KERNEL__ */ #endif /* _ASM_X86_RWSEM_H */ --- a/include/asm-generic/rwsem.h +++ b/include/asm-generic/rwsem.h @@ -107,14 +107,6 @@ static inline void __up_write(struct rw_ } /* - * implement atomic add functionality - */ -static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem) -{ - atomic_long_add(delta, (atomic_long_t *)&sem->count); -} - -/* * downgrade write lock to read lock */ static inline void __downgrade_write(struct rw_semaphore *sem) @@ -134,13 +126,5 @@ static inline void __downgrade_write(str rwsem_downgrade_wake(sem); } -/* - * implement exchange and add functionality - */ -static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem) -{ - return atomic_long_add_return(delta, (atomic_long_t *)&sem->count); -} - #endif /* __KERNEL__ */ #endif /* _ASM_GENERIC_RWSEM_H */