atomic64: No need for CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
Subsystems (13)
PATCH 1/1 atomic64: No need for CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
This came to light when implementing native 64-bit atomics for ARCv2.
The atomic64 self-test code uses CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE to check whether atomic64_dec_if_positive() is available.
It seems it was needed when not every arch defined it. However as of current code the Kconfig option seems needless
- for CONFIG_GENERIC_ATOMIC64 it is auto-enabled in lib/Kconfig and a generic definition of API is present lib/atomic64.c
- arches with native 64-bit atomics select it in arch/*/Kconfig and define the API in their headers
So I see no point in keeping the Kconfig option
Compile tested for 2 representatives:
- blackfin (CONFIG_GENERIC_ATOMIC64)
- x86 (!CONFIG_GENERIC_ATOMIC64)
Also logistics wise it seemed simpler to just do this in 1 patch vs. splitting per arch - but I can break it up if maintainer feel that is better to avoid conflicts.
--- arch/alpha/Kconfig | 1 - arch/arm/Kconfig | 1 - arch/arm64/Kconfig | 1 - arch/mips/Kconfig | 1 - arch/parisc/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/sparc/Kconfig | 1 - arch/tile/Kconfig | 1 - arch/x86/Kconfig | 1 - lib/Kconfig | 3 --- lib/atomic64_test.c | 4 ---- 12 files changed, 17 deletions(-)
arch/alpha/Kconfig +0 -1
@@ -15,7 +15,6 @@ config ALPHA select GENERIC_IRQ_SHOW select ARCH_WANT_IPC_PARSE_VERSION select ARCH_HAVE_NMI_SAFE_CMPXCHG - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select AUDIT_ARCH select GENERIC_CLOCKEVENTS select GENERIC_SMP_IDLE_THREAD
arch/arm/Kconfig +0 -1
@@ -1,7 +1,6 @@ config ARM bool default y - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
arch/arm64/Kconfig +0 -1
@@ -6,7 +6,6 @@ config ARM64 select ACPI_MCFG if ACPI select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_KCOV
arch/mips/Kconfig +0 -1
@@ -30,7 +30,6 @@ config MIPS select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES && 64BIT select RTC_LIB if !MACH_LOONGSON64 select GENERIC_ATOMIC64 if !64BIT - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select HAVE_DMA_CONTIGUOUS select HAVE_DMA_API_DEBUG select GENERIC_IRQ_PROBE
arch/parisc/Kconfig +0 -1
@@ -15,7 +15,6 @@ config PARISC select BUILDTIME_EXTABLE_SORT select HAVE_PERF_EVENTS select GENERIC_ATOMIC64 if !64BIT - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select BROKEN_RODATA select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP
arch/powerpc/Kconfig +0 -1
@@ -113,7 +113,6 @@ config PPC select HAVE_DEBUG_KMEMLEAK select ARCH_HAS_SG_CHAIN select GENERIC_ATOMIC64 if PPC32 - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select HAVE_PERF_EVENTS select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP
arch/s390/Kconfig +0 -1
@@ -67,7 +67,6 @@ config DEBUG_RODATA config S390 def_bool y - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE
arch/sparc/Kconfig +0 -1
@@ -22,7 +22,6 @@ config SPARC select HAVE_ARCH_TRACEHOOK select HAVE_EXIT_THREAD select SYSCTL_EXCEPTION_TRACE - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select RTC_CLASS select RTC_DRV_M48T59 select RTC_SYSTOHC
arch/tile/Kconfig +0 -1
@@ -3,7 +3,6 @@ config TILE def_bool y - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAVE_NMI_SAFE_CMPXCHG
arch/x86/Kconfig +0 -1
@@ -23,7 +23,6 @@ config X86 select ARCH_CLOCKSOURCE_DATA select ARCH_DISCARD_MEMBLOCK select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE
lib/Kconfig +0 -3
@@ -457,9 +457,6 @@ config NLATTR config GENERIC_ATOMIC64 bool -config ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE - def_bool y if GENERIC_ATOMIC64 - config LRU_CACHE tristate
lib/atomic64_test.c +0 -4
@@ -213,7 +213,6 @@ static __init void test_atomic64(void) r += one;BUG_ON (v.counter != r); -#ifdef CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE INIT (onestwos);BUG_ON (atomic64_dec_if_positive (&v) != (onestwos -1 )); r -= one;
@@ -226,9 +225,6 @@ static __init void test_atomic64(void)INIT (-one);BUG_ON (atomic64_dec_if_positive (&v) != (-one - one));BUG_ON (v.counter != r); -#else -#warning Please implement atomic64_dec_if_positive for your architecture and select the above Kconfig symbol -#endif INIT (onestwos);BUG_ON (!atomic64_inc_not_zero (&v));
Signature · 1 line
2.7.4
Peter Zijlstra
maintainerQuoted 14 lines · Vineet Gupta
This came to light when implementing native 64-bit atomics for ARCv2.
The atomic64 self-test code uses
CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVEto check whetheratomic64_dec_if_positive()is available.
It seems it was needed when not every arch defined it. However as of current code theKconfigoption seems needless- for
CONFIG_GENERIC_ATOMIC64it is auto-enabled in lib/Kconfig and a generic definition of API is presentlib/atomic64.c
- arches with native 64-bit atomics select it inarch/*/Kconfigand define the API in their headersSo I see no point in keeping the
Kconfigoption
Quoted 7 lines
Compile tested for 2 representatives:
- blackfin (CONFIG_GENERIC_ATOMIC64)
- x86 (!CONFIG_GENERIC_ATOMIC64)Also logistics wise it seemed simpler to just do this in 1 patch vs. splitting per arch - but I can break it up if maintainer feel that is better to avoid conflicts.
Works for me; you want me to take this, or do you need it for you ARCv2 patches?
Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Vineet Gupta
This came to light when implementing native 64-bit atomics for ARCv2.
The atomic64 self-test code uses
CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVEto check whetheratomic64_dec_if_positive()is available.
It seems it was needed when not every arch defined it. However as of current code theKconfigoption seems needless- for
CONFIG_GENERIC_ATOMIC64it is auto-enabled in lib/Kconfig and a generic definition of API is presentlib/atomic64.c
- arches with native 64-bit atomics select it inarch/*/Kconfigand define the API in their headersSo I see no point in keeping the
KconfigoptionCompile tested for 2 representatives:
- blackfin (CONFIG_GENERIC_ATOMIC64)
- x86 (!CONFIG_GENERIC_ATOMIC64)
Quoted 5 lines
Quoted 3 lines
Also logistics wise it seemed simpler to just do this in 1 patch vs. splitting per arch - but I can break it up if maintainer feel that is better to avoid conflicts.
Works for me; you want me to take this, or do you need it for you ARCv2 patches?
Please do. ARCv2 patch (following shortly) doesn't need it - I selected the option in orig patch - which I can just take out.
Thx,
-Vineet
kbuild test robot
build botreproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Vineet,
[auto build test ERROR on arm64/for-next/core]
[cannot apply to linus/master linux/master v4.8-rc5 next-20160909]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Vineet-Gupta/atomic64-No-need-for-CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE/20160909-013936 base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 4.9.0
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64
All errors (new ones prefixed by >>):
lib/atomic64_test.c: In function 'test_atomic64':
>> lib/atomic64_test.c:217:2: error: implicit declaration of function 'atomic64_dec_if_positive' [-Werror=implicit-function-declaration]
BUG_ON(atomic64_dec_if_positive(&v) != (onestwos - 1));
^cc1: some warnings being treated as errors
vim +/atomic64_dec_if_positive +217 lib/atomic64_test.c
86a89380 Luca Barbieri 2010-02-24 211 INIT(v0); 9efbcd59 Luca Barbieri 2010-03-01 212 BUG_ON(!atomic64_add_unless(&v, one, v1)); 86a89380 Luca Barbieri 2010-02-24 213 r += one; 86a89380 Luca Barbieri 2010-02-24 214 BUG_ON(v.counter != r); 86a89380 Luca Barbieri 2010-02-24 215 86a89380 Luca Barbieri 2010-02-24 216 INIT(onestwos); 86a89380 Luca Barbieri 2010-02-24 @217 BUG_ON(atomic64_dec_if_positive(&v) != (onestwos - 1)); 86a89380 Luca Barbieri 2010-02-24 218 r -= one; 86a89380 Luca Barbieri 2010-02-24 219 BUG_ON(v.counter != r);
86a89380 Luca Barbieri 2010-02-24 220
:::::: The code at line 217 was first introduced by commit
:::::: 86a8938078a8bb518c5376de493e348c7490d506 lib: Add self-test for atomic64_t
:::::: TO: Luca Barbieri <[email protected]>
:::::: CC: H. Peter Anvin <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
v3 cover Getting rid of CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
Hi Peter / Tony.
Sorry for the rebase snafu with v2.
So kbuild service reported build failure of ia64 with v1 of the patch. I've added an untested atomic64_dec_if_positive() to ia64, shamelessly copied from s390 with some adjustments 64-bit long etc. Could you please double check.
It builds fine with ia64 cross compiler.
Thx,
-Vineet
*** BLURB HERE ***
Vineet Gupta (2):
ia64: implement atomic64_dec_if_positive
atomic64: No need for CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
arch/alpha/Kconfig | 1 - arch/arm/Kconfig | 1 - arch/arm64/Kconfig | 1 - arch/ia64/include/asm/atomic.h | 16 ++++++++++++++++ arch/mips/Kconfig | 1 - arch/parisc/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/sparc/Kconfig | 1 - arch/tile/Kconfig | 1 - arch/x86/Kconfig | 1 - lib/Kconfig | 3 --- lib/atomic64_test.c | 4 ---- 13 files changed, 16 insertions(+), 17 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/2 ia64: implement atomic64_dec_if_positive
This is based on s390 version and needed to get rid of CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
--- arch/ia64/include/asm/atomic.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/ia64/include/asm/atomic.h +16 -0
@@ -269,6 +269,22 @@ static __inline__ long atomic64_add_unless(atomic64_t *v, long a, long u)#define atomic64_inc_not_zero (v) atomic64_add_unless((v), 1, 0) +static __inline__long atomic64_dec_if_positive (atomic64_t *v) +{ +long c, old, dec; + c =atomic64_read (v); +for (;;) { + dec = c -1 ; +if (unlikely (dec <0 )) +break ; + old =atomic64_cmpxchg ((v), c, dec); +if (likely (old = c)) +break ; + c = old; + } +return dec; +} +/* * Atomically add I to V and return TRUE if the resulting value is * negative.
Signature · 1 line
2.7.4
PATCH v3 2/2 atomic64: No need for CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
In reply to Vineet GuptaThis came to light when implementing native 64-bit atomics for ARCv2.
The atomic64 self-test code uses CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE to check whether atomic64_dec_if_positive() is available.
It seems it was needed when not every arch defined it. However as of current code the Kconfig option seems needless
- for CONFIG_GENERIC_ATOMIC64 it is auto-enabled in lib/Kconfig and a generic definition of API is present lib/atomic64.c
- arches with native 64-bit atomics select it in arch/*/Kconfig and define the API in their headers
So I see no point in keeping the Kconfig option
Compile tested for:
- blackfin (CONFIG_GENERIC_ATOMIC64)
- x86 (!CONFIG_GENERIC_ATOMIC64)
- ia64
--- arch/alpha/Kconfig | 1 - arch/arm/Kconfig | 1 - arch/arm64/Kconfig | 1 - arch/mips/Kconfig | 1 - arch/parisc/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/sparc/Kconfig | 1 - arch/tile/Kconfig | 1 - arch/x86/Kconfig | 1 - lib/Kconfig | 3 --- lib/atomic64_test.c | 4 ---- 12 files changed, 17 deletions(-)
arch/alpha/Kconfig +0 -1
@@ -15,7 +15,6 @@ config ALPHA select GENERIC_IRQ_SHOW select ARCH_WANT_IPC_PARSE_VERSION select ARCH_HAVE_NMI_SAFE_CMPXCHG - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select AUDIT_ARCH select GENERIC_CLOCKEVENTS select GENERIC_SMP_IDLE_THREAD
arch/arm/Kconfig +0 -1
@@ -1,7 +1,6 @@ config ARM bool default y - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
arch/arm64/Kconfig +0 -1
@@ -6,7 +6,6 @@ config ARM64 select ACPI_MCFG if ACPI select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_KCOV
arch/mips/Kconfig +0 -1
@@ -30,7 +30,6 @@ config MIPS select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES && 64BIT select RTC_LIB if !MACH_LOONGSON64 select GENERIC_ATOMIC64 if !64BIT - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select HAVE_DMA_CONTIGUOUS select HAVE_DMA_API_DEBUG select GENERIC_IRQ_PROBE
arch/parisc/Kconfig +0 -1
@@ -14,7 +14,6 @@ config PARISC select BUILDTIME_EXTABLE_SORT select HAVE_PERF_EVENTS select GENERIC_ATOMIC64 if !64BIT - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select BROKEN_RODATA select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP
arch/powerpc/Kconfig +0 -1
@@ -113,7 +113,6 @@ config PPC select HAVE_DEBUG_KMEMLEAK select ARCH_HAS_SG_CHAIN select GENERIC_ATOMIC64 if PPC32 - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select HAVE_PERF_EVENTS select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP
arch/s390/Kconfig +0 -1
@@ -67,7 +67,6 @@ config DEBUG_RODATA config S390 def_bool y - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_GCOV_PROFILE_ALL
arch/sparc/Kconfig +0 -1
@@ -22,7 +22,6 @@ config SPARC select HAVE_ARCH_TRACEHOOK select HAVE_EXIT_THREAD select SYSCTL_EXCEPTION_TRACE - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select RTC_CLASS select RTC_DRV_M48T59 select RTC_SYSTOHC
arch/tile/Kconfig +0 -1
@@ -3,7 +3,6 @@ config TILE def_bool y - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_WANT_FRAME_POINTERS
arch/x86/Kconfig +0 -1
@@ -23,7 +23,6 @@ config X86 select ARCH_CLOCKSOURCE_DATA select ARCH_DISCARD_MEMBLOCK select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FAST_MULTIPLIER
lib/Kconfig +0 -3
@@ -457,9 +457,6 @@ config NLATTR config GENERIC_ATOMIC64 bool -config ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE - def_bool y if GENERIC_ATOMIC64 - config LRU_CACHE tristate
lib/atomic64_test.c +0 -4
@@ -213,7 +213,6 @@ static __init void test_atomic64(void) r += one;BUG_ON (v.counter != r); -#ifdef CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE INIT (onestwos);BUG_ON (atomic64_dec_if_positive (&v) != (onestwos -1 )); r -= one;
@@ -226,9 +225,6 @@ static __init void test_atomic64(void)INIT (-one);BUG_ON (atomic64_dec_if_positive (&v) != (-one - one));BUG_ON (v.counter != r); -#else -#warning Please implement atomic64_dec_if_positive for your architecture and select the above Kconfig symbol -#endif INIT (onestwos);BUG_ON (!atomic64_inc_not_zero (&v));
Signature · 1 line
2.7.4