Skip to contentSkip to conversation

MIPS: cmpxchg64() and HAVE_VIRT_CPU_ACCOUNTING_GEN don't work for 32-bit SMP

RFC PATCH Applied Ben Hutchings 2 participants 2 messages Oct 4, 2017 – Nov 13, 2017 MIPS

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 MIPS: cmpxchg64() and HAVE_VIRT_CPU_ACCOUNTING_GEN don't work for 32-bit SMP

__cmpxchg64_local_generic() is atomic only w.r.t tasks and interrupts on the same CPU (that's what the 'local' means). We can't use it to implement cmpxchg64() in SMP configurations.

So, for 32-bit SMP configurations:

- Don't define cmpxchg64()
- Don't enable HAVE_VIRT_CPU_ACCOUNTING_GEN, which requires it

Fixes e2093c7b03c1 ("MIPS: Fall back to generic implementation of ...")
Fixes bb877e96bea1 ("MIPS: Add support for full dynticks CPU time accounting")
---
 arch/mips/Kconfig               | 2 +-
 arch/mips/include/asm/cmpxchg.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/mips/Kconfig +1 -1
index cb7fcc4216fd..1e23f8455b7d 100644
@@ -64,7 +64,7 @@ config MIPS
 	select HAVE_PERF_EVENTS
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_SYSCALL_TRACEPOINTS
-	select HAVE_VIRT_CPU_ACCOUNTING_GEN
+	select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP
 	select IRQ_FORCED_THREADING
 	select MODULES_USE_ELF_RELA if MODULES && 64BIT
 	select MODULES_USE_ELF_REL if MODULES
arch/mips/include/asm/cmpxchg.h +2 -0
index 903f3bf48419..ae2b4583b486 100644
@@ -202,8 +202,10 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
 #else
 #include <asm-generic/cmpxchg-local.h>
 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
+#ifndef CONFIG_SMP
 #define cmpxchg64(ptr, o, n) cmpxchg64_local((ptr), (o), (n))
 #endif
+#endif
 
 #undef __scbeqz
 
Applied
#1 lore raw
Quoted 4 lines · Ben Hutchings

__cmpxchg64_local_generic() is atomic only w.r.t tasks and interrupts on the same CPU (that's what the 'local' means). We can't use it to implement cmpxchg64() in SMP configurations.

Quoted 8 lines

So, for 32-bit SMP configurations:

- Don't define cmpxchg64()
- Don't enable HAVE_VIRT_CPU_ACCOUNTING_GEN, which requires it

Fixes e2093c7b03c1 ("MIPS: Fall back to generic implementation of ...")
Fixes bb877e96bea1 ("MIPS: Add support for full dynticks CPU time accounting")

Thanks, looks reasonable to me

Applied

Cheers
James

Quoted 33 lines
---
 arch/mips/Kconfig               | 2 +-
 arch/mips/include/asm/cmpxchg.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/mips/Kconfig +1 -1
index cb7fcc4216fd..1e23f8455b7d 100644
@@ -64,7 +64,7 @@ config MIPS
 	select HAVE_PERF_EVENTS
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_SYSCALL_TRACEPOINTS
-	select HAVE_VIRT_CPU_ACCOUNTING_GEN
+	select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP
 	select IRQ_FORCED_THREADING
 	select MODULES_USE_ELF_RELA if MODULES && 64BIT
 	select MODULES_USE_ELF_REL if MODULES
arch/mips/include/asm/cmpxchg.h +2 -0
index 903f3bf48419..ae2b4583b486 100644
@@ -202,8 +202,10 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
 #else
 #include <asm-generic/cmpxchg-local.h>
 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
+#ifndef CONFIG_SMP
 #define cmpxchg64(ptr, o, n) cmpxchg64_local((ptr), (o), (n))
 #endif
+#endif
 
 #undef __scbeqz