Re: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
On Sun, 06 May 2018 07:57:27 PDT (-0700), mi...@kernel.org wrote: > > * Andrea Parri <andrea.pa...@amarulasolutions.com> wrote: > >> Hi Ingo, >> >> > From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 >> > From: Ingo Molnar <mi...@kernel.org> >> > Date: Sat, 5 May 2018 10:23:23 +0200 >> > Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h >> > some more >> > >> > Before: >> > >> > #ifndef atomic_fetch_dec_relaxed >> > # ifndef atomic_fetch_dec >> > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) >> > # define atomic_fetch_dec_relaxed(v) >> > atomic_fetch_sub_relaxed(1, (v)) >> > # define atomic_fetch_dec_acquire(v) >> > atomic_fetch_sub_acquire(1, (v)) >> > # define atomic_fetch_dec_release(v) >> > atomic_fetch_sub_release(1, (v)) >> > # else >> > # define atomic_fetch_dec_relaxedatomic_fetch_dec >> > # define atomic_fetch_dec_acquireatomic_fetch_dec >> > # define atomic_fetch_dec_releaseatomic_fetch_dec >> > # endif >> > #else >> > # ifndef atomic_fetch_dec_acquire >> > # define atomic_fetch_dec_acquire(...) >> > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) >> > # endif >> > # ifndef atomic_fetch_dec_release >> > # define atomic_fetch_dec_release(...) >> > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) >> > # endif >> > # ifndef atomic_fetch_dec >> > # define atomic_fetch_dec(...) >> > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) >> > # endif >> > #endif >> > >> > After: >> > >> > #ifndef atomic_fetch_dec_relaxed >> > # ifndef atomic_fetch_dec >> > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) >> > # define atomic_fetch_dec_relaxed(v) >> > atomic_fetch_sub_relaxed(1, (v)) >> > # define atomic_fetch_dec_acquire(v) >> > atomic_fetch_sub_acquire(1, (v)) >> > # define atomic_fetch_dec_release(v) >> > atomic_fetch_sub_release(1, (v)) >> > # else >> > # define atomic_fetch_dec_relaxedatomic_fetch_dec >> > # define atomic_fetch_dec_acquireatomic_fetch_dec >> > # define atomic_fetch_dec_releaseatomic_fetch_dec >> > # endif >> > #else >> > # ifndef atomic_fetch_dec >> > # define atomic_fetch_dec(...) >> > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) >> > # define atomic_fetch_dec_acquire(...) >> > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) >> > # define atomic_fetch_dec_release(...) >> > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) >> > # endif >> > #endif >> > >> > The idea is that because we already group these APIs by certain defines >> > such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary >> > branches - we can do the same in the secondary branch as well. >> > >> > ( Also remove some unnecessarily duplicate comments, as the API >> > group defines are now pretty much self-documenting. ) >> > >> > No change in functionality. >> > >> > Cc: Peter Zijlstra <pet...@infradead.org> >> > Cc: Linus Torvalds <torva...@linux-foundation.org> >> > Cc: Andrew Morton <a...@linux-foundation.org> >> > Cc: Thomas Gleixner <t...@linutronix.de> >> > Cc: Paul E. McKenney <paul...@linux.vnet.ibm.com> >> > Cc: Will Deacon <will.dea...@arm.com> >> > Cc: linux-kernel@vger.kernel.org >> > Signed-off-by: Ingo Molnar <mi...@kernel.org> >> >> This breaks compilation on RISC-V. (For some of its atomics, the arch >> currently defines the _relaxed and the full variants and it relies on >> the generic definitions for the _acquire and the _release variants.) > > I don't have cross-compilation for RISC-V, which is a relatively new arch. > (Is there any RISC-V set of cross-compilation tools on kernel.org somewhere?) Arnd added RISC-V to the cross compiler list a month or two ago when he updated them all. I use the "make.cross" script from the Intel test robot, which will fetch the cross compilers for you. It looks like I made a Git Hub pull request to update the script for RISC-V, it fetches from kernel.org https://github.com/palmer-dabbelt/lkp-tests/blob/e14f4236ccd0572f4b87ffd480fecefee412dedc/sbin/make.cross http://cdn.kernel.org/pub/tools/crosstool/files/bin/ http://cdn.kernel.org/pub/tools/crosstool/files/bin/x86_64/7.3.0/x86_64-gcc-7.3.0-nolibc_riscv64-linux.tar.gz > Could you please send a patch that defines those variants against Linus's > tree, > like the PowerPC patch that does something similar: > > 0476a632cb3a: locking/atomics/powerpc: Move cmpxchg helpers to > asm/cmpxchg.h and define the full set of cmpxchg APIs > > ? > > ... and I'll integrate it into the proper place to make it all bisectable, > etc. Sorry, I got buried in email again. Did this get merged, or is there a current version of the patch set I should look at?
Re: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
On Sun, 06 May 2018 07:57:27 PDT (-0700), mi...@kernel.org wrote: > > * Andrea Parri wrote: > >> Hi Ingo, >> >> > From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 >> > From: Ingo Molnar >> > Date: Sat, 5 May 2018 10:23:23 +0200 >> > Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h >> > some more >> > >> > Before: >> > >> > #ifndef atomic_fetch_dec_relaxed >> > # ifndef atomic_fetch_dec >> > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) >> > # define atomic_fetch_dec_relaxed(v) >> > atomic_fetch_sub_relaxed(1, (v)) >> > # define atomic_fetch_dec_acquire(v) >> > atomic_fetch_sub_acquire(1, (v)) >> > # define atomic_fetch_dec_release(v) >> > atomic_fetch_sub_release(1, (v)) >> > # else >> > # define atomic_fetch_dec_relaxedatomic_fetch_dec >> > # define atomic_fetch_dec_acquireatomic_fetch_dec >> > # define atomic_fetch_dec_releaseatomic_fetch_dec >> > # endif >> > #else >> > # ifndef atomic_fetch_dec_acquire >> > # define atomic_fetch_dec_acquire(...) >> > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) >> > # endif >> > # ifndef atomic_fetch_dec_release >> > # define atomic_fetch_dec_release(...) >> > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) >> > # endif >> > # ifndef atomic_fetch_dec >> > # define atomic_fetch_dec(...) >> > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) >> > # endif >> > #endif >> > >> > After: >> > >> > #ifndef atomic_fetch_dec_relaxed >> > # ifndef atomic_fetch_dec >> > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) >> > # define atomic_fetch_dec_relaxed(v) >> > atomic_fetch_sub_relaxed(1, (v)) >> > # define atomic_fetch_dec_acquire(v) >> > atomic_fetch_sub_acquire(1, (v)) >> > # define atomic_fetch_dec_release(v) >> > atomic_fetch_sub_release(1, (v)) >> > # else >> > # define atomic_fetch_dec_relaxedatomic_fetch_dec >> > # define atomic_fetch_dec_acquireatomic_fetch_dec >> > # define atomic_fetch_dec_releaseatomic_fetch_dec >> > # endif >> > #else >> > # ifndef atomic_fetch_dec >> > # define atomic_fetch_dec(...) >> > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) >> > # define atomic_fetch_dec_acquire(...) >> > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) >> > # define atomic_fetch_dec_release(...) >> > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) >> > # endif >> > #endif >> > >> > The idea is that because we already group these APIs by certain defines >> > such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary >> > branches - we can do the same in the secondary branch as well. >> > >> > ( Also remove some unnecessarily duplicate comments, as the API >> > group defines are now pretty much self-documenting. ) >> > >> > No change in functionality. >> > >> > Cc: Peter Zijlstra >> > Cc: Linus Torvalds >> > Cc: Andrew Morton >> > Cc: Thomas Gleixner >> > Cc: Paul E. McKenney >> > Cc: Will Deacon >> > Cc: linux-kernel@vger.kernel.org >> > Signed-off-by: Ingo Molnar >> >> This breaks compilation on RISC-V. (For some of its atomics, the arch >> currently defines the _relaxed and the full variants and it relies on >> the generic definitions for the _acquire and the _release variants.) > > I don't have cross-compilation for RISC-V, which is a relatively new arch. > (Is there any RISC-V set of cross-compilation tools on kernel.org somewhere?) Arnd added RISC-V to the cross compiler list a month or two ago when he updated them all. I use the "make.cross" script from the Intel test robot, which will fetch the cross compilers for you. It looks like I made a Git Hub pull request to update the script for RISC-V, it fetches from kernel.org https://github.com/palmer-dabbelt/lkp-tests/blob/e14f4236ccd0572f4b87ffd480fecefee412dedc/sbin/make.cross http://cdn.kernel.org/pub/tools/crosstool/files/bin/ http://cdn.kernel.org/pub/tools/crosstool/files/bin/x86_64/7.3.0/x86_64-gcc-7.3.0-nolibc_riscv64-linux.tar.gz > Could you please send a patch that defines those variants against Linus's > tree, > like the PowerPC patch that does something similar: > > 0476a632cb3a: locking/atomics/powerpc: Move cmpxchg helpers to > asm/cmpxchg.h and define the full set of cmpxchg APIs > > ? > > ... and I'll integrate it into the proper place to make it all bisectable, > etc. Sorry, I got buried in email again. Did this get merged, or is there a current version of the patch set I should look at?
Re: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
On Sun, May 06, 2018 at 04:57:27PM +0200, Ingo Molnar wrote: > > * Andrea Parri <andrea.pa...@amarulasolutions.com> wrote: > > > Hi Ingo, > > > > > From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 > > > From: Ingo Molnar <mi...@kernel.org> > > > Date: Sat, 5 May 2018 10:23:23 +0200 > > > Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h > > > some more > > > > > > Before: > > > > > > #ifndef atomic_fetch_dec_relaxed > > > # ifndef atomic_fetch_dec > > > # define atomic_fetch_dec(v)atomic_fetch_sub(1, (v)) > > > # define atomic_fetch_dec_relaxed(v) > > > atomic_fetch_sub_relaxed(1, (v)) > > > # define atomic_fetch_dec_acquire(v) > > > atomic_fetch_sub_acquire(1, (v)) > > > # define atomic_fetch_dec_release(v) > > > atomic_fetch_sub_release(1, (v)) > > > # else > > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > > # define atomic_fetch_dec_release atomic_fetch_dec > > > # endif > > > #else > > > # ifndef atomic_fetch_dec_acquire > > > # define atomic_fetch_dec_acquire(...) > > > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > > # endif > > > # ifndef atomic_fetch_dec_release > > > # define atomic_fetch_dec_release(...) > > > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > > # endif > > > # ifndef atomic_fetch_dec > > > # define atomic_fetch_dec(...) > > > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > > # endif > > > #endif > > > > > > After: > > > > > > #ifndef atomic_fetch_dec_relaxed > > > # ifndef atomic_fetch_dec > > > # define atomic_fetch_dec(v)atomic_fetch_sub(1, (v)) > > > # define atomic_fetch_dec_relaxed(v) > > > atomic_fetch_sub_relaxed(1, (v)) > > > # define atomic_fetch_dec_acquire(v) > > > atomic_fetch_sub_acquire(1, (v)) > > > # define atomic_fetch_dec_release(v) > > > atomic_fetch_sub_release(1, (v)) > > > # else > > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > > # define atomic_fetch_dec_release atomic_fetch_dec > > > # endif > > > #else > > > # ifndef atomic_fetch_dec > > > # define atomic_fetch_dec(...) > > > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > > # define atomic_fetch_dec_acquire(...) > > > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > > # define atomic_fetch_dec_release(...) > > > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > > # endif > > > #endif > > > > > > The idea is that because we already group these APIs by certain defines > > > such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary > > > branches - we can do the same in the secondary branch as well. > > > > > > ( Also remove some unnecessarily duplicate comments, as the API > > > group defines are now pretty much self-documenting. ) > > > > > > No change in functionality. > > > > > > Cc: Peter Zijlstra <pet...@infradead.org> > > > Cc: Linus Torvalds <torva...@linux-foundation.org> > > > Cc: Andrew Morton <a...@linux-foundation.org> > > > Cc: Thomas Gleixner <t...@linutronix.de> > > > Cc: Paul E. McKenney <paul...@linux.vnet.ibm.com> > > > Cc: Will Deacon <will.dea...@arm.com> > > > Cc: linux-kernel@vger.kernel.org > > > Signed-off-by: Ingo Molnar <mi...@kernel.org> > > > > This breaks compilation on RISC-V. (For some of its atomics, the arch > > currently defines the _relaxed and the full variants and it relies on > > the generic definitions for the _acquire and the _release variants.) > > I don't have cross-compilation for RISC-V, which is a relatively new arch. > (Is there any RISC-V set of cross-compilation tools on kernel.org somewhere?) I'm using the toolchain from: https://riscv.org/software-tools/ (adding Palmer and Albert in Cc:) > > Could you please send a patch that defines those variants against Linus's > tree, > like the PowerPC patc
Re: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
On Sun, May 06, 2018 at 04:57:27PM +0200, Ingo Molnar wrote: > > * Andrea Parri wrote: > > > Hi Ingo, > > > > > From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 > > > From: Ingo Molnar > > > Date: Sat, 5 May 2018 10:23:23 +0200 > > > Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h > > > some more > > > > > > Before: > > > > > > #ifndef atomic_fetch_dec_relaxed > > > # ifndef atomic_fetch_dec > > > # define atomic_fetch_dec(v)atomic_fetch_sub(1, (v)) > > > # define atomic_fetch_dec_relaxed(v) > > > atomic_fetch_sub_relaxed(1, (v)) > > > # define atomic_fetch_dec_acquire(v) > > > atomic_fetch_sub_acquire(1, (v)) > > > # define atomic_fetch_dec_release(v) > > > atomic_fetch_sub_release(1, (v)) > > > # else > > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > > # define atomic_fetch_dec_release atomic_fetch_dec > > > # endif > > > #else > > > # ifndef atomic_fetch_dec_acquire > > > # define atomic_fetch_dec_acquire(...) > > > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > > # endif > > > # ifndef atomic_fetch_dec_release > > > # define atomic_fetch_dec_release(...) > > > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > > # endif > > > # ifndef atomic_fetch_dec > > > # define atomic_fetch_dec(...) > > > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > > # endif > > > #endif > > > > > > After: > > > > > > #ifndef atomic_fetch_dec_relaxed > > > # ifndef atomic_fetch_dec > > > # define atomic_fetch_dec(v)atomic_fetch_sub(1, (v)) > > > # define atomic_fetch_dec_relaxed(v) > > > atomic_fetch_sub_relaxed(1, (v)) > > > # define atomic_fetch_dec_acquire(v) > > > atomic_fetch_sub_acquire(1, (v)) > > > # define atomic_fetch_dec_release(v) > > > atomic_fetch_sub_release(1, (v)) > > > # else > > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > > # define atomic_fetch_dec_release atomic_fetch_dec > > > # endif > > > #else > > > # ifndef atomic_fetch_dec > > > # define atomic_fetch_dec(...) > > > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > > # define atomic_fetch_dec_acquire(...) > > > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > > # define atomic_fetch_dec_release(...) > > > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > > # endif > > > #endif > > > > > > The idea is that because we already group these APIs by certain defines > > > such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary > > > branches - we can do the same in the secondary branch as well. > > > > > > ( Also remove some unnecessarily duplicate comments, as the API > > > group defines are now pretty much self-documenting. ) > > > > > > No change in functionality. > > > > > > Cc: Peter Zijlstra > > > Cc: Linus Torvalds > > > Cc: Andrew Morton > > > Cc: Thomas Gleixner > > > Cc: Paul E. McKenney > > > Cc: Will Deacon > > > Cc: linux-kernel@vger.kernel.org > > > Signed-off-by: Ingo Molnar > > > > This breaks compilation on RISC-V. (For some of its atomics, the arch > > currently defines the _relaxed and the full variants and it relies on > > the generic definitions for the _acquire and the _release variants.) > > I don't have cross-compilation for RISC-V, which is a relatively new arch. > (Is there any RISC-V set of cross-compilation tools on kernel.org somewhere?) I'm using the toolchain from: https://riscv.org/software-tools/ (adding Palmer and Albert in Cc:) > > Could you please send a patch that defines those variants against Linus's > tree, > like the PowerPC patch that does something similar: > > 0476a632cb3a: locking/atomics/powerpc: Move cmpxchg helpers to > asm/cmpxchg.h and define the full set of cmpxchg APIs > > ? Yes, please see below for a first RFC. (BTW, get_maintainer.pl says that that patch missed
Re: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
* Andrea Parri <andrea.pa...@amarulasolutions.com> wrote: > Hi Ingo, > > > From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 > > From: Ingo Molnar <mi...@kernel.org> > > Date: Sat, 5 May 2018 10:23:23 +0200 > > Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h > > some more > > > > Before: > > > > #ifndef atomic_fetch_dec_relaxed > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) > > # define atomic_fetch_dec_relaxed(v) > > atomic_fetch_sub_relaxed(1, (v)) > > # define atomic_fetch_dec_acquire(v) > > atomic_fetch_sub_acquire(1, (v)) > > # define atomic_fetch_dec_release(v) > > atomic_fetch_sub_release(1, (v)) > > # else > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > # define atomic_fetch_dec_release atomic_fetch_dec > > # endif > > #else > > # ifndef atomic_fetch_dec_acquire > > # define atomic_fetch_dec_acquire(...) > > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > # endif > > # ifndef atomic_fetch_dec_release > > # define atomic_fetch_dec_release(...) > > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > # endif > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(...) > > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > # endif > > #endif > > > > After: > > > > #ifndef atomic_fetch_dec_relaxed > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) > > # define atomic_fetch_dec_relaxed(v) > > atomic_fetch_sub_relaxed(1, (v)) > > # define atomic_fetch_dec_acquire(v) > > atomic_fetch_sub_acquire(1, (v)) > > # define atomic_fetch_dec_release(v) > > atomic_fetch_sub_release(1, (v)) > > # else > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > # define atomic_fetch_dec_release atomic_fetch_dec > > # endif > > #else > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(...) > > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > # define atomic_fetch_dec_acquire(...) > > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > # define atomic_fetch_dec_release(...) > > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > # endif > > #endif > > > > The idea is that because we already group these APIs by certain defines > > such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary > > branches - we can do the same in the secondary branch as well. > > > > ( Also remove some unnecessarily duplicate comments, as the API > > group defines are now pretty much self-documenting. ) > > > > No change in functionality. > > > > Cc: Peter Zijlstra <pet...@infradead.org> > > Cc: Linus Torvalds <torva...@linux-foundation.org> > > Cc: Andrew Morton <a...@linux-foundation.org> > > Cc: Thomas Gleixner <t...@linutronix.de> > > Cc: Paul E. McKenney <paul...@linux.vnet.ibm.com> > > Cc: Will Deacon <will.dea...@arm.com> > > Cc: linux-kernel@vger.kernel.org > > Signed-off-by: Ingo Molnar <mi...@kernel.org> > > This breaks compilation on RISC-V. (For some of its atomics, the arch > currently defines the _relaxed and the full variants and it relies on > the generic definitions for the _acquire and the _release variants.) I don't have cross-compilation for RISC-V, which is a relatively new arch. (Is there any RISC-V set of cross-compilation tools on kernel.org somewhere?) Could you please send a patch that defines those variants against Linus's tree, like the PowerPC patch that does something similar: 0476a632cb3a: locking/atomics/powerpc: Move cmpxchg helpers to asm/cmpxchg.h and define the full set of cmpxchg APIs ? ... and I'll integrate it into the proper place to make it all bisectable, etc. Thanks, Ingo
Re: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
* Andrea Parri wrote: > Hi Ingo, > > > From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 > > From: Ingo Molnar > > Date: Sat, 5 May 2018 10:23:23 +0200 > > Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h > > some more > > > > Before: > > > > #ifndef atomic_fetch_dec_relaxed > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) > > # define atomic_fetch_dec_relaxed(v) > > atomic_fetch_sub_relaxed(1, (v)) > > # define atomic_fetch_dec_acquire(v) > > atomic_fetch_sub_acquire(1, (v)) > > # define atomic_fetch_dec_release(v) > > atomic_fetch_sub_release(1, (v)) > > # else > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > # define atomic_fetch_dec_release atomic_fetch_dec > > # endif > > #else > > # ifndef atomic_fetch_dec_acquire > > # define atomic_fetch_dec_acquire(...) > > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > # endif > > # ifndef atomic_fetch_dec_release > > # define atomic_fetch_dec_release(...) > > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > # endif > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(...) > > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > # endif > > #endif > > > > After: > > > > #ifndef atomic_fetch_dec_relaxed > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) > > # define atomic_fetch_dec_relaxed(v) > > atomic_fetch_sub_relaxed(1, (v)) > > # define atomic_fetch_dec_acquire(v) > > atomic_fetch_sub_acquire(1, (v)) > > # define atomic_fetch_dec_release(v) > > atomic_fetch_sub_release(1, (v)) > > # else > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > # define atomic_fetch_dec_release atomic_fetch_dec > > # endif > > #else > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(...) > > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > # define atomic_fetch_dec_acquire(...) > > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > # define atomic_fetch_dec_release(...) > > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > # endif > > #endif > > > > The idea is that because we already group these APIs by certain defines > > such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary > > branches - we can do the same in the secondary branch as well. > > > > ( Also remove some unnecessarily duplicate comments, as the API > > group defines are now pretty much self-documenting. ) > > > > No change in functionality. > > > > Cc: Peter Zijlstra > > Cc: Linus Torvalds > > Cc: Andrew Morton > > Cc: Thomas Gleixner > > Cc: Paul E. McKenney > > Cc: Will Deacon > > Cc: linux-kernel@vger.kernel.org > > Signed-off-by: Ingo Molnar > > This breaks compilation on RISC-V. (For some of its atomics, the arch > currently defines the _relaxed and the full variants and it relies on > the generic definitions for the _acquire and the _release variants.) I don't have cross-compilation for RISC-V, which is a relatively new arch. (Is there any RISC-V set of cross-compilation tools on kernel.org somewhere?) Could you please send a patch that defines those variants against Linus's tree, like the PowerPC patch that does something similar: 0476a632cb3a: locking/atomics/powerpc: Move cmpxchg helpers to asm/cmpxchg.h and define the full set of cmpxchg APIs ? ... and I'll integrate it into the proper place to make it all bisectable, etc. Thanks, Ingo
Re: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
Hi Ingo, > From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 > From: Ingo Molnar <mi...@kernel.org> > Date: Sat, 5 May 2018 10:23:23 +0200 > Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h > some more > > Before: > > #ifndef atomic_fetch_dec_relaxed > # ifndef atomic_fetch_dec > # define atomic_fetch_dec(v)atomic_fetch_sub(1, (v)) > # define atomic_fetch_dec_relaxed(v) > atomic_fetch_sub_relaxed(1, (v)) > # define atomic_fetch_dec_acquire(v) > atomic_fetch_sub_acquire(1, (v)) > # define atomic_fetch_dec_release(v) > atomic_fetch_sub_release(1, (v)) > # else > # define atomic_fetch_dec_relaxed atomic_fetch_dec > # define atomic_fetch_dec_acquire atomic_fetch_dec > # define atomic_fetch_dec_release atomic_fetch_dec > # endif > #else > # ifndef atomic_fetch_dec_acquire > # define atomic_fetch_dec_acquire(...) > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > # endif > # ifndef atomic_fetch_dec_release > # define atomic_fetch_dec_release(...) > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > # endif > # ifndef atomic_fetch_dec > # define atomic_fetch_dec(...) > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > # endif > #endif > > After: > > #ifndef atomic_fetch_dec_relaxed > # ifndef atomic_fetch_dec > # define atomic_fetch_dec(v)atomic_fetch_sub(1, (v)) > # define atomic_fetch_dec_relaxed(v) > atomic_fetch_sub_relaxed(1, (v)) > # define atomic_fetch_dec_acquire(v) > atomic_fetch_sub_acquire(1, (v)) > # define atomic_fetch_dec_release(v) > atomic_fetch_sub_release(1, (v)) > # else > # define atomic_fetch_dec_relaxed atomic_fetch_dec > # define atomic_fetch_dec_acquire atomic_fetch_dec > # define atomic_fetch_dec_release atomic_fetch_dec > # endif > #else > # ifndef atomic_fetch_dec > # define atomic_fetch_dec(...) > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > # define atomic_fetch_dec_acquire(...) > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > # define atomic_fetch_dec_release(...) > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > # endif > #endif > > The idea is that because we already group these APIs by certain defines > such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary > branches - we can do the same in the secondary branch as well. > > ( Also remove some unnecessarily duplicate comments, as the API > group defines are now pretty much self-documenting. ) > > No change in functionality. > > Cc: Peter Zijlstra <pet...@infradead.org> > Cc: Linus Torvalds <torva...@linux-foundation.org> > Cc: Andrew Morton <a...@linux-foundation.org> > Cc: Thomas Gleixner <t...@linutronix.de> > Cc: Paul E. McKenney <paul...@linux.vnet.ibm.com> > Cc: Will Deacon <will.dea...@arm.com> > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Ingo Molnar <mi...@kernel.org> This breaks compilation on RISC-V. (For some of its atomics, the arch currently defines the _relaxed and the full variants and it relies on the generic definitions for the _acquire and the _release variants.) Andrea > --- > include/linux/atomic.h | 312 > ++--- > 1 file changed, 62 insertions(+), 250 deletions(-) > > diff --git a/include/linux/atomic.h b/include/linux/atomic.h > index 67aaafba256b..352ecc72d7f5 100644 > --- a/include/linux/atomic.h > +++ b/include/linux/atomic.h > @@ -71,98 +71,66 @@ > }) > #endif > > -/* atomic_add_return_relaxed() et al: */ > - > #ifndef atomic_add_return_relaxed > # define atomic_add_return_relaxed atomic_add_return > # define atomic_add_return_acquire atomic_add_return > # define atomic_add_return_release atomic_add_return > #else > -# ifndef atomic_add_return_acquire > -# define atomic_add_return_acquire(...) > __atomic_op_acquire(atomic_add_return, __VA_ARGS__) > -# endif > -# ifndef atomic_add_return_release > -# define atomic_add_return_release(...) > __atomic_op_release(atomic_add_return, __VA_ARGS__) > -# endif > # ifndef atomic_add_return > # define atomic_add_return(...) > __atomic_op_fence(atomic_add_return, __VA_ARGS__) > +# define atomic_add_return_acquire(...) > __atomic_op_acquire(atomic_add_return, __VA_ARGS__) > +# define atomic_add_return_release(...) > __atomic_op_release(ato
Re: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
Hi Ingo, > From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 > From: Ingo Molnar > Date: Sat, 5 May 2018 10:23:23 +0200 > Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h > some more > > Before: > > #ifndef atomic_fetch_dec_relaxed > # ifndef atomic_fetch_dec > # define atomic_fetch_dec(v)atomic_fetch_sub(1, (v)) > # define atomic_fetch_dec_relaxed(v) > atomic_fetch_sub_relaxed(1, (v)) > # define atomic_fetch_dec_acquire(v) > atomic_fetch_sub_acquire(1, (v)) > # define atomic_fetch_dec_release(v) > atomic_fetch_sub_release(1, (v)) > # else > # define atomic_fetch_dec_relaxed atomic_fetch_dec > # define atomic_fetch_dec_acquire atomic_fetch_dec > # define atomic_fetch_dec_release atomic_fetch_dec > # endif > #else > # ifndef atomic_fetch_dec_acquire > # define atomic_fetch_dec_acquire(...) > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > # endif > # ifndef atomic_fetch_dec_release > # define atomic_fetch_dec_release(...) > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > # endif > # ifndef atomic_fetch_dec > # define atomic_fetch_dec(...) > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > # endif > #endif > > After: > > #ifndef atomic_fetch_dec_relaxed > # ifndef atomic_fetch_dec > # define atomic_fetch_dec(v)atomic_fetch_sub(1, (v)) > # define atomic_fetch_dec_relaxed(v) > atomic_fetch_sub_relaxed(1, (v)) > # define atomic_fetch_dec_acquire(v) > atomic_fetch_sub_acquire(1, (v)) > # define atomic_fetch_dec_release(v) > atomic_fetch_sub_release(1, (v)) > # else > # define atomic_fetch_dec_relaxed atomic_fetch_dec > # define atomic_fetch_dec_acquire atomic_fetch_dec > # define atomic_fetch_dec_release atomic_fetch_dec > # endif > #else > # ifndef atomic_fetch_dec > # define atomic_fetch_dec(...) > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > # define atomic_fetch_dec_acquire(...) > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > # define atomic_fetch_dec_release(...) > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > # endif > #endif > > The idea is that because we already group these APIs by certain defines > such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary > branches - we can do the same in the secondary branch as well. > > ( Also remove some unnecessarily duplicate comments, as the API > group defines are now pretty much self-documenting. ) > > No change in functionality. > > Cc: Peter Zijlstra > Cc: Linus Torvalds > Cc: Andrew Morton > Cc: Thomas Gleixner > Cc: Paul E. McKenney > Cc: Will Deacon > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Ingo Molnar This breaks compilation on RISC-V. (For some of its atomics, the arch currently defines the _relaxed and the full variants and it relies on the generic definitions for the _acquire and the _release variants.) Andrea > --- > include/linux/atomic.h | 312 > ++--- > 1 file changed, 62 insertions(+), 250 deletions(-) > > diff --git a/include/linux/atomic.h b/include/linux/atomic.h > index 67aaafba256b..352ecc72d7f5 100644 > --- a/include/linux/atomic.h > +++ b/include/linux/atomic.h > @@ -71,98 +71,66 @@ > }) > #endif > > -/* atomic_add_return_relaxed() et al: */ > - > #ifndef atomic_add_return_relaxed > # define atomic_add_return_relaxed atomic_add_return > # define atomic_add_return_acquire atomic_add_return > # define atomic_add_return_release atomic_add_return > #else > -# ifndef atomic_add_return_acquire > -# define atomic_add_return_acquire(...) > __atomic_op_acquire(atomic_add_return, __VA_ARGS__) > -# endif > -# ifndef atomic_add_return_release > -# define atomic_add_return_release(...) > __atomic_op_release(atomic_add_return, __VA_ARGS__) > -# endif > # ifndef atomic_add_return > # define atomic_add_return(...) > __atomic_op_fence(atomic_add_return, __VA_ARGS__) > +# define atomic_add_return_acquire(...) > __atomic_op_acquire(atomic_add_return, __VA_ARGS__) > +# define atomic_add_return_release(...) > __atomic_op_release(atomic_add_return, __VA_ARGS__) > # endif > #endif > > -/* atomic_inc_return_relaxed() et al: */ > - > #ifndef atomic_inc_return_relaxed > # define atomic_inc_return_relaxed atomic_inc_return
[PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
omic.h | 1063 1 file changed, 343 insertions(+), 720 deletions(-) Note that I kept the second patch separate, because technically it changes the way we use the defines - it should not break anything, unless I missed some detail. Please keep this kind of clarity and simplicity in new instrumentation patches! Thanks, Ingo ==> >From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 From: Ingo Molnar <mi...@kernel.org> Date: Sat, 5 May 2018 10:23:23 +0200 Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more Before: #ifndef atomic_fetch_dec_relaxed # ifndef atomic_fetch_dec # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) # define atomic_fetch_dec_relaxed(v) atomic_fetch_sub_relaxed(1, (v)) # define atomic_fetch_dec_acquire(v) atomic_fetch_sub_acquire(1, (v)) # define atomic_fetch_dec_release(v) atomic_fetch_sub_release(1, (v)) # else # define atomic_fetch_dec_relaxed atomic_fetch_dec # define atomic_fetch_dec_acquire atomic_fetch_dec # define atomic_fetch_dec_release atomic_fetch_dec # endif #else # ifndef atomic_fetch_dec_acquire # define atomic_fetch_dec_acquire(...) __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) # endif # ifndef atomic_fetch_dec_release # define atomic_fetch_dec_release(...) __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) # endif # ifndef atomic_fetch_dec # define atomic_fetch_dec(...) __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) # endif #endif After: #ifndef atomic_fetch_dec_relaxed # ifndef atomic_fetch_dec # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) # define atomic_fetch_dec_relaxed(v) atomic_fetch_sub_relaxed(1, (v)) # define atomic_fetch_dec_acquire(v) atomic_fetch_sub_acquire(1, (v)) # define atomic_fetch_dec_release(v) atomic_fetch_sub_release(1, (v)) # else # define atomic_fetch_dec_relaxed atomic_fetch_dec # define atomic_fetch_dec_acquire atomic_fetch_dec # define atomic_fetch_dec_release atomic_fetch_dec # endif #else # ifndef atomic_fetch_dec # define atomic_fetch_dec(...) __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) # define atomic_fetch_dec_acquire(...) __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) # define atomic_fetch_dec_release(...) __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) # endif #endif The idea is that because we already group these APIs by certain defines such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary branches - we can do the same in the secondary branch as well. ( Also remove some unnecessarily duplicate comments, as the API group defines are now pretty much self-documenting. ) No change in functionality. Cc: Peter Zijlstra <pet...@infradead.org> Cc: Linus Torvalds <torva...@linux-foundation.org> Cc: Andrew Morton <a...@linux-foundation.org> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Paul E. McKenney <paul...@linux.vnet.ibm.com> Cc: Will Deacon <will.dea...@arm.com> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mi...@kernel.org> --- include/linux/atomic.h | 312 ++--- 1 file changed, 62 insertions(+), 250 deletions(-) diff --git a/include/linux/atomic.h b/include/linux/atomic.h index 67aaafba256b..352ecc72d7f5 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h @@ -71,98 +71,66 @@ }) #endif -/* atomic_add_return_relaxed() et al: */ - #ifndef atomic_add_return_relaxed # define atomic_add_return_relaxed atomic_add_return # define atomic_add_return_acquire atomic_add_return # define atomic_add_return_release atomic_add_return #else -# ifndef atomic_add_return_acquire -# define atomic_add_return_acquire(...) __atomic_op_acquire(atomic_add_return, __VA_ARGS__) -# endif -# ifndef atomic_add_return_release -# define atomic_add_return_release(...) __atomic_op_release(atomic_add_return, __VA_ARGS__) -# endif # ifndef atomic_add_return # define atomic_add_return(...) __atomic_op_fence(atomic_add_return, __VA_ARGS__) +# define atomic_add_return_acquire(...) __atomic_op_acquire(atomic_add_return, __VA_ARGS__) +# define atomic_add_return_release(...) __atomic_op_release(atomic_add_return, __VA_ARGS__) # endif #endif -/* atomic_inc_return_relaxed() et al: */ - #ifndef atomic_inc_return_relaxed # define atomic_inc_return_relaxed atomic_inc_return # define atomic_inc_return_acquire atomic_inc_return # define atomic_inc_return_release atomic_inc_return #else -# ifndef atomic_inc_return_acquire -# define atomic_inc_return_acquire(...)
[PATCH] locking/atomics: Simplify the op definitions in atomic.h some more
++ 1 file changed, 343 insertions(+), 720 deletions(-) Note that I kept the second patch separate, because technically it changes the way we use the defines - it should not break anything, unless I missed some detail. Please keep this kind of clarity and simplicity in new instrumentation patches! Thanks, Ingo ==> >From 5affbf7e91901143f84f1b2ca64f4afe70e210fd Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 May 2018 10:23:23 +0200 Subject: [PATCH] locking/atomics: Simplify the op definitions in atomic.h some more Before: #ifndef atomic_fetch_dec_relaxed # ifndef atomic_fetch_dec # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) # define atomic_fetch_dec_relaxed(v) atomic_fetch_sub_relaxed(1, (v)) # define atomic_fetch_dec_acquire(v) atomic_fetch_sub_acquire(1, (v)) # define atomic_fetch_dec_release(v) atomic_fetch_sub_release(1, (v)) # else # define atomic_fetch_dec_relaxed atomic_fetch_dec # define atomic_fetch_dec_acquire atomic_fetch_dec # define atomic_fetch_dec_release atomic_fetch_dec # endif #else # ifndef atomic_fetch_dec_acquire # define atomic_fetch_dec_acquire(...) __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) # endif # ifndef atomic_fetch_dec_release # define atomic_fetch_dec_release(...) __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) # endif # ifndef atomic_fetch_dec # define atomic_fetch_dec(...) __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) # endif #endif After: #ifndef atomic_fetch_dec_relaxed # ifndef atomic_fetch_dec # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) # define atomic_fetch_dec_relaxed(v) atomic_fetch_sub_relaxed(1, (v)) # define atomic_fetch_dec_acquire(v) atomic_fetch_sub_acquire(1, (v)) # define atomic_fetch_dec_release(v) atomic_fetch_sub_release(1, (v)) # else # define atomic_fetch_dec_relaxed atomic_fetch_dec # define atomic_fetch_dec_acquire atomic_fetch_dec # define atomic_fetch_dec_release atomic_fetch_dec # endif #else # ifndef atomic_fetch_dec # define atomic_fetch_dec(...) __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) # define atomic_fetch_dec_acquire(...) __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) # define atomic_fetch_dec_release(...) __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) # endif #endif The idea is that because we already group these APIs by certain defines such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary branches - we can do the same in the secondary branch as well. ( Also remove some unnecessarily duplicate comments, as the API group defines are now pretty much self-documenting. ) No change in functionality. Cc: Peter Zijlstra Cc: Linus Torvalds Cc: Andrew Morton Cc: Thomas Gleixner Cc: Paul E. McKenney Cc: Will Deacon Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- include/linux/atomic.h | 312 ++--- 1 file changed, 62 insertions(+), 250 deletions(-) diff --git a/include/linux/atomic.h b/include/linux/atomic.h index 67aaafba256b..352ecc72d7f5 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h @@ -71,98 +71,66 @@ }) #endif -/* atomic_add_return_relaxed() et al: */ - #ifndef atomic_add_return_relaxed # define atomic_add_return_relaxed atomic_add_return # define atomic_add_return_acquire atomic_add_return # define atomic_add_return_release atomic_add_return #else -# ifndef atomic_add_return_acquire -# define atomic_add_return_acquire(...) __atomic_op_acquire(atomic_add_return, __VA_ARGS__) -# endif -# ifndef atomic_add_return_release -# define atomic_add_return_release(...) __atomic_op_release(atomic_add_return, __VA_ARGS__) -# endif # ifndef atomic_add_return # define atomic_add_return(...) __atomic_op_fence(atomic_add_return, __VA_ARGS__) +# define atomic_add_return_acquire(...) __atomic_op_acquire(atomic_add_return, __VA_ARGS__) +# define atomic_add_return_release(...) __atomic_op_release(atomic_add_return, __VA_ARGS__) # endif #endif -/* atomic_inc_return_relaxed() et al: */ - #ifndef atomic_inc_return_relaxed # define atomic_inc_return_relaxed atomic_inc_return # define atomic_inc_return_acquire atomic_inc_return # define atomic_inc_return_release atomic_inc_return #else -# ifndef atomic_inc_return_acquire -# define atomic_inc_return_acquire(...) __atomic_op_acquire(atomic_inc_return, __VA_ARGS__) -# endif -# ifndef atomic_inc_return_release -# define atomic_inc_return_release(...) __atomic_op_release(atomic_inc_return, __VA_ARGS__) -# endif # ifndef atomic_inc_return # define atom