* [PATCH 1/2] futex: ensure futex_atomic_cmpxchg_inatomic() is present
@ 2021-10-26 10:03 Arnd Bergmann
2021-10-26 10:03 ` Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 29+ messages in thread
From: Arnd Bergmann @ 2021-10-26 10:03 UTC (permalink / raw)
To: Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Thomas Bogendoerfer, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida,
Masahiro Yamada, Kees Cook, Andrew Morton, Nathan Chancellor,
linux-mips, linux-kernel, linux-xtensa, linux-arch
From: Arnd Bergmann <arnd@arndb.de>
The boot-time detection of futex_atomic_cmpxchg_inatomic()
has a bug on some 32-bit arm builds, and Thomas Gleixner
suggested that setting CONFIG_HAVE_FUTEX_CMPXCHG would
avoid the problem, as it is always present anyway.
Looking into which other architectures could do the same
showed that almost all architectures have it, the exceptions
being:
- some old 32-bit MIPS uniprocessor cores without ll/sc
- one xtensa variant with no SMP
- 32-bit SPARC when built for SMP
Fix MIPS And Xtensa by rearranging the generic code to let it be used
as a fallback.
For SPARC, the SMP definition just ends up turning off futex anyway,
so this can be done at Kconfig time instead. Note that sparc32
glibc requires the CASA instruction for its mutexes anyway,
which is only available when running on SPARCv9 or LEON CPUs,
but needs to be implemented in the sparc32 kernel for those.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/mips/include/asm/futex.h | 29 ++++++++++++++++++-----------
arch/xtensa/include/asm/futex.h | 8 ++++++--
include/asm-generic/futex.h | 31 +++++++++++--------------------
init/Kconfig | 1 +
4 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/arch/mips/include/asm/futex.h b/arch/mips/include/asm/futex.h
index d85248404c52..9287110cb06d 100644
--- a/arch/mips/include/asm/futex.h
+++ b/arch/mips/include/asm/futex.h
@@ -19,7 +19,11 @@
#include <asm/sync.h>
#include <asm/war.h>
-#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
+#define arch_futex_atomic_op_inuser arch_futex_atomic_op_inuser
+#define futex_atomic_cmpxchg_inatomic futex_atomic_cmpxchg_inatomic
+#include <asm-generic/futex.h>
+
+#define __futex_atomic_op(op, insn, ret, oldval, uaddr, oparg) \
{ \
if (cpu_has_llsc && IS_ENABLED(CONFIG_WAR_R10000_LLSC)) { \
__asm__ __volatile__( \
@@ -80,9 +84,11 @@
: "0" (0), GCC_OFF_SMALL_ASM() (*uaddr), "Jr" (oparg), \
"i" (-EFAULT) \
: "memory"); \
- } else \
- ret = -ENOSYS; \
-}
+ } else { \
+ /* fallback for non-SMP */ \
+ ret = arch_futex_atomic_op_inuser_local(op, oparg, oval,\
+ uaddr); \
+ }
static inline int
arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
@@ -94,23 +100,23 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
switch (op) {
case FUTEX_OP_SET:
- __futex_atomic_op("move $1, %z5", ret, oldval, uaddr, oparg);
+ __futex_atomic_op(op, "move $1, %z5", ret, oldval, uaddr, oparg);
break;
case FUTEX_OP_ADD:
- __futex_atomic_op("addu $1, %1, %z5",
+ __futex_atomic_op(op, "addu $1, %1, %z5",
ret, oldval, uaddr, oparg);
break;
case FUTEX_OP_OR:
- __futex_atomic_op("or $1, %1, %z5",
+ __futex_atomic_op(op, "or $1, %1, %z5",
ret, oldval, uaddr, oparg);
break;
case FUTEX_OP_ANDN:
- __futex_atomic_op("and $1, %1, %z5",
+ __futex_atomic_op(op, "and $1, %1, %z5",
ret, oldval, uaddr, ~oparg);
break;
case FUTEX_OP_XOR:
- __futex_atomic_op("xor $1, %1, %z5",
+ __futex_atomic_op(op, "xor $1, %1, %z5",
ret, oldval, uaddr, oparg);
break;
default:
@@ -193,8 +199,9 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
: GCC_OFF_SMALL_ASM() (*uaddr), "Jr" (oldval), "Jr" (newval),
"i" (-EFAULT)
: "memory");
- } else
- return -ENOSYS;
+ } else {
+ return futex_atomic_cmpxchg_inatomic_local(uval, uaddr, oldval, newval);
+ }
*uval = val;
return ret;
diff --git a/arch/xtensa/include/asm/futex.h b/arch/xtensa/include/asm/futex.h
index a1a27b2ea460..fe8f31575ab1 100644
--- a/arch/xtensa/include/asm/futex.h
+++ b/arch/xtensa/include/asm/futex.h
@@ -16,6 +16,10 @@
#include <linux/uaccess.h>
#include <linux/errno.h>
+#define arch_futex_atomic_op_inuser arch_futex_atomic_op_inuser
+#define futex_atomic_cmpxchg_inatomic futex_atomic_cmpxchg_inatomic
+#include <asm-generic/futex.h>
+
#if XCHAL_HAVE_EXCLUSIVE
#define __futex_atomic_op(insn, ret, old, uaddr, arg) \
__asm__ __volatile( \
@@ -105,7 +109,7 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
return ret;
#else
- return -ENOSYS;
+ return arch_futex_atomic_op_inuser_local(op, oparg, oval, uaddr);
#endif
}
@@ -156,7 +160,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
return ret;
#else
- return -ENOSYS;
+ return futex_atomic_cmpxchg_inatomic_local(uval, uaddr, oldval, newval);
#endif
}
diff --git a/include/asm-generic/futex.h b/include/asm-generic/futex.h
index f4c3470480c7..30e7fa63b5df 100644
--- a/include/asm-generic/futex.h
+++ b/include/asm-generic/futex.h
@@ -6,15 +6,22 @@
#include <linux/uaccess.h>
#include <asm/errno.h>
+#ifndef futex_atomic_cmpxchg_inatomic
#ifndef CONFIG_SMP
/*
* The following implementation only for uniprocessor machines.
* It relies on preempt_disable() ensuring mutual exclusion.
*
*/
+#define futex_atomic_cmpxchg_inatomic(uval, uaddr, oldval, newval) \
+ futex_atomic_cmpxchg_inatomic_local_generic(uval, uaddr, oldval, newval)
+#define arch_futex_atomic_op_inuser(op, oparg, oval, uaddr) \
+ arch_futex_atomic_op_inuser_local_generic(op, oparg, oval, uaddr)
+#endif /* CONFIG_SMP */
+#endif
/**
- * arch_futex_atomic_op_inuser() - Atomic arithmetic operation with constant
+ * arch_futex_atomic_op_inuser_local() - Atomic arithmetic operation with constant
* argument and comparison of the previous
* futex value with another constant.
*
@@ -28,7 +35,7 @@
* -ENOSYS - Operation not supported
*/
static inline int
-arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr)
+futex_atomic_op_inuser_local(int op, u32 oparg, int *oval, u32 __user *uaddr)
{
int oldval, ret;
u32 tmp;
@@ -75,7 +82,7 @@ arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr)
}
/**
- * futex_atomic_cmpxchg_inatomic() - Compare and exchange the content of the
+ * futex_atomic_cmpxchg_inatomic_local() - Compare and exchange the content of the
* uaddr with newval if the current value is
* oldval.
* @uval: pointer to store content of @uaddr
@@ -87,10 +94,9 @@ arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr)
* 0 - On success
* -EFAULT - User access resulted in a page fault
* -EAGAIN - Atomic operation was unable to complete due to contention
- * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
*/
static inline int
-futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
+futex_atomic_cmpxchg_inatomic_local(u32 *uval, u32 __user *uaddr,
u32 oldval, u32 newval)
{
u32 val;
@@ -112,19 +118,4 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
return 0;
}
-#else
-static inline int
-arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr)
-{
- return -ENOSYS;
-}
-
-static inline int
-futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
- u32 oldval, u32 newval)
-{
- return -ENOSYS;
-}
-
-#endif /* CONFIG_SMP */
#endif
diff --git a/init/Kconfig b/init/Kconfig
index edc0a0228f14..c0f55ea5a71f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1584,6 +1584,7 @@ config BASE_FULL
config FUTEX
bool "Enable futex support" if EXPERT
+ depends on !(SPARC32 && SMP)
default y
imply RT_MUTEXES
help
--
2.29.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 2/2] futex: remove futex_cmpxchg detection
2021-10-26 10:03 [PATCH 1/2] futex: ensure futex_atomic_cmpxchg_inatomic() is present Arnd Bergmann
2021-10-26 10:03 ` Arnd Bergmann
2021-10-26 12:29 ` [PATCH 1/2] futex: ensure futex_atomic_cmpxchg_inatomic() is present Max Filippov
@ 2021-10-26 10:03 ` Arnd Bergmann
2 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2021-10-26 10:03 UTC (permalink / raw)
To: Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Vineet Gupta, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, Alexander Gordeev, Yoshinori Sato,
Rich Felker, Jeff Dike, Richard Weinberger, Anton Ivanov,
Chris Zankel, Max Filippov, Darren Hart, Davidlohr Bueso,
André Almeida, Andrew Morton, Mike Rapoport, Mark Rutland,
Anshuman Khandual, linux-snps-arc, linux-kernel,
linux-arm-kernel, linux-csky, linux-m68k, linux-riscv,
linux-s390, linux-sh, linux-um, linux-xtensa
From: Arnd Bergmann <arnd@arndb.de>
Now that all architectures have a working futex implementation
in any configuration, remove the runtime detection code.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arc/Kconfig | 1 -
arch/arm/Kconfig | 1 -
arch/arm64/Kconfig | 1 -
arch/csky/Kconfig | 1 -
arch/m68k/Kconfig | 1 -
arch/riscv/Kconfig | 1 -
arch/s390/Kconfig | 1 -
arch/sh/Kconfig | 1 -
arch/um/Kconfig | 1 -
arch/um/kernel/skas/uaccess.c | 1 -
arch/xtensa/Kconfig | 1 -
init/Kconfig | 8 --------
kernel/futex/core.c | 35 -----------------------------------
kernel/futex/futex.h | 6 ------
kernel/futex/syscalls.c | 22 ----------------------
15 files changed, 82 deletions(-)
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 248389278e8f..f9413041686f 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -31,7 +31,6 @@ config ARC
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
select HAVE_DEBUG_STACKOVERFLOW
select HAVE_DEBUG_KMEMLEAK
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_IOREMAP_PROT
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZMA
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index bb5d2c45477b..6448d311635d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -93,7 +93,6 @@ config ARM
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 0efc501f77aa..6c3c2ff5cef8 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -193,7 +193,6 @@ config ARM64
select HAVE_PERF_USER_STACK_DUMP
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_FUNCTION_ARG_ACCESS_API
- select HAVE_FUTEX_CMPXCHG if FUTEX
select MMU_GATHER_RCU_TABLE_FREE
select HAVE_RSEQ
select HAVE_STACKPROTECTOR
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 823d3d5a9e11..efd7c5feac8b 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -53,7 +53,6 @@ config CSKY
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 0b50da08a9c5..15a793c5b2dc 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -20,7 +20,6 @@ config M68K
select HAVE_ASM_MODVERSIONS
select HAVE_DEBUG_BUGVERBOSE
select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
- select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_UID16
select MMU_GATHER_NO_RANGE if MMU
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 77a088d0a7e9..037fea9fac14 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -84,7 +84,6 @@ config RISCV
select HAVE_DMA_CONTIGUOUS if MMU
select HAVE_EBPF_JIT if MMU
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO if MMU && 64BIT
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f615c3f65f5a..1c9ecf619e04 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -164,7 +164,6 @@ config S390
select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO
select HAVE_IOREMAP_PROT if PCI
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 6904f4bdbf00..93195d3368c0 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -34,7 +34,6 @@ config SUPERH
select HAVE_FAST_GUP if MMU
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_HW_BREAKPOINT
select HAVE_IOREMAP_PROT if MMU && !X2TLB
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index c18b45f75d41..c906250d4970 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -14,7 +14,6 @@ config UML
select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ASM_MODVERSIONS
select HAVE_UID16
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_DEBUG_KMEMLEAK
select HAVE_DEBUG_BUGVERBOSE
select NO_DMA if !UML_DMA_EMULATION
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index a509be911026..9e37a7c05990 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -348,7 +348,6 @@ EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
* 0 - On success
* -EFAULT - User access resulted in a page fault
* -EAGAIN - Atomic operation was unable to complete due to contention
- * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
*/
int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 0e56bad058fa..8ac599aa6d99 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -31,7 +31,6 @@ config XTENSA
select HAVE_DMA_CONTIGUOUS
select HAVE_EXIT_THREAD
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
select HAVE_HW_BREAKPOINT if PERF_EVENTS
select HAVE_IRQ_TIME_ACCOUNTING
select HAVE_PCI
diff --git a/init/Kconfig b/init/Kconfig
index c0f55ea5a71f..538688598f2f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1597,14 +1597,6 @@ config FUTEX_PI
depends on FUTEX && RT_MUTEXES
default y
-config HAVE_FUTEX_CMPXCHG
- bool
- depends on FUTEX
- help
- Architectures should select this if futex_atomic_cmpxchg_inatomic()
- is implemented and always working. This removes a couple of runtime
- checks.
-
config EPOLL
bool "Enable eventpoll support" if EXPERT
default y
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 25d8a88b32e5..926c2bb752bc 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -41,11 +41,6 @@
#include "futex.h"
#include "../locking/rtmutex_common.h"
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
-int __read_mostly futex_cmpxchg_enabled;
-#endif
-
-
/*
* The base of the bucket array and its size are always used together
* (after initialization only in futex_hash()), so ensure that they
@@ -776,9 +771,6 @@ static void exit_robust_list(struct task_struct *curr)
unsigned long futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -874,9 +866,6 @@ static void compat_exit_robust_list(struct task_struct *curr)
compat_long_t futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -950,8 +939,6 @@ static void exit_pi_state_list(struct task_struct *curr)
struct futex_hash_bucket *hb;
union futex_key key = FUTEX_KEY_INIT;
- if (!futex_cmpxchg_enabled)
- return;
/*
* We are a ZOMBIE and nobody can enqueue itself on
* pi_state_list anymore, but we have to be careful
@@ -1125,26 +1112,6 @@ void futex_exit_release(struct task_struct *tsk)
futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
}
-static void __init futex_detect_cmpxchg(void)
-{
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
- u32 curval;
-
- /*
- * This will fail and we want it. Some arch implementations do
- * runtime detection of the futex_atomic_cmpxchg_inatomic()
- * functionality. We want to know that before we call in any
- * of the complex code paths. Also we want to prevent
- * registration of robust lists in that case. NULL is
- * guaranteed to fault and we get -EFAULT on functional
- * implementation, the non-functional ones will return
- * -ENOSYS.
- */
- if (futex_cmpxchg_value_locked(&curval, NULL, 0, 0) == -EFAULT)
- futex_cmpxchg_enabled = 1;
-#endif
-}
-
static int __init futex_init(void)
{
unsigned int futex_shift;
@@ -1163,8 +1130,6 @@ static int __init futex_init(void)
futex_hashsize, futex_hashsize);
futex_hashsize = 1UL << futex_shift;
- futex_detect_cmpxchg();
-
for (i = 0; i < futex_hashsize; i++) {
atomic_set(&futex_queues[i].waiters, 0);
plist_head_init(&futex_queues[i].chain);
diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
index 040ae4277cb0..c264cbeab71c 100644
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -27,12 +27,6 @@
#define FLAGS_CLOCKRT 0x02
#define FLAGS_HAS_TIMEOUT 0x04
-#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
-#define futex_cmpxchg_enabled 1
-#else
-extern int __read_mostly futex_cmpxchg_enabled;
-#endif
-
#ifdef CONFIG_FAIL_FUTEX
extern bool should_fail_futex(bool fshared);
#else
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 6f91a07a6a83..086a22d1adb7 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -29,8 +29,6 @@
SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
/*
* The kernel knows only one size for now:
*/
@@ -56,9 +54,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
@@ -103,17 +98,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
return -ENOSYS;
}
- switch (cmd) {
- case FUTEX_LOCK_PI:
- case FUTEX_LOCK_PI2:
- case FUTEX_UNLOCK_PI:
- case FUTEX_TRYLOCK_PI:
- case FUTEX_WAIT_REQUEUE_PI:
- case FUTEX_CMP_REQUEUE_PI:
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
- }
-
switch (cmd) {
case FUTEX_WAIT:
val3 = FUTEX_BITSET_MATCH_ANY;
@@ -323,9 +307,6 @@ COMPAT_SYSCALL_DEFINE2(set_robust_list,
struct compat_robust_list_head __user *, head,
compat_size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
if (unlikely(len != sizeof(*head)))
return -EINVAL;
@@ -342,9 +323,6 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
--
2.29.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:03 ` Arnd Bergmann
0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2021-10-26 10:03 UTC (permalink / raw)
To: Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Vineet Gupta, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, Alexander Gordeev, Yoshinori Sato,
Rich Felker, Jeff Dike, Richard Weinberger, Anton Ivanov,
Chris Zankel, Max Filippov, Darren Hart, Davidlohr Bueso,
André Almeida, Andrew Morton, Mike Rapoport, Mark Rutland,
Anshuman Khandual, linux-snps-arc, linux-kernel,
linux-arm-kernel, linux-csky, linux-m68k, linux-riscv,
linux-s390, linux-sh, linux-um, linux-xtensa
From: Arnd Bergmann <arnd@arndb.de>
Now that all architectures have a working futex implementation
in any configuration, remove the runtime detection code.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arc/Kconfig | 1 -
arch/arm/Kconfig | 1 -
arch/arm64/Kconfig | 1 -
arch/csky/Kconfig | 1 -
arch/m68k/Kconfig | 1 -
arch/riscv/Kconfig | 1 -
arch/s390/Kconfig | 1 -
arch/sh/Kconfig | 1 -
arch/um/Kconfig | 1 -
arch/um/kernel/skas/uaccess.c | 1 -
arch/xtensa/Kconfig | 1 -
init/Kconfig | 8 --------
kernel/futex/core.c | 35 -----------------------------------
kernel/futex/futex.h | 6 ------
kernel/futex/syscalls.c | 22 ----------------------
15 files changed, 82 deletions(-)
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 248389278e8f..f9413041686f 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -31,7 +31,6 @@ config ARC
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
select HAVE_DEBUG_STACKOVERFLOW
select HAVE_DEBUG_KMEMLEAK
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_IOREMAP_PROT
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZMA
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index bb5d2c45477b..6448d311635d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -93,7 +93,6 @@ config ARM
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 0efc501f77aa..6c3c2ff5cef8 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -193,7 +193,6 @@ config ARM64
select HAVE_PERF_USER_STACK_DUMP
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_FUNCTION_ARG_ACCESS_API
- select HAVE_FUTEX_CMPXCHG if FUTEX
select MMU_GATHER_RCU_TABLE_FREE
select HAVE_RSEQ
select HAVE_STACKPROTECTOR
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 823d3d5a9e11..efd7c5feac8b 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -53,7 +53,6 @@ config CSKY
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 0b50da08a9c5..15a793c5b2dc 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -20,7 +20,6 @@ config M68K
select HAVE_ASM_MODVERSIONS
select HAVE_DEBUG_BUGVERBOSE
select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
- select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_UID16
select MMU_GATHER_NO_RANGE if MMU
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 77a088d0a7e9..037fea9fac14 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -84,7 +84,6 @@ config RISCV
select HAVE_DMA_CONTIGUOUS if MMU
select HAVE_EBPF_JIT if MMU
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO if MMU && 64BIT
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f615c3f65f5a..1c9ecf619e04 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -164,7 +164,6 @@ config S390
select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO
select HAVE_IOREMAP_PROT if PCI
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 6904f4bdbf00..93195d3368c0 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -34,7 +34,6 @@ config SUPERH
select HAVE_FAST_GUP if MMU
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_HW_BREAKPOINT
select HAVE_IOREMAP_PROT if MMU && !X2TLB
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index c18b45f75d41..c906250d4970 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -14,7 +14,6 @@ config UML
select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ASM_MODVERSIONS
select HAVE_UID16
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_DEBUG_KMEMLEAK
select HAVE_DEBUG_BUGVERBOSE
select NO_DMA if !UML_DMA_EMULATION
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index a509be911026..9e37a7c05990 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -348,7 +348,6 @@ EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
* 0 - On success
* -EFAULT - User access resulted in a page fault
* -EAGAIN - Atomic operation was unable to complete due to contention
- * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
*/
int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 0e56bad058fa..8ac599aa6d99 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -31,7 +31,6 @@ config XTENSA
select HAVE_DMA_CONTIGUOUS
select HAVE_EXIT_THREAD
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
select HAVE_HW_BREAKPOINT if PERF_EVENTS
select HAVE_IRQ_TIME_ACCOUNTING
select HAVE_PCI
diff --git a/init/Kconfig b/init/Kconfig
index c0f55ea5a71f..538688598f2f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1597,14 +1597,6 @@ config FUTEX_PI
depends on FUTEX && RT_MUTEXES
default y
-config HAVE_FUTEX_CMPXCHG
- bool
- depends on FUTEX
- help
- Architectures should select this if futex_atomic_cmpxchg_inatomic()
- is implemented and always working. This removes a couple of runtime
- checks.
-
config EPOLL
bool "Enable eventpoll support" if EXPERT
default y
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 25d8a88b32e5..926c2bb752bc 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -41,11 +41,6 @@
#include "futex.h"
#include "../locking/rtmutex_common.h"
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
-int __read_mostly futex_cmpxchg_enabled;
-#endif
-
-
/*
* The base of the bucket array and its size are always used together
* (after initialization only in futex_hash()), so ensure that they
@@ -776,9 +771,6 @@ static void exit_robust_list(struct task_struct *curr)
unsigned long futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -874,9 +866,6 @@ static void compat_exit_robust_list(struct task_struct *curr)
compat_long_t futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -950,8 +939,6 @@ static void exit_pi_state_list(struct task_struct *curr)
struct futex_hash_bucket *hb;
union futex_key key = FUTEX_KEY_INIT;
- if (!futex_cmpxchg_enabled)
- return;
/*
* We are a ZOMBIE and nobody can enqueue itself on
* pi_state_list anymore, but we have to be careful
@@ -1125,26 +1112,6 @@ void futex_exit_release(struct task_struct *tsk)
futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
}
-static void __init futex_detect_cmpxchg(void)
-{
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
- u32 curval;
-
- /*
- * This will fail and we want it. Some arch implementations do
- * runtime detection of the futex_atomic_cmpxchg_inatomic()
- * functionality. We want to know that before we call in any
- * of the complex code paths. Also we want to prevent
- * registration of robust lists in that case. NULL is
- * guaranteed to fault and we get -EFAULT on functional
- * implementation, the non-functional ones will return
- * -ENOSYS.
- */
- if (futex_cmpxchg_value_locked(&curval, NULL, 0, 0) == -EFAULT)
- futex_cmpxchg_enabled = 1;
-#endif
-}
-
static int __init futex_init(void)
{
unsigned int futex_shift;
@@ -1163,8 +1130,6 @@ static int __init futex_init(void)
futex_hashsize, futex_hashsize);
futex_hashsize = 1UL << futex_shift;
- futex_detect_cmpxchg();
-
for (i = 0; i < futex_hashsize; i++) {
atomic_set(&futex_queues[i].waiters, 0);
plist_head_init(&futex_queues[i].chain);
diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
index 040ae4277cb0..c264cbeab71c 100644
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -27,12 +27,6 @@
#define FLAGS_CLOCKRT 0x02
#define FLAGS_HAS_TIMEOUT 0x04
-#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
-#define futex_cmpxchg_enabled 1
-#else
-extern int __read_mostly futex_cmpxchg_enabled;
-#endif
-
#ifdef CONFIG_FAIL_FUTEX
extern bool should_fail_futex(bool fshared);
#else
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 6f91a07a6a83..086a22d1adb7 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -29,8 +29,6 @@
SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
/*
* The kernel knows only one size for now:
*/
@@ -56,9 +54,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
@@ -103,17 +98,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
return -ENOSYS;
}
- switch (cmd) {
- case FUTEX_LOCK_PI:
- case FUTEX_LOCK_PI2:
- case FUTEX_UNLOCK_PI:
- case FUTEX_TRYLOCK_PI:
- case FUTEX_WAIT_REQUEUE_PI:
- case FUTEX_CMP_REQUEUE_PI:
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
- }
-
switch (cmd) {
case FUTEX_WAIT:
val3 = FUTEX_BITSET_MATCH_ANY;
@@ -323,9 +307,6 @@ COMPAT_SYSCALL_DEFINE2(set_robust_list,
struct compat_robust_list_head __user *, head,
compat_size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
if (unlikely(len != sizeof(*head)))
return -EINVAL;
@@ -342,9 +323,6 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
--
2.29.2
_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:03 ` Arnd Bergmann
0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2021-10-26 10:03 UTC (permalink / raw)
To: Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Vineet Gupta, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, Alexander Gordeev, Yoshinori Sato,
Rich Felker, Jeff Dike, Richard Weinberger, Anton Ivanov,
Chris Zankel, Max Filippov, Darren Hart, Davidlohr Bueso,
André Almeida, Andrew Morton, Mike Rapoport, Mark Rutland,
Anshuman Khandual, linux-snps-arc, linux-kernel,
linux-arm-kernel, linux-csky, linux-m68k, linux-riscv,
linux-s390, linux-sh, linux-um, linux-xtensa
From: Arnd Bergmann <arnd@arndb.de>
Now that all architectures have a working futex implementation
in any configuration, remove the runtime detection code.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arc/Kconfig | 1 -
arch/arm/Kconfig | 1 -
arch/arm64/Kconfig | 1 -
arch/csky/Kconfig | 1 -
arch/m68k/Kconfig | 1 -
arch/riscv/Kconfig | 1 -
arch/s390/Kconfig | 1 -
arch/sh/Kconfig | 1 -
arch/um/Kconfig | 1 -
arch/um/kernel/skas/uaccess.c | 1 -
arch/xtensa/Kconfig | 1 -
init/Kconfig | 8 --------
kernel/futex/core.c | 35 -----------------------------------
kernel/futex/futex.h | 6 ------
kernel/futex/syscalls.c | 22 ----------------------
15 files changed, 82 deletions(-)
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 248389278e8f..f9413041686f 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -31,7 +31,6 @@ config ARC
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
select HAVE_DEBUG_STACKOVERFLOW
select HAVE_DEBUG_KMEMLEAK
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_IOREMAP_PROT
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZMA
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index bb5d2c45477b..6448d311635d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -93,7 +93,6 @@ config ARM
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 0efc501f77aa..6c3c2ff5cef8 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -193,7 +193,6 @@ config ARM64
select HAVE_PERF_USER_STACK_DUMP
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_FUNCTION_ARG_ACCESS_API
- select HAVE_FUTEX_CMPXCHG if FUTEX
select MMU_GATHER_RCU_TABLE_FREE
select HAVE_RSEQ
select HAVE_STACKPROTECTOR
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 823d3d5a9e11..efd7c5feac8b 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -53,7 +53,6 @@ config CSKY
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 0b50da08a9c5..15a793c5b2dc 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -20,7 +20,6 @@ config M68K
select HAVE_ASM_MODVERSIONS
select HAVE_DEBUG_BUGVERBOSE
select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
- select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_UID16
select MMU_GATHER_NO_RANGE if MMU
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 77a088d0a7e9..037fea9fac14 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -84,7 +84,6 @@ config RISCV
select HAVE_DMA_CONTIGUOUS if MMU
select HAVE_EBPF_JIT if MMU
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO if MMU && 64BIT
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f615c3f65f5a..1c9ecf619e04 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -164,7 +164,6 @@ config S390
select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO
select HAVE_IOREMAP_PROT if PCI
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 6904f4bdbf00..93195d3368c0 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -34,7 +34,6 @@ config SUPERH
select HAVE_FAST_GUP if MMU
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_HW_BREAKPOINT
select HAVE_IOREMAP_PROT if MMU && !X2TLB
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index c18b45f75d41..c906250d4970 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -14,7 +14,6 @@ config UML
select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ASM_MODVERSIONS
select HAVE_UID16
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_DEBUG_KMEMLEAK
select HAVE_DEBUG_BUGVERBOSE
select NO_DMA if !UML_DMA_EMULATION
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index a509be911026..9e37a7c05990 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -348,7 +348,6 @@ EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
* 0 - On success
* -EFAULT - User access resulted in a page fault
* -EAGAIN - Atomic operation was unable to complete due to contention
- * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
*/
int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 0e56bad058fa..8ac599aa6d99 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -31,7 +31,6 @@ config XTENSA
select HAVE_DMA_CONTIGUOUS
select HAVE_EXIT_THREAD
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
select HAVE_HW_BREAKPOINT if PERF_EVENTS
select HAVE_IRQ_TIME_ACCOUNTING
select HAVE_PCI
diff --git a/init/Kconfig b/init/Kconfig
index c0f55ea5a71f..538688598f2f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1597,14 +1597,6 @@ config FUTEX_PI
depends on FUTEX && RT_MUTEXES
default y
-config HAVE_FUTEX_CMPXCHG
- bool
- depends on FUTEX
- help
- Architectures should select this if futex_atomic_cmpxchg_inatomic()
- is implemented and always working. This removes a couple of runtime
- checks.
-
config EPOLL
bool "Enable eventpoll support" if EXPERT
default y
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 25d8a88b32e5..926c2bb752bc 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -41,11 +41,6 @@
#include "futex.h"
#include "../locking/rtmutex_common.h"
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
-int __read_mostly futex_cmpxchg_enabled;
-#endif
-
-
/*
* The base of the bucket array and its size are always used together
* (after initialization only in futex_hash()), so ensure that they
@@ -776,9 +771,6 @@ static void exit_robust_list(struct task_struct *curr)
unsigned long futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -874,9 +866,6 @@ static void compat_exit_robust_list(struct task_struct *curr)
compat_long_t futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -950,8 +939,6 @@ static void exit_pi_state_list(struct task_struct *curr)
struct futex_hash_bucket *hb;
union futex_key key = FUTEX_KEY_INIT;
- if (!futex_cmpxchg_enabled)
- return;
/*
* We are a ZOMBIE and nobody can enqueue itself on
* pi_state_list anymore, but we have to be careful
@@ -1125,26 +1112,6 @@ void futex_exit_release(struct task_struct *tsk)
futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
}
-static void __init futex_detect_cmpxchg(void)
-{
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
- u32 curval;
-
- /*
- * This will fail and we want it. Some arch implementations do
- * runtime detection of the futex_atomic_cmpxchg_inatomic()
- * functionality. We want to know that before we call in any
- * of the complex code paths. Also we want to prevent
- * registration of robust lists in that case. NULL is
- * guaranteed to fault and we get -EFAULT on functional
- * implementation, the non-functional ones will return
- * -ENOSYS.
- */
- if (futex_cmpxchg_value_locked(&curval, NULL, 0, 0) == -EFAULT)
- futex_cmpxchg_enabled = 1;
-#endif
-}
-
static int __init futex_init(void)
{
unsigned int futex_shift;
@@ -1163,8 +1130,6 @@ static int __init futex_init(void)
futex_hashsize, futex_hashsize);
futex_hashsize = 1UL << futex_shift;
- futex_detect_cmpxchg();
-
for (i = 0; i < futex_hashsize; i++) {
atomic_set(&futex_queues[i].waiters, 0);
plist_head_init(&futex_queues[i].chain);
diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
index 040ae4277cb0..c264cbeab71c 100644
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -27,12 +27,6 @@
#define FLAGS_CLOCKRT 0x02
#define FLAGS_HAS_TIMEOUT 0x04
-#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
-#define futex_cmpxchg_enabled 1
-#else
-extern int __read_mostly futex_cmpxchg_enabled;
-#endif
-
#ifdef CONFIG_FAIL_FUTEX
extern bool should_fail_futex(bool fshared);
#else
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 6f91a07a6a83..086a22d1adb7 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -29,8 +29,6 @@
SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
/*
* The kernel knows only one size for now:
*/
@@ -56,9 +54,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
@@ -103,17 +98,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
return -ENOSYS;
}
- switch (cmd) {
- case FUTEX_LOCK_PI:
- case FUTEX_LOCK_PI2:
- case FUTEX_UNLOCK_PI:
- case FUTEX_TRYLOCK_PI:
- case FUTEX_WAIT_REQUEUE_PI:
- case FUTEX_CMP_REQUEUE_PI:
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
- }
-
switch (cmd) {
case FUTEX_WAIT:
val3 = FUTEX_BITSET_MATCH_ANY;
@@ -323,9 +307,6 @@ COMPAT_SYSCALL_DEFINE2(set_robust_list,
struct compat_robust_list_head __user *, head,
compat_size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
if (unlikely(len != sizeof(*head)))
return -EINVAL;
@@ -342,9 +323,6 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
--
2.29.2
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:03 ` Arnd Bergmann
0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2021-10-26 10:03 UTC (permalink / raw)
To: Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Vineet Gupta, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, Alexander Gordeev, Yoshinori Sato,
Rich Felker, Jeff Dike, Richard Weinberger, Anton Ivanov,
Chris Zankel, Max Filippov, Darren Hart, Davidlohr Bueso,
André Almeida, Andrew Morton, Mike Rapoport, Mark Rutland,
Anshuman Khandual, linux-snps-arc, linux-kernel,
linux-arm-kernel, linux-csky, linux-m68k, linux-riscv,
linux-s390, linux-sh, linux-um, linux-xtensa
From: Arnd Bergmann <arnd@arndb.de>
Now that all architectures have a working futex implementation
in any configuration, remove the runtime detection code.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arc/Kconfig | 1 -
arch/arm/Kconfig | 1 -
arch/arm64/Kconfig | 1 -
arch/csky/Kconfig | 1 -
arch/m68k/Kconfig | 1 -
arch/riscv/Kconfig | 1 -
arch/s390/Kconfig | 1 -
arch/sh/Kconfig | 1 -
arch/um/Kconfig | 1 -
arch/um/kernel/skas/uaccess.c | 1 -
arch/xtensa/Kconfig | 1 -
init/Kconfig | 8 --------
kernel/futex/core.c | 35 -----------------------------------
kernel/futex/futex.h | 6 ------
kernel/futex/syscalls.c | 22 ----------------------
15 files changed, 82 deletions(-)
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 248389278e8f..f9413041686f 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -31,7 +31,6 @@ config ARC
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
select HAVE_DEBUG_STACKOVERFLOW
select HAVE_DEBUG_KMEMLEAK
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_IOREMAP_PROT
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZMA
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index bb5d2c45477b..6448d311635d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -93,7 +93,6 @@ config ARM
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 0efc501f77aa..6c3c2ff5cef8 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -193,7 +193,6 @@ config ARM64
select HAVE_PERF_USER_STACK_DUMP
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_FUNCTION_ARG_ACCESS_API
- select HAVE_FUTEX_CMPXCHG if FUTEX
select MMU_GATHER_RCU_TABLE_FREE
select HAVE_RSEQ
select HAVE_STACKPROTECTOR
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 823d3d5a9e11..efd7c5feac8b 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -53,7 +53,6 @@ config CSKY
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 0b50da08a9c5..15a793c5b2dc 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -20,7 +20,6 @@ config M68K
select HAVE_ASM_MODVERSIONS
select HAVE_DEBUG_BUGVERBOSE
select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
- select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_UID16
select MMU_GATHER_NO_RANGE if MMU
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 77a088d0a7e9..037fea9fac14 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -84,7 +84,6 @@ config RISCV
select HAVE_DMA_CONTIGUOUS if MMU
select HAVE_EBPF_JIT if MMU
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO if MMU && 64BIT
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f615c3f65f5a..1c9ecf619e04 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -164,7 +164,6 @@ config S390
select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO
select HAVE_IOREMAP_PROT if PCI
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 6904f4bdbf00..93195d3368c0 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -34,7 +34,6 @@ config SUPERH
select HAVE_FAST_GUP if MMU
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_HW_BREAKPOINT
select HAVE_IOREMAP_PROT if MMU && !X2TLB
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index c18b45f75d41..c906250d4970 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -14,7 +14,6 @@ config UML
select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ASM_MODVERSIONS
select HAVE_UID16
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_DEBUG_KMEMLEAK
select HAVE_DEBUG_BUGVERBOSE
select NO_DMA if !UML_DMA_EMULATION
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index a509be911026..9e37a7c05990 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -348,7 +348,6 @@ EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
* 0 - On success
* -EFAULT - User access resulted in a page fault
* -EAGAIN - Atomic operation was unable to complete due to contention
- * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
*/
int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 0e56bad058fa..8ac599aa6d99 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -31,7 +31,6 @@ config XTENSA
select HAVE_DMA_CONTIGUOUS
select HAVE_EXIT_THREAD
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
select HAVE_HW_BREAKPOINT if PERF_EVENTS
select HAVE_IRQ_TIME_ACCOUNTING
select HAVE_PCI
diff --git a/init/Kconfig b/init/Kconfig
index c0f55ea5a71f..538688598f2f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1597,14 +1597,6 @@ config FUTEX_PI
depends on FUTEX && RT_MUTEXES
default y
-config HAVE_FUTEX_CMPXCHG
- bool
- depends on FUTEX
- help
- Architectures should select this if futex_atomic_cmpxchg_inatomic()
- is implemented and always working. This removes a couple of runtime
- checks.
-
config EPOLL
bool "Enable eventpoll support" if EXPERT
default y
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 25d8a88b32e5..926c2bb752bc 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -41,11 +41,6 @@
#include "futex.h"
#include "../locking/rtmutex_common.h"
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
-int __read_mostly futex_cmpxchg_enabled;
-#endif
-
-
/*
* The base of the bucket array and its size are always used together
* (after initialization only in futex_hash()), so ensure that they
@@ -776,9 +771,6 @@ static void exit_robust_list(struct task_struct *curr)
unsigned long futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -874,9 +866,6 @@ static void compat_exit_robust_list(struct task_struct *curr)
compat_long_t futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -950,8 +939,6 @@ static void exit_pi_state_list(struct task_struct *curr)
struct futex_hash_bucket *hb;
union futex_key key = FUTEX_KEY_INIT;
- if (!futex_cmpxchg_enabled)
- return;
/*
* We are a ZOMBIE and nobody can enqueue itself on
* pi_state_list anymore, but we have to be careful
@@ -1125,26 +1112,6 @@ void futex_exit_release(struct task_struct *tsk)
futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
}
-static void __init futex_detect_cmpxchg(void)
-{
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
- u32 curval;
-
- /*
- * This will fail and we want it. Some arch implementations do
- * runtime detection of the futex_atomic_cmpxchg_inatomic()
- * functionality. We want to know that before we call in any
- * of the complex code paths. Also we want to prevent
- * registration of robust lists in that case. NULL is
- * guaranteed to fault and we get -EFAULT on functional
- * implementation, the non-functional ones will return
- * -ENOSYS.
- */
- if (futex_cmpxchg_value_locked(&curval, NULL, 0, 0) == -EFAULT)
- futex_cmpxchg_enabled = 1;
-#endif
-}
-
static int __init futex_init(void)
{
unsigned int futex_shift;
@@ -1163,8 +1130,6 @@ static int __init futex_init(void)
futex_hashsize, futex_hashsize);
futex_hashsize = 1UL << futex_shift;
- futex_detect_cmpxchg();
-
for (i = 0; i < futex_hashsize; i++) {
atomic_set(&futex_queues[i].waiters, 0);
plist_head_init(&futex_queues[i].chain);
diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
index 040ae4277cb0..c264cbeab71c 100644
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -27,12 +27,6 @@
#define FLAGS_CLOCKRT 0x02
#define FLAGS_HAS_TIMEOUT 0x04
-#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
-#define futex_cmpxchg_enabled 1
-#else
-extern int __read_mostly futex_cmpxchg_enabled;
-#endif
-
#ifdef CONFIG_FAIL_FUTEX
extern bool should_fail_futex(bool fshared);
#else
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 6f91a07a6a83..086a22d1adb7 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -29,8 +29,6 @@
SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
/*
* The kernel knows only one size for now:
*/
@@ -56,9 +54,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
@@ -103,17 +98,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
return -ENOSYS;
}
- switch (cmd) {
- case FUTEX_LOCK_PI:
- case FUTEX_LOCK_PI2:
- case FUTEX_UNLOCK_PI:
- case FUTEX_TRYLOCK_PI:
- case FUTEX_WAIT_REQUEUE_PI:
- case FUTEX_CMP_REQUEUE_PI:
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
- }
-
switch (cmd) {
case FUTEX_WAIT:
val3 = FUTEX_BITSET_MATCH_ANY;
@@ -323,9 +307,6 @@ COMPAT_SYSCALL_DEFINE2(set_robust_list,
struct compat_robust_list_head __user *, head,
compat_size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
if (unlikely(len != sizeof(*head)))
return -EINVAL;
@@ -342,9 +323,6 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
--
2.29.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
2021-10-26 10:03 ` Arnd Bergmann
(?)
(?)
@ 2021-10-26 10:16 ` Geert Uytterhoeven
-1 siblings, 0 replies; 29+ messages in thread
From: Geert Uytterhoeven @ 2021-10-26 10:16 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, arcml,
Linux Kernel Mailing List, Linux ARM, linux-csky, linux-m68k,
linux-riscv, linux-s390, Linux-sh list, linux-um,
open list:TENSILICA XTENSA PORT (xtensa)
On Tue, Oct 26, 2021 at 12:06 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> arch/m68k/Kconfig | 1 -
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:16 ` Geert Uytterhoeven
0 siblings, 0 replies; 29+ messages in thread
From: Geert Uytterhoeven @ 2021-10-26 10:16 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, arcml,
Linux Kernel Mailing List, Linux ARM, linux-csky, linux-m68k,
linux-riscv, linux-s390, Linux-sh list, linux-um,
open list:TENSILICA XTENSA PORT (xtensa)
On Tue, Oct 26, 2021 at 12:06 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> arch/m68k/Kconfig | 1 -
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:16 ` Geert Uytterhoeven
0 siblings, 0 replies; 29+ messages in thread
From: Geert Uytterhoeven @ 2021-10-26 10:16 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, arcml,
Linux Kernel Mailing List, Linux ARM, linux-csky, linux-m68k,
linux-riscv, linux-s390, Linux-sh list, linux-um,
open list:TENSILICA XTENSA PORT (xtensa)
On Tue, Oct 26, 2021 at 12:06 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> arch/m68k/Kconfig | 1 -
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:16 ` Geert Uytterhoeven
0 siblings, 0 replies; 29+ messages in thread
From: Geert Uytterhoeven @ 2021-10-26 10:16 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, arcml,
Linux Kernel Mailing List, Linux ARM, linux-csky, linux-m68k,
linux-riscv, linux-s390, Linux-sh list, linux-um,
open list:TENSILICA XTENSA PORT (xtensa)
On Tue, Oct 26, 2021 at 12:06 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> arch/m68k/Kconfig | 1 -
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
2021-10-26 10:03 ` Arnd Bergmann
(?)
(?)
@ 2021-10-26 10:38 ` Russell King (Oracle)
-1 siblings, 0 replies; 29+ messages in thread
From: Russell King (Oracle) @ 2021-10-26 10:38 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Catalin Marinas, Will Deacon, Guo Ren,
Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
On Tue, Oct 26, 2021 at 12:03:48PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
For ARM:
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
As Arnd explained to me what was going on, I'll include it here...
This patch requires patch 1 which touches other architectures, so
it is not an independent patch.
Patch 1 can be found at:
https://lore.kernel.org/lkml/20211026100432.1730393-1-arnd@kernel.org/T/#t
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:38 ` Russell King (Oracle)
0 siblings, 0 replies; 29+ messages in thread
From: Russell King (Oracle) @ 2021-10-26 10:38 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Catalin Marinas, Will Deacon, Guo Ren,
Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
On Tue, Oct 26, 2021 at 12:03:48PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
For ARM:
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
As Arnd explained to me what was going on, I'll include it here...
This patch requires patch 1 which touches other architectures, so
it is not an independent patch.
Patch 1 can be found at:
https://lore.kernel.org/lkml/20211026100432.1730393-1-arnd@kernel.org/T/#t
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:38 ` Russell King (Oracle)
0 siblings, 0 replies; 29+ messages in thread
From: Russell King (Oracle) @ 2021-10-26 10:38 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Catalin Marinas, Will Deacon, Guo Ren,
Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
On Tue, Oct 26, 2021 at 12:03:48PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
For ARM:
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
As Arnd explained to me what was going on, I'll include it here...
This patch requires patch 1 which touches other architectures, so
it is not an independent patch.
Patch 1 can be found at:
https://lore.kernel.org/lkml/20211026100432.1730393-1-arnd@kernel.org/T/#t
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:38 ` Russell King (Oracle)
0 siblings, 0 replies; 29+ messages in thread
From: Russell King (Oracle) @ 2021-10-26 10:38 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Catalin Marinas, Will Deacon, Guo Ren,
Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
On Tue, Oct 26, 2021 at 12:03:48PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
For ARM:
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
As Arnd explained to me what was going on, I'll include it here...
This patch requires patch 1 which touches other architectures, so
it is not an independent patch.
Patch 1 can be found at:
https://lore.kernel.org/lkml/20211026100432.1730393-1-arnd@kernel.org/T/#t
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
2021-10-26 10:03 ` Arnd Bergmann
(?)
(?)
@ 2021-10-26 10:43 ` Christian Borntraeger
-1 siblings, 0 replies; 29+ messages in thread
From: Christian Borntraeger @ 2021-10-26 10:43 UTC (permalink / raw)
To: Arnd Bergmann, Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Vineet Gupta, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
Am 26.10.21 um 12:03 schrieb Arnd Bergmann:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
s390 part
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
>
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 248389278e8f..f9413041686f 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -31,7 +31,6 @@ config ARC
> select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
> select HAVE_DEBUG_STACKOVERFLOW
> select HAVE_DEBUG_KMEMLEAK
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_IOREMAP_PROT
> select HAVE_KERNEL_GZIP
> select HAVE_KERNEL_LZMA
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index bb5d2c45477b..6448d311635d 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -93,7 +93,6 @@ config ARM
> select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
> select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
> select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
> select HAVE_IRQ_TIME_ACCOUNTING
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 0efc501f77aa..6c3c2ff5cef8 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -193,7 +193,6 @@ config ARM64
> select HAVE_PERF_USER_STACK_DUMP
> select HAVE_REGS_AND_STACK_ACCESS_API
> select HAVE_FUNCTION_ARG_ACCESS_API
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select MMU_GATHER_RCU_TABLE_FREE
> select HAVE_RSEQ
> select HAVE_STACKPROTECTOR
> diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
> index 823d3d5a9e11..efd7c5feac8b 100644
> --- a/arch/csky/Kconfig
> +++ b/arch/csky/Kconfig
> @@ -53,7 +53,6 @@ config CSKY
> select HAVE_FUNCTION_TRACER
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_ERROR_INJECTION
> - select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
> select HAVE_FTRACE_MCOUNT_RECORD
> select HAVE_KERNEL_GZIP
> select HAVE_KERNEL_LZO
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index 0b50da08a9c5..15a793c5b2dc 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -20,7 +20,6 @@ config M68K
> select HAVE_ASM_MODVERSIONS
> select HAVE_DEBUG_BUGVERBOSE
> select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
> - select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
> select HAVE_MOD_ARCH_SPECIFIC
> select HAVE_UID16
> select MMU_GATHER_NO_RANGE if MMU
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 77a088d0a7e9..037fea9fac14 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -84,7 +84,6 @@ config RISCV
> select HAVE_DMA_CONTIGUOUS if MMU
> select HAVE_EBPF_JIT if MMU
> select HAVE_FUNCTION_ERROR_INJECTION
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_GENERIC_VDSO if MMU && 64BIT
> select HAVE_IRQ_TIME_ACCOUNTING
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index f615c3f65f5a..1c9ecf619e04 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -164,7 +164,6 @@ config S390
> select HAVE_FUNCTION_ERROR_INJECTION
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_GENERIC_VDSO
> select HAVE_IOREMAP_PROT if PCI
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 6904f4bdbf00..93195d3368c0 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -34,7 +34,6 @@ config SUPERH
> select HAVE_FAST_GUP if MMU
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_FTRACE_MCOUNT_RECORD
> select HAVE_HW_BREAKPOINT
> select HAVE_IOREMAP_PROT if MMU && !X2TLB
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index c18b45f75d41..c906250d4970 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -14,7 +14,6 @@ config UML
> select HAVE_ARCH_SECCOMP_FILTER
> select HAVE_ASM_MODVERSIONS
> select HAVE_UID16
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_DEBUG_KMEMLEAK
> select HAVE_DEBUG_BUGVERBOSE
> select NO_DMA if !UML_DMA_EMULATION
> diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
> index a509be911026..9e37a7c05990 100644
> --- a/arch/um/kernel/skas/uaccess.c
> +++ b/arch/um/kernel/skas/uaccess.c
> @@ -348,7 +348,6 @@ EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
> * 0 - On success
> * -EFAULT - User access resulted in a page fault
> * -EAGAIN - Atomic operation was unable to complete due to contention
> - * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
> */
>
> int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
> diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
> index 0e56bad058fa..8ac599aa6d99 100644
> --- a/arch/xtensa/Kconfig
> +++ b/arch/xtensa/Kconfig
> @@ -31,7 +31,6 @@ config XTENSA
> select HAVE_DMA_CONTIGUOUS
> select HAVE_EXIT_THREAD
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
> select HAVE_HW_BREAKPOINT if PERF_EVENTS
> select HAVE_IRQ_TIME_ACCOUNTING
> select HAVE_PCI
> diff --git a/init/Kconfig b/init/Kconfig
> index c0f55ea5a71f..538688598f2f 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1597,14 +1597,6 @@ config FUTEX_PI
> depends on FUTEX && RT_MUTEXES
> default y
>
> -config HAVE_FUTEX_CMPXCHG
> - bool
> - depends on FUTEX
> - help
> - Architectures should select this if futex_atomic_cmpxchg_inatomic()
> - is implemented and always working. This removes a couple of runtime
> - checks.
> -
> config EPOLL
> bool "Enable eventpoll support" if EXPERT
> default y
> diff --git a/kernel/futex/core.c b/kernel/futex/core.c
> index 25d8a88b32e5..926c2bb752bc 100644
> --- a/kernel/futex/core.c
> +++ b/kernel/futex/core.c
> @@ -41,11 +41,6 @@
> #include "futex.h"
> #include "../locking/rtmutex_common.h"
>
> -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
> -int __read_mostly futex_cmpxchg_enabled;
> -#endif
> -
> -
> /*
> * The base of the bucket array and its size are always used together
> * (after initialization only in futex_hash()), so ensure that they
> @@ -776,9 +771,6 @@ static void exit_robust_list(struct task_struct *curr)
> unsigned long futex_offset;
> int rc;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> -
> /*
> * Fetch the list head (which was registered earlier, via
> * sys_set_robust_list()):
> @@ -874,9 +866,6 @@ static void compat_exit_robust_list(struct task_struct *curr)
> compat_long_t futex_offset;
> int rc;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> -
> /*
> * Fetch the list head (which was registered earlier, via
> * sys_set_robust_list()):
> @@ -950,8 +939,6 @@ static void exit_pi_state_list(struct task_struct *curr)
> struct futex_hash_bucket *hb;
> union futex_key key = FUTEX_KEY_INIT;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> /*
> * We are a ZOMBIE and nobody can enqueue itself on
> * pi_state_list anymore, but we have to be careful
> @@ -1125,26 +1112,6 @@ void futex_exit_release(struct task_struct *tsk)
> futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
> }
>
> -static void __init futex_detect_cmpxchg(void)
> -{
> -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
> - u32 curval;
> -
> - /*
> - * This will fail and we want it. Some arch implementations do
> - * runtime detection of the futex_atomic_cmpxchg_inatomic()
> - * functionality. We want to know that before we call in any
> - * of the complex code paths. Also we want to prevent
> - * registration of robust lists in that case. NULL is
> - * guaranteed to fault and we get -EFAULT on functional
> - * implementation, the non-functional ones will return
> - * -ENOSYS.
> - */
> - if (futex_cmpxchg_value_locked(&curval, NULL, 0, 0) == -EFAULT)
> - futex_cmpxchg_enabled = 1;
> -#endif
> -}
> -
> static int __init futex_init(void)
> {
> unsigned int futex_shift;
> @@ -1163,8 +1130,6 @@ static int __init futex_init(void)
> futex_hashsize, futex_hashsize);
> futex_hashsize = 1UL << futex_shift;
>
> - futex_detect_cmpxchg();
> -
> for (i = 0; i < futex_hashsize; i++) {
> atomic_set(&futex_queues[i].waiters, 0);
> plist_head_init(&futex_queues[i].chain);
> diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
> index 040ae4277cb0..c264cbeab71c 100644
> --- a/kernel/futex/futex.h
> +++ b/kernel/futex/futex.h
> @@ -27,12 +27,6 @@
> #define FLAGS_CLOCKRT 0x02
> #define FLAGS_HAS_TIMEOUT 0x04
>
> -#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
> -#define futex_cmpxchg_enabled 1
> -#else
> -extern int __read_mostly futex_cmpxchg_enabled;
> -#endif
> -
> #ifdef CONFIG_FAIL_FUTEX
> extern bool should_fail_futex(bool fshared);
> #else
> diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
> index 6f91a07a6a83..086a22d1adb7 100644
> --- a/kernel/futex/syscalls.c
> +++ b/kernel/futex/syscalls.c
> @@ -29,8 +29,6 @@
> SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
> size_t, len)
> {
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> /*
> * The kernel knows only one size for now:
> */
> @@ -56,9 +54,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
> unsigned long ret;
> struct task_struct *p;
>
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> rcu_read_lock();
>
> ret = -ESRCH;
> @@ -103,17 +98,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
> return -ENOSYS;
> }
>
> - switch (cmd) {
> - case FUTEX_LOCK_PI:
> - case FUTEX_LOCK_PI2:
> - case FUTEX_UNLOCK_PI:
> - case FUTEX_TRYLOCK_PI:
> - case FUTEX_WAIT_REQUEUE_PI:
> - case FUTEX_CMP_REQUEUE_PI:
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> - }
> -
> switch (cmd) {
> case FUTEX_WAIT:
> val3 = FUTEX_BITSET_MATCH_ANY;
> @@ -323,9 +307,6 @@ COMPAT_SYSCALL_DEFINE2(set_robust_list,
> struct compat_robust_list_head __user *, head,
> compat_size_t, len)
> {
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> if (unlikely(len != sizeof(*head)))
> return -EINVAL;
>
> @@ -342,9 +323,6 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
> unsigned long ret;
> struct task_struct *p;
>
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> rcu_read_lock();
>
> ret = -ESRCH;
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:43 ` Christian Borntraeger
0 siblings, 0 replies; 29+ messages in thread
From: Christian Borntraeger @ 2021-10-26 10:43 UTC (permalink / raw)
To: Arnd Bergmann, Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Vineet Gupta, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
Am 26.10.21 um 12:03 schrieb Arnd Bergmann:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
s390 part
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
>
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 248389278e8f..f9413041686f 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -31,7 +31,6 @@ config ARC
> select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
> select HAVE_DEBUG_STACKOVERFLOW
> select HAVE_DEBUG_KMEMLEAK
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_IOREMAP_PROT
> select HAVE_KERNEL_GZIP
> select HAVE_KERNEL_LZMA
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index bb5d2c45477b..6448d311635d 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -93,7 +93,6 @@ config ARM
> select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
> select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
> select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
> select HAVE_IRQ_TIME_ACCOUNTING
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 0efc501f77aa..6c3c2ff5cef8 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -193,7 +193,6 @@ config ARM64
> select HAVE_PERF_USER_STACK_DUMP
> select HAVE_REGS_AND_STACK_ACCESS_API
> select HAVE_FUNCTION_ARG_ACCESS_API
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select MMU_GATHER_RCU_TABLE_FREE
> select HAVE_RSEQ
> select HAVE_STACKPROTECTOR
> diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
> index 823d3d5a9e11..efd7c5feac8b 100644
> --- a/arch/csky/Kconfig
> +++ b/arch/csky/Kconfig
> @@ -53,7 +53,6 @@ config CSKY
> select HAVE_FUNCTION_TRACER
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_ERROR_INJECTION
> - select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
> select HAVE_FTRACE_MCOUNT_RECORD
> select HAVE_KERNEL_GZIP
> select HAVE_KERNEL_LZO
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index 0b50da08a9c5..15a793c5b2dc 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -20,7 +20,6 @@ config M68K
> select HAVE_ASM_MODVERSIONS
> select HAVE_DEBUG_BUGVERBOSE
> select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
> - select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
> select HAVE_MOD_ARCH_SPECIFIC
> select HAVE_UID16
> select MMU_GATHER_NO_RANGE if MMU
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 77a088d0a7e9..037fea9fac14 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -84,7 +84,6 @@ config RISCV
> select HAVE_DMA_CONTIGUOUS if MMU
> select HAVE_EBPF_JIT if MMU
> select HAVE_FUNCTION_ERROR_INJECTION
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_GENERIC_VDSO if MMU && 64BIT
> select HAVE_IRQ_TIME_ACCOUNTING
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index f615c3f65f5a..1c9ecf619e04 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -164,7 +164,6 @@ config S390
> select HAVE_FUNCTION_ERROR_INJECTION
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_GENERIC_VDSO
> select HAVE_IOREMAP_PROT if PCI
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 6904f4bdbf00..93195d3368c0 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -34,7 +34,6 @@ config SUPERH
> select HAVE_FAST_GUP if MMU
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_FTRACE_MCOUNT_RECORD
> select HAVE_HW_BREAKPOINT
> select HAVE_IOREMAP_PROT if MMU && !X2TLB
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index c18b45f75d41..c906250d4970 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -14,7 +14,6 @@ config UML
> select HAVE_ARCH_SECCOMP_FILTER
> select HAVE_ASM_MODVERSIONS
> select HAVE_UID16
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_DEBUG_KMEMLEAK
> select HAVE_DEBUG_BUGVERBOSE
> select NO_DMA if !UML_DMA_EMULATION
> diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
> index a509be911026..9e37a7c05990 100644
> --- a/arch/um/kernel/skas/uaccess.c
> +++ b/arch/um/kernel/skas/uaccess.c
> @@ -348,7 +348,6 @@ EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
> * 0 - On success
> * -EFAULT - User access resulted in a page fault
> * -EAGAIN - Atomic operation was unable to complete due to contention
> - * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
> */
>
> int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
> diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
> index 0e56bad058fa..8ac599aa6d99 100644
> --- a/arch/xtensa/Kconfig
> +++ b/arch/xtensa/Kconfig
> @@ -31,7 +31,6 @@ config XTENSA
> select HAVE_DMA_CONTIGUOUS
> select HAVE_EXIT_THREAD
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
> select HAVE_HW_BREAKPOINT if PERF_EVENTS
> select HAVE_IRQ_TIME_ACCOUNTING
> select HAVE_PCI
> diff --git a/init/Kconfig b/init/Kconfig
> index c0f55ea5a71f..538688598f2f 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1597,14 +1597,6 @@ config FUTEX_PI
> depends on FUTEX && RT_MUTEXES
> default y
>
> -config HAVE_FUTEX_CMPXCHG
> - bool
> - depends on FUTEX
> - help
> - Architectures should select this if futex_atomic_cmpxchg_inatomic()
> - is implemented and always working. This removes a couple of runtime
> - checks.
> -
> config EPOLL
> bool "Enable eventpoll support" if EXPERT
> default y
> diff --git a/kernel/futex/core.c b/kernel/futex/core.c
> index 25d8a88b32e5..926c2bb752bc 100644
> --- a/kernel/futex/core.c
> +++ b/kernel/futex/core.c
> @@ -41,11 +41,6 @@
> #include "futex.h"
> #include "../locking/rtmutex_common.h"
>
> -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
> -int __read_mostly futex_cmpxchg_enabled;
> -#endif
> -
> -
> /*
> * The base of the bucket array and its size are always used together
> * (after initialization only in futex_hash()), so ensure that they
> @@ -776,9 +771,6 @@ static void exit_robust_list(struct task_struct *curr)
> unsigned long futex_offset;
> int rc;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> -
> /*
> * Fetch the list head (which was registered earlier, via
> * sys_set_robust_list()):
> @@ -874,9 +866,6 @@ static void compat_exit_robust_list(struct task_struct *curr)
> compat_long_t futex_offset;
> int rc;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> -
> /*
> * Fetch the list head (which was registered earlier, via
> * sys_set_robust_list()):
> @@ -950,8 +939,6 @@ static void exit_pi_state_list(struct task_struct *curr)
> struct futex_hash_bucket *hb;
> union futex_key key = FUTEX_KEY_INIT;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> /*
> * We are a ZOMBIE and nobody can enqueue itself on
> * pi_state_list anymore, but we have to be careful
> @@ -1125,26 +1112,6 @@ void futex_exit_release(struct task_struct *tsk)
> futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
> }
>
> -static void __init futex_detect_cmpxchg(void)
> -{
> -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
> - u32 curval;
> -
> - /*
> - * This will fail and we want it. Some arch implementations do
> - * runtime detection of the futex_atomic_cmpxchg_inatomic()
> - * functionality. We want to know that before we call in any
> - * of the complex code paths. Also we want to prevent
> - * registration of robust lists in that case. NULL is
> - * guaranteed to fault and we get -EFAULT on functional
> - * implementation, the non-functional ones will return
> - * -ENOSYS.
> - */
> - if (futex_cmpxchg_value_locked(&curval, NULL, 0, 0) == -EFAULT)
> - futex_cmpxchg_enabled = 1;
> -#endif
> -}
> -
> static int __init futex_init(void)
> {
> unsigned int futex_shift;
> @@ -1163,8 +1130,6 @@ static int __init futex_init(void)
> futex_hashsize, futex_hashsize);
> futex_hashsize = 1UL << futex_shift;
>
> - futex_detect_cmpxchg();
> -
> for (i = 0; i < futex_hashsize; i++) {
> atomic_set(&futex_queues[i].waiters, 0);
> plist_head_init(&futex_queues[i].chain);
> diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
> index 040ae4277cb0..c264cbeab71c 100644
> --- a/kernel/futex/futex.h
> +++ b/kernel/futex/futex.h
> @@ -27,12 +27,6 @@
> #define FLAGS_CLOCKRT 0x02
> #define FLAGS_HAS_TIMEOUT 0x04
>
> -#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
> -#define futex_cmpxchg_enabled 1
> -#else
> -extern int __read_mostly futex_cmpxchg_enabled;
> -#endif
> -
> #ifdef CONFIG_FAIL_FUTEX
> extern bool should_fail_futex(bool fshared);
> #else
> diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
> index 6f91a07a6a83..086a22d1adb7 100644
> --- a/kernel/futex/syscalls.c
> +++ b/kernel/futex/syscalls.c
> @@ -29,8 +29,6 @@
> SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
> size_t, len)
> {
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> /*
> * The kernel knows only one size for now:
> */
> @@ -56,9 +54,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
> unsigned long ret;
> struct task_struct *p;
>
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> rcu_read_lock();
>
> ret = -ESRCH;
> @@ -103,17 +98,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
> return -ENOSYS;
> }
>
> - switch (cmd) {
> - case FUTEX_LOCK_PI:
> - case FUTEX_LOCK_PI2:
> - case FUTEX_UNLOCK_PI:
> - case FUTEX_TRYLOCK_PI:
> - case FUTEX_WAIT_REQUEUE_PI:
> - case FUTEX_CMP_REQUEUE_PI:
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> - }
> -
> switch (cmd) {
> case FUTEX_WAIT:
> val3 = FUTEX_BITSET_MATCH_ANY;
> @@ -323,9 +307,6 @@ COMPAT_SYSCALL_DEFINE2(set_robust_list,
> struct compat_robust_list_head __user *, head,
> compat_size_t, len)
> {
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> if (unlikely(len != sizeof(*head)))
> return -EINVAL;
>
> @@ -342,9 +323,6 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
> unsigned long ret;
> struct task_struct *p;
>
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> rcu_read_lock();
>
> ret = -ESRCH;
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:43 ` Christian Borntraeger
0 siblings, 0 replies; 29+ messages in thread
From: Christian Borntraeger @ 2021-10-26 10:43 UTC (permalink / raw)
To: Arnd Bergmann, Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Vineet Gupta, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
Am 26.10.21 um 12:03 schrieb Arnd Bergmann:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
s390 part
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
>
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 248389278e8f..f9413041686f 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -31,7 +31,6 @@ config ARC
> select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
> select HAVE_DEBUG_STACKOVERFLOW
> select HAVE_DEBUG_KMEMLEAK
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_IOREMAP_PROT
> select HAVE_KERNEL_GZIP
> select HAVE_KERNEL_LZMA
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index bb5d2c45477b..6448d311635d 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -93,7 +93,6 @@ config ARM
> select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
> select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
> select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
> select HAVE_IRQ_TIME_ACCOUNTING
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 0efc501f77aa..6c3c2ff5cef8 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -193,7 +193,6 @@ config ARM64
> select HAVE_PERF_USER_STACK_DUMP
> select HAVE_REGS_AND_STACK_ACCESS_API
> select HAVE_FUNCTION_ARG_ACCESS_API
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select MMU_GATHER_RCU_TABLE_FREE
> select HAVE_RSEQ
> select HAVE_STACKPROTECTOR
> diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
> index 823d3d5a9e11..efd7c5feac8b 100644
> --- a/arch/csky/Kconfig
> +++ b/arch/csky/Kconfig
> @@ -53,7 +53,6 @@ config CSKY
> select HAVE_FUNCTION_TRACER
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_ERROR_INJECTION
> - select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
> select HAVE_FTRACE_MCOUNT_RECORD
> select HAVE_KERNEL_GZIP
> select HAVE_KERNEL_LZO
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index 0b50da08a9c5..15a793c5b2dc 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -20,7 +20,6 @@ config M68K
> select HAVE_ASM_MODVERSIONS
> select HAVE_DEBUG_BUGVERBOSE
> select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
> - select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
> select HAVE_MOD_ARCH_SPECIFIC
> select HAVE_UID16
> select MMU_GATHER_NO_RANGE if MMU
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 77a088d0a7e9..037fea9fac14 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -84,7 +84,6 @@ config RISCV
> select HAVE_DMA_CONTIGUOUS if MMU
> select HAVE_EBPF_JIT if MMU
> select HAVE_FUNCTION_ERROR_INJECTION
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_GENERIC_VDSO if MMU && 64BIT
> select HAVE_IRQ_TIME_ACCOUNTING
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index f615c3f65f5a..1c9ecf619e04 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -164,7 +164,6 @@ config S390
> select HAVE_FUNCTION_ERROR_INJECTION
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_GENERIC_VDSO
> select HAVE_IOREMAP_PROT if PCI
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 6904f4bdbf00..93195d3368c0 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -34,7 +34,6 @@ config SUPERH
> select HAVE_FAST_GUP if MMU
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_FTRACE_MCOUNT_RECORD
> select HAVE_HW_BREAKPOINT
> select HAVE_IOREMAP_PROT if MMU && !X2TLB
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index c18b45f75d41..c906250d4970 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -14,7 +14,6 @@ config UML
> select HAVE_ARCH_SECCOMP_FILTER
> select HAVE_ASM_MODVERSIONS
> select HAVE_UID16
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_DEBUG_KMEMLEAK
> select HAVE_DEBUG_BUGVERBOSE
> select NO_DMA if !UML_DMA_EMULATION
> diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
> index a509be911026..9e37a7c05990 100644
> --- a/arch/um/kernel/skas/uaccess.c
> +++ b/arch/um/kernel/skas/uaccess.c
> @@ -348,7 +348,6 @@ EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
> * 0 - On success
> * -EFAULT - User access resulted in a page fault
> * -EAGAIN - Atomic operation was unable to complete due to contention
> - * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
> */
>
> int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
> diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
> index 0e56bad058fa..8ac599aa6d99 100644
> --- a/arch/xtensa/Kconfig
> +++ b/arch/xtensa/Kconfig
> @@ -31,7 +31,6 @@ config XTENSA
> select HAVE_DMA_CONTIGUOUS
> select HAVE_EXIT_THREAD
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
> select HAVE_HW_BREAKPOINT if PERF_EVENTS
> select HAVE_IRQ_TIME_ACCOUNTING
> select HAVE_PCI
> diff --git a/init/Kconfig b/init/Kconfig
> index c0f55ea5a71f..538688598f2f 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1597,14 +1597,6 @@ config FUTEX_PI
> depends on FUTEX && RT_MUTEXES
> default y
>
> -config HAVE_FUTEX_CMPXCHG
> - bool
> - depends on FUTEX
> - help
> - Architectures should select this if futex_atomic_cmpxchg_inatomic()
> - is implemented and always working. This removes a couple of runtime
> - checks.
> -
> config EPOLL
> bool "Enable eventpoll support" if EXPERT
> default y
> diff --git a/kernel/futex/core.c b/kernel/futex/core.c
> index 25d8a88b32e5..926c2bb752bc 100644
> --- a/kernel/futex/core.c
> +++ b/kernel/futex/core.c
> @@ -41,11 +41,6 @@
> #include "futex.h"
> #include "../locking/rtmutex_common.h"
>
> -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
> -int __read_mostly futex_cmpxchg_enabled;
> -#endif
> -
> -
> /*
> * The base of the bucket array and its size are always used together
> * (after initialization only in futex_hash()), so ensure that they
> @@ -776,9 +771,6 @@ static void exit_robust_list(struct task_struct *curr)
> unsigned long futex_offset;
> int rc;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> -
> /*
> * Fetch the list head (which was registered earlier, via
> * sys_set_robust_list()):
> @@ -874,9 +866,6 @@ static void compat_exit_robust_list(struct task_struct *curr)
> compat_long_t futex_offset;
> int rc;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> -
> /*
> * Fetch the list head (which was registered earlier, via
> * sys_set_robust_list()):
> @@ -950,8 +939,6 @@ static void exit_pi_state_list(struct task_struct *curr)
> struct futex_hash_bucket *hb;
> union futex_key key = FUTEX_KEY_INIT;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> /*
> * We are a ZOMBIE and nobody can enqueue itself on
> * pi_state_list anymore, but we have to be careful
> @@ -1125,26 +1112,6 @@ void futex_exit_release(struct task_struct *tsk)
> futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
> }
>
> -static void __init futex_detect_cmpxchg(void)
> -{
> -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
> - u32 curval;
> -
> - /*
> - * This will fail and we want it. Some arch implementations do
> - * runtime detection of the futex_atomic_cmpxchg_inatomic()
> - * functionality. We want to know that before we call in any
> - * of the complex code paths. Also we want to prevent
> - * registration of robust lists in that case. NULL is
> - * guaranteed to fault and we get -EFAULT on functional
> - * implementation, the non-functional ones will return
> - * -ENOSYS.
> - */
> - if (futex_cmpxchg_value_locked(&curval, NULL, 0, 0) == -EFAULT)
> - futex_cmpxchg_enabled = 1;
> -#endif
> -}
> -
> static int __init futex_init(void)
> {
> unsigned int futex_shift;
> @@ -1163,8 +1130,6 @@ static int __init futex_init(void)
> futex_hashsize, futex_hashsize);
> futex_hashsize = 1UL << futex_shift;
>
> - futex_detect_cmpxchg();
> -
> for (i = 0; i < futex_hashsize; i++) {
> atomic_set(&futex_queues[i].waiters, 0);
> plist_head_init(&futex_queues[i].chain);
> diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
> index 040ae4277cb0..c264cbeab71c 100644
> --- a/kernel/futex/futex.h
> +++ b/kernel/futex/futex.h
> @@ -27,12 +27,6 @@
> #define FLAGS_CLOCKRT 0x02
> #define FLAGS_HAS_TIMEOUT 0x04
>
> -#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
> -#define futex_cmpxchg_enabled 1
> -#else
> -extern int __read_mostly futex_cmpxchg_enabled;
> -#endif
> -
> #ifdef CONFIG_FAIL_FUTEX
> extern bool should_fail_futex(bool fshared);
> #else
> diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
> index 6f91a07a6a83..086a22d1adb7 100644
> --- a/kernel/futex/syscalls.c
> +++ b/kernel/futex/syscalls.c
> @@ -29,8 +29,6 @@
> SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
> size_t, len)
> {
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> /*
> * The kernel knows only one size for now:
> */
> @@ -56,9 +54,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
> unsigned long ret;
> struct task_struct *p;
>
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> rcu_read_lock();
>
> ret = -ESRCH;
> @@ -103,17 +98,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
> return -ENOSYS;
> }
>
> - switch (cmd) {
> - case FUTEX_LOCK_PI:
> - case FUTEX_LOCK_PI2:
> - case FUTEX_UNLOCK_PI:
> - case FUTEX_TRYLOCK_PI:
> - case FUTEX_WAIT_REQUEUE_PI:
> - case FUTEX_CMP_REQUEUE_PI:
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> - }
> -
> switch (cmd) {
> case FUTEX_WAIT:
> val3 = FUTEX_BITSET_MATCH_ANY;
> @@ -323,9 +307,6 @@ COMPAT_SYSCALL_DEFINE2(set_robust_list,
> struct compat_robust_list_head __user *, head,
> compat_size_t, len)
> {
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> if (unlikely(len != sizeof(*head)))
> return -EINVAL;
>
> @@ -342,9 +323,6 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
> unsigned long ret;
> struct task_struct *p;
>
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> rcu_read_lock();
>
> ret = -ESRCH;
>
_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 10:43 ` Christian Borntraeger
0 siblings, 0 replies; 29+ messages in thread
From: Christian Borntraeger @ 2021-10-26 10:43 UTC (permalink / raw)
To: Arnd Bergmann, Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Vineet Gupta, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
Darren Hart, Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
Am 26.10.21 um 12:03 schrieb Arnd Bergmann:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
s390 part
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
>
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 248389278e8f..f9413041686f 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -31,7 +31,6 @@ config ARC
> select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
> select HAVE_DEBUG_STACKOVERFLOW
> select HAVE_DEBUG_KMEMLEAK
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_IOREMAP_PROT
> select HAVE_KERNEL_GZIP
> select HAVE_KERNEL_LZMA
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index bb5d2c45477b..6448d311635d 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -93,7 +93,6 @@ config ARM
> select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
> select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
> select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
> select HAVE_IRQ_TIME_ACCOUNTING
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 0efc501f77aa..6c3c2ff5cef8 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -193,7 +193,6 @@ config ARM64
> select HAVE_PERF_USER_STACK_DUMP
> select HAVE_REGS_AND_STACK_ACCESS_API
> select HAVE_FUNCTION_ARG_ACCESS_API
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select MMU_GATHER_RCU_TABLE_FREE
> select HAVE_RSEQ
> select HAVE_STACKPROTECTOR
> diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
> index 823d3d5a9e11..efd7c5feac8b 100644
> --- a/arch/csky/Kconfig
> +++ b/arch/csky/Kconfig
> @@ -53,7 +53,6 @@ config CSKY
> select HAVE_FUNCTION_TRACER
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_ERROR_INJECTION
> - select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
> select HAVE_FTRACE_MCOUNT_RECORD
> select HAVE_KERNEL_GZIP
> select HAVE_KERNEL_LZO
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index 0b50da08a9c5..15a793c5b2dc 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -20,7 +20,6 @@ config M68K
> select HAVE_ASM_MODVERSIONS
> select HAVE_DEBUG_BUGVERBOSE
> select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
> - select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
> select HAVE_MOD_ARCH_SPECIFIC
> select HAVE_UID16
> select MMU_GATHER_NO_RANGE if MMU
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 77a088d0a7e9..037fea9fac14 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -84,7 +84,6 @@ config RISCV
> select HAVE_DMA_CONTIGUOUS if MMU
> select HAVE_EBPF_JIT if MMU
> select HAVE_FUNCTION_ERROR_INJECTION
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_GENERIC_VDSO if MMU && 64BIT
> select HAVE_IRQ_TIME_ACCOUNTING
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index f615c3f65f5a..1c9ecf619e04 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -164,7 +164,6 @@ config S390
> select HAVE_FUNCTION_ERROR_INJECTION
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_GCC_PLUGINS
> select HAVE_GENERIC_VDSO
> select HAVE_IOREMAP_PROT if PCI
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 6904f4bdbf00..93195d3368c0 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -34,7 +34,6 @@ config SUPERH
> select HAVE_FAST_GUP if MMU
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_FTRACE_MCOUNT_RECORD
> select HAVE_HW_BREAKPOINT
> select HAVE_IOREMAP_PROT if MMU && !X2TLB
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index c18b45f75d41..c906250d4970 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -14,7 +14,6 @@ config UML
> select HAVE_ARCH_SECCOMP_FILTER
> select HAVE_ASM_MODVERSIONS
> select HAVE_UID16
> - select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_DEBUG_KMEMLEAK
> select HAVE_DEBUG_BUGVERBOSE
> select NO_DMA if !UML_DMA_EMULATION
> diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
> index a509be911026..9e37a7c05990 100644
> --- a/arch/um/kernel/skas/uaccess.c
> +++ b/arch/um/kernel/skas/uaccess.c
> @@ -348,7 +348,6 @@ EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
> * 0 - On success
> * -EFAULT - User access resulted in a page fault
> * -EAGAIN - Atomic operation was unable to complete due to contention
> - * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
> */
>
> int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
> diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
> index 0e56bad058fa..8ac599aa6d99 100644
> --- a/arch/xtensa/Kconfig
> +++ b/arch/xtensa/Kconfig
> @@ -31,7 +31,6 @@ config XTENSA
> select HAVE_DMA_CONTIGUOUS
> select HAVE_EXIT_THREAD
> select HAVE_FUNCTION_TRACER
> - select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
> select HAVE_HW_BREAKPOINT if PERF_EVENTS
> select HAVE_IRQ_TIME_ACCOUNTING
> select HAVE_PCI
> diff --git a/init/Kconfig b/init/Kconfig
> index c0f55ea5a71f..538688598f2f 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1597,14 +1597,6 @@ config FUTEX_PI
> depends on FUTEX && RT_MUTEXES
> default y
>
> -config HAVE_FUTEX_CMPXCHG
> - bool
> - depends on FUTEX
> - help
> - Architectures should select this if futex_atomic_cmpxchg_inatomic()
> - is implemented and always working. This removes a couple of runtime
> - checks.
> -
> config EPOLL
> bool "Enable eventpoll support" if EXPERT
> default y
> diff --git a/kernel/futex/core.c b/kernel/futex/core.c
> index 25d8a88b32e5..926c2bb752bc 100644
> --- a/kernel/futex/core.c
> +++ b/kernel/futex/core.c
> @@ -41,11 +41,6 @@
> #include "futex.h"
> #include "../locking/rtmutex_common.h"
>
> -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
> -int __read_mostly futex_cmpxchg_enabled;
> -#endif
> -
> -
> /*
> * The base of the bucket array and its size are always used together
> * (after initialization only in futex_hash()), so ensure that they
> @@ -776,9 +771,6 @@ static void exit_robust_list(struct task_struct *curr)
> unsigned long futex_offset;
> int rc;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> -
> /*
> * Fetch the list head (which was registered earlier, via
> * sys_set_robust_list()):
> @@ -874,9 +866,6 @@ static void compat_exit_robust_list(struct task_struct *curr)
> compat_long_t futex_offset;
> int rc;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> -
> /*
> * Fetch the list head (which was registered earlier, via
> * sys_set_robust_list()):
> @@ -950,8 +939,6 @@ static void exit_pi_state_list(struct task_struct *curr)
> struct futex_hash_bucket *hb;
> union futex_key key = FUTEX_KEY_INIT;
>
> - if (!futex_cmpxchg_enabled)
> - return;
> /*
> * We are a ZOMBIE and nobody can enqueue itself on
> * pi_state_list anymore, but we have to be careful
> @@ -1125,26 +1112,6 @@ void futex_exit_release(struct task_struct *tsk)
> futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
> }
>
> -static void __init futex_detect_cmpxchg(void)
> -{
> -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
> - u32 curval;
> -
> - /*
> - * This will fail and we want it. Some arch implementations do
> - * runtime detection of the futex_atomic_cmpxchg_inatomic()
> - * functionality. We want to know that before we call in any
> - * of the complex code paths. Also we want to prevent
> - * registration of robust lists in that case. NULL is
> - * guaranteed to fault and we get -EFAULT on functional
> - * implementation, the non-functional ones will return
> - * -ENOSYS.
> - */
> - if (futex_cmpxchg_value_locked(&curval, NULL, 0, 0) == -EFAULT)
> - futex_cmpxchg_enabled = 1;
> -#endif
> -}
> -
> static int __init futex_init(void)
> {
> unsigned int futex_shift;
> @@ -1163,8 +1130,6 @@ static int __init futex_init(void)
> futex_hashsize, futex_hashsize);
> futex_hashsize = 1UL << futex_shift;
>
> - futex_detect_cmpxchg();
> -
> for (i = 0; i < futex_hashsize; i++) {
> atomic_set(&futex_queues[i].waiters, 0);
> plist_head_init(&futex_queues[i].chain);
> diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
> index 040ae4277cb0..c264cbeab71c 100644
> --- a/kernel/futex/futex.h
> +++ b/kernel/futex/futex.h
> @@ -27,12 +27,6 @@
> #define FLAGS_CLOCKRT 0x02
> #define FLAGS_HAS_TIMEOUT 0x04
>
> -#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
> -#define futex_cmpxchg_enabled 1
> -#else
> -extern int __read_mostly futex_cmpxchg_enabled;
> -#endif
> -
> #ifdef CONFIG_FAIL_FUTEX
> extern bool should_fail_futex(bool fshared);
> #else
> diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
> index 6f91a07a6a83..086a22d1adb7 100644
> --- a/kernel/futex/syscalls.c
> +++ b/kernel/futex/syscalls.c
> @@ -29,8 +29,6 @@
> SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
> size_t, len)
> {
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> /*
> * The kernel knows only one size for now:
> */
> @@ -56,9 +54,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
> unsigned long ret;
> struct task_struct *p;
>
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> rcu_read_lock();
>
> ret = -ESRCH;
> @@ -103,17 +98,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
> return -ENOSYS;
> }
>
> - switch (cmd) {
> - case FUTEX_LOCK_PI:
> - case FUTEX_LOCK_PI2:
> - case FUTEX_UNLOCK_PI:
> - case FUTEX_TRYLOCK_PI:
> - case FUTEX_WAIT_REQUEUE_PI:
> - case FUTEX_CMP_REQUEUE_PI:
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> - }
> -
> switch (cmd) {
> case FUTEX_WAIT:
> val3 = FUTEX_BITSET_MATCH_ANY;
> @@ -323,9 +307,6 @@ COMPAT_SYSCALL_DEFINE2(set_robust_list,
> struct compat_robust_list_head __user *, head,
> compat_size_t, len)
> {
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> if (unlikely(len != sizeof(*head)))
> return -EINVAL;
>
> @@ -342,9 +323,6 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
> unsigned long ret;
> struct task_struct *p;
>
> - if (!futex_cmpxchg_enabled)
> - return -ENOSYS;
> -
> rcu_read_lock();
>
> ret = -ESRCH;
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 1/2] futex: ensure futex_atomic_cmpxchg_inatomic() is present
2021-10-26 10:03 [PATCH 1/2] futex: ensure futex_atomic_cmpxchg_inatomic() is present Arnd Bergmann
2021-10-26 10:03 ` Arnd Bergmann
@ 2021-10-26 12:29 ` Max Filippov
2021-11-24 23:06 ` [tip: locking/core] futex: Ensure " tip-bot2 for Arnd Bergmann
2 siblings, 0 replies; 29+ messages in thread
From: Max Filippov @ 2021-10-26 12:29 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Thomas Bogendoerfer, Chris Zankel, Darren Hart, Davidlohr Bueso,
André Almeida, Masahiro Yamada, Kees Cook, Andrew Morton,
Nathan Chancellor, linux-mips, LKML,
open list:TENSILICA XTENSA PORT (xtensa),
Linux-Arch
On Tue, Oct 26, 2021 at 3:04 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> The boot-time detection of futex_atomic_cmpxchg_inatomic()
> has a bug on some 32-bit arm builds, and Thomas Gleixner
> suggested that setting CONFIG_HAVE_FUTEX_CMPXCHG would
> avoid the problem, as it is always present anyway.
>
> Looking into which other architectures could do the same
> showed that almost all architectures have it, the exceptions
> being:
>
> - some old 32-bit MIPS uniprocessor cores without ll/sc
> - one xtensa variant with no SMP
> - 32-bit SPARC when built for SMP
>
> Fix MIPS And Xtensa by rearranging the generic code to let it be used
> as a fallback.
>
> For SPARC, the SMP definition just ends up turning off futex anyway,
> so this can be done at Kconfig time instead. Note that sparc32
> glibc requires the CASA instruction for its mutexes anyway,
> which is only available when running on SPARCv9 or LEON CPUs,
> but needs to be implemented in the sparc32 kernel for those.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/mips/include/asm/futex.h | 29 ++++++++++++++++++-----------
> arch/xtensa/include/asm/futex.h | 8 ++++++--
> include/asm-generic/futex.h | 31 +++++++++++--------------------
> init/Kconfig | 1 +
> 4 files changed, 36 insertions(+), 33 deletions(-)
For xtensa:
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
2021-10-26 10:03 ` Arnd Bergmann
(?)
(?)
@ 2021-10-26 12:30 ` Max Filippov
-1 siblings, 0 replies; 29+ messages in thread
From: Max Filippov @ 2021-10-26 12:30 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Darren Hart,
Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
LKML, linux-arm-kernel, linux-csky, open list:M68K ARCHITECTURE,
linux-riscv, linux-s390, open list:SUPERH, linux-um,
open list:TENSILICA XTENSA PORT (xtensa)
On Tue, Oct 26, 2021 at 3:06 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
For xtensa:
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 12:30 ` Max Filippov
0 siblings, 0 replies; 29+ messages in thread
From: Max Filippov @ 2021-10-26 12:30 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Darren Hart,
Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
LKML, linux-arm-kernel, linux-csky, open list:M68K ARCHITECTURE,
linux-riscv, linux-s390, open list:SUPERH, linux-um,
open list:TENSILICA XTENSA PORT (xtensa)
On Tue, Oct 26, 2021 at 3:06 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
For xtensa:
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
--
Thanks.
-- Max
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 12:30 ` Max Filippov
0 siblings, 0 replies; 29+ messages in thread
From: Max Filippov @ 2021-10-26 12:30 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Darren Hart,
Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
LKML, linux-arm-kernel, linux-csky, open list:M68K ARCHITECTURE,
linux-riscv, linux-s390, open list:SUPERH, linux-um,
open list:TENSILICA XTENSA PORT (xtensa)
On Tue, Oct 26, 2021 at 3:06 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
For xtensa:
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
--
Thanks.
-- Max
_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 12:30 ` Max Filippov
0 siblings, 0 replies; 29+ messages in thread
From: Max Filippov @ 2021-10-26 12:30 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Rich Felker, Jeff Dike,
Richard Weinberger, Anton Ivanov, Chris Zankel, Darren Hart,
Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
LKML, linux-arm-kernel, linux-csky, open list:M68K ARCHITECTURE,
linux-riscv, linux-s390, open list:SUPERH, linux-um,
open list:TENSILICA XTENSA PORT (xtensa)
On Tue, Oct 26, 2021 at 3:06 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
For xtensa:
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
--
Thanks.
-- Max
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
2021-10-26 10:03 ` Arnd Bergmann
(?)
(?)
@ 2021-10-26 20:26 ` Rich Felker
-1 siblings, 0 replies; 29+ messages in thread
From: Rich Felker @ 2021-10-26 20:26 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Jeff Dike, Richard Weinberger,
Anton Ivanov, Chris Zankel, Max Filippov, Darren Hart,
Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
On Tue, Oct 26, 2021 at 12:03:48PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
Acked-by: Rich Felker <dalias@libc.org>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 20:26 ` Rich Felker
0 siblings, 0 replies; 29+ messages in thread
From: Rich Felker @ 2021-10-26 20:26 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Jeff Dike, Richard Weinberger,
Anton Ivanov, Chris Zankel, Max Filippov, Darren Hart,
Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
On Tue, Oct 26, 2021 at 12:03:48PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
Acked-by: Rich Felker <dalias@libc.org>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 20:26 ` Rich Felker
0 siblings, 0 replies; 29+ messages in thread
From: Rich Felker @ 2021-10-26 20:26 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Jeff Dike, Richard Weinberger,
Anton Ivanov, Chris Zankel, Max Filippov, Darren Hart,
Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
On Tue, Oct 26, 2021 at 12:03:48PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
Acked-by: Rich Felker <dalias@libc.org>
_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
@ 2021-10-26 20:26 ` Rich Felker
0 siblings, 0 replies; 29+ messages in thread
From: Rich Felker @ 2021-10-26 20:26 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Arnd Bergmann,
Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Geert Uytterhoeven, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
Alexander Gordeev, Yoshinori Sato, Jeff Dike, Richard Weinberger,
Anton Ivanov, Chris Zankel, Max Filippov, Darren Hart,
Davidlohr Bueso, André Almeida, Andrew Morton,
Mike Rapoport, Mark Rutland, Anshuman Khandual, linux-snps-arc,
linux-kernel, linux-arm-kernel, linux-csky, linux-m68k,
linux-riscv, linux-s390, linux-sh, linux-um, linux-xtensa
On Tue, Oct 26, 2021 at 12:03:48PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arc/Kconfig | 1 -
> arch/arm/Kconfig | 1 -
> arch/arm64/Kconfig | 1 -
> arch/csky/Kconfig | 1 -
> arch/m68k/Kconfig | 1 -
> arch/riscv/Kconfig | 1 -
> arch/s390/Kconfig | 1 -
> arch/sh/Kconfig | 1 -
> arch/um/Kconfig | 1 -
> arch/um/kernel/skas/uaccess.c | 1 -
> arch/xtensa/Kconfig | 1 -
> init/Kconfig | 8 --------
> kernel/futex/core.c | 35 -----------------------------------
> kernel/futex/futex.h | 6 ------
> kernel/futex/syscalls.c | 22 ----------------------
> 15 files changed, 82 deletions(-)
Acked-by: Rich Felker <dalias@libc.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/2] futex: remove futex_cmpxchg detection
2021-10-26 10:03 ` Arnd Bergmann
` (7 preceding siblings ...)
(?)
@ 2021-10-30 17:37 ` Vineet Gupta
-1 siblings, 0 replies; 29+ messages in thread
From: Vineet Gupta @ 2021-10-30 17:37 UTC (permalink / raw)
To: Arnd Bergmann, Peter Zijlstra, Thomas Gleixner, Ingo Molnar
Cc: Arnd Bergmann, Vineet Gupta, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, Alexander Gordeev, Yoshinori Sato,
Rich Felker, Jeff Dike, Richard Weinberger, Anton Ivanov,
Chris Zankel, arcml
On 10/26/21 3:03 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Now that all architectures have a working futex implementation
> in any configuration, remove the runtime detection code.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arc/Kconfig | 1 -
Acked-by: Vineet Gupta <vgupta@kernel.org> #arch/arc
Thx,
-Vineet
_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
^ permalink raw reply [flat|nested] 29+ messages in thread
* [tip: locking/core] futex: Remove futex_cmpxchg detection
2021-10-26 10:03 ` Arnd Bergmann
` (8 preceding siblings ...)
(?)
@ 2021-11-24 23:06 ` tip-bot2 for Arnd Bergmann
-1 siblings, 0 replies; 29+ messages in thread
From: tip-bot2 for Arnd Bergmann @ 2021-11-24 23:06 UTC (permalink / raw)
To: linux-tip-commits
Cc: Arnd Bergmann, Thomas Gleixner, Russell King (Oracle),
Vineet Gupta, Max Filippov, Christian Borntraeger, x86,
linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 3297481d688a5cc2973ea58bd78e66b8639748b1
Gitweb: https://git.kernel.org/tip/3297481d688a5cc2973ea58bd78e66b8639748b1
Author: Arnd Bergmann <arnd@arndb.de>
AuthorDate: Tue, 26 Oct 2021 12:03:48 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 25 Nov 2021 00:02:28 +01:00
futex: Remove futex_cmpxchg detection
Now that all architectures have a working futex implementation in any
configuration, remove the runtime detection code.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Acked-by: Vineet Gupta <vgupta@kernel.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Link: https://lore.kernel.org/r/20211026100432.1730393-2-arnd@kernel.org
---
arch/arc/Kconfig | 1 +-
arch/arm/Kconfig | 1 +-
arch/arm64/Kconfig | 1 +-
arch/csky/Kconfig | 1 +-
arch/m68k/Kconfig | 1 +-
arch/riscv/Kconfig | 1 +-
arch/s390/Kconfig | 1 +-
arch/sh/Kconfig | 1 +-
arch/um/Kconfig | 1 +-
arch/um/kernel/skas/uaccess.c | 1 +-
arch/xtensa/Kconfig | 1 +-
init/Kconfig | 8 +--------
kernel/futex/core.c | 35 +----------------------------------
kernel/futex/futex.h | 6 +------
kernel/futex/syscalls.c | 22 +---------------------
15 files changed, 82 deletions(-)
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index b4ae605..f74d986 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -32,7 +32,6 @@ config ARC
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
select HAVE_DEBUG_STACKOVERFLOW
select HAVE_DEBUG_KMEMLEAK
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_IOREMAP_PROT
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZMA
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f0f9e8b..2948487 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -92,7 +92,6 @@ config ARM
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index c4207cf..5e2dfef 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -194,7 +194,6 @@ config ARM64
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_POSIX_CPU_TIMERS_TASK_WORK
select HAVE_FUNCTION_ARG_ACCESS_API
- select HAVE_FUTEX_CMPXCHG if FUTEX
select MMU_GATHER_RCU_TABLE_FREE
select HAVE_RSEQ
select HAVE_STACKPROTECTOR
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index aed2b3e..132f43f 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -52,7 +52,6 @@ config CSKY
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 0b50da0..15a793c 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -20,7 +20,6 @@ config M68K
select HAVE_ASM_MODVERSIONS
select HAVE_DEBUG_BUGVERBOSE
select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
- select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_UID16
select MMU_GATHER_NO_RANGE if MMU
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 821252b..09abf62 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -83,7 +83,6 @@ config RISCV
select HAVE_DMA_CONTIGUOUS if MMU
select HAVE_EBPF_JIT if MMU
select HAVE_FUNCTION_ERROR_INJECTION
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO if MMU && 64BIT
select HAVE_IRQ_TIME_ACCOUNTING
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 8857ec3..f614562 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -165,7 +165,6 @@ config S390
select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS
select HAVE_GENERIC_VDSO
select HAVE_IOREMAP_PROT if PCI
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 70afb30..2474a04 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -34,7 +34,6 @@ config SUPERH
select HAVE_FAST_GUP if MMU
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_HW_BREAKPOINT
select HAVE_IOREMAP_PROT if MMU && !X2TLB
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index c18b45f..c906250 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -14,7 +14,6 @@ config UML
select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ASM_MODVERSIONS
select HAVE_UID16
- select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_DEBUG_KMEMLEAK
select HAVE_DEBUG_BUGVERBOSE
select NO_DMA if !UML_DMA_EMULATION
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index a509be9..9e37a7c 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -348,7 +348,6 @@ EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
* 0 - On success
* -EFAULT - User access resulted in a page fault
* -EAGAIN - Atomic operation was unable to complete due to contention
- * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
*/
int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 0e56bad..8ac599a 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -31,7 +31,6 @@ config XTENSA
select HAVE_DMA_CONTIGUOUS
select HAVE_EXIT_THREAD
select HAVE_FUNCTION_TRACER
- select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
select HAVE_HW_BREAKPOINT if PERF_EVENTS
select HAVE_IRQ_TIME_ACCOUNTING
select HAVE_PCI
diff --git a/init/Kconfig b/init/Kconfig
index 3f5aa50..76d89db 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1592,14 +1592,6 @@ config FUTEX_PI
depends on FUTEX && RT_MUTEXES
default y
-config HAVE_FUTEX_CMPXCHG
- bool
- depends on FUTEX
- help
- Architectures should select this if futex_atomic_cmpxchg_inatomic()
- is implemented and always working. This removes a couple of runtime
- checks.
-
config EPOLL
bool "Enable eventpoll support" if EXPERT
default y
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 25d8a88..926c2bb 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -41,11 +41,6 @@
#include "futex.h"
#include "../locking/rtmutex_common.h"
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
-int __read_mostly futex_cmpxchg_enabled;
-#endif
-
-
/*
* The base of the bucket array and its size are always used together
* (after initialization only in futex_hash()), so ensure that they
@@ -776,9 +771,6 @@ static void exit_robust_list(struct task_struct *curr)
unsigned long futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -874,9 +866,6 @@ static void compat_exit_robust_list(struct task_struct *curr)
compat_long_t futex_offset;
int rc;
- if (!futex_cmpxchg_enabled)
- return;
-
/*
* Fetch the list head (which was registered earlier, via
* sys_set_robust_list()):
@@ -950,8 +939,6 @@ static void exit_pi_state_list(struct task_struct *curr)
struct futex_hash_bucket *hb;
union futex_key key = FUTEX_KEY_INIT;
- if (!futex_cmpxchg_enabled)
- return;
/*
* We are a ZOMBIE and nobody can enqueue itself on
* pi_state_list anymore, but we have to be careful
@@ -1125,26 +1112,6 @@ void futex_exit_release(struct task_struct *tsk)
futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
}
-static void __init futex_detect_cmpxchg(void)
-{
-#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
- u32 curval;
-
- /*
- * This will fail and we want it. Some arch implementations do
- * runtime detection of the futex_atomic_cmpxchg_inatomic()
- * functionality. We want to know that before we call in any
- * of the complex code paths. Also we want to prevent
- * registration of robust lists in that case. NULL is
- * guaranteed to fault and we get -EFAULT on functional
- * implementation, the non-functional ones will return
- * -ENOSYS.
- */
- if (futex_cmpxchg_value_locked(&curval, NULL, 0, 0) == -EFAULT)
- futex_cmpxchg_enabled = 1;
-#endif
-}
-
static int __init futex_init(void)
{
unsigned int futex_shift;
@@ -1163,8 +1130,6 @@ static int __init futex_init(void)
futex_hashsize, futex_hashsize);
futex_hashsize = 1UL << futex_shift;
- futex_detect_cmpxchg();
-
for (i = 0; i < futex_hashsize; i++) {
atomic_set(&futex_queues[i].waiters, 0);
plist_head_init(&futex_queues[i].chain);
diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
index 040ae42..c264cbe 100644
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -27,12 +27,6 @@
#define FLAGS_CLOCKRT 0x02
#define FLAGS_HAS_TIMEOUT 0x04
-#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
-#define futex_cmpxchg_enabled 1
-#else
-extern int __read_mostly futex_cmpxchg_enabled;
-#endif
-
#ifdef CONFIG_FAIL_FUTEX
extern bool should_fail_futex(bool fshared);
#else
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index 6f91a07..086a22d 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -29,8 +29,6 @@
SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
/*
* The kernel knows only one size for now:
*/
@@ -56,9 +54,6 @@ SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
@@ -104,17 +99,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
}
switch (cmd) {
- case FUTEX_LOCK_PI:
- case FUTEX_LOCK_PI2:
- case FUTEX_UNLOCK_PI:
- case FUTEX_TRYLOCK_PI:
- case FUTEX_WAIT_REQUEUE_PI:
- case FUTEX_CMP_REQUEUE_PI:
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
- }
-
- switch (cmd) {
case FUTEX_WAIT:
val3 = FUTEX_BITSET_MATCH_ANY;
fallthrough;
@@ -323,9 +307,6 @@ COMPAT_SYSCALL_DEFINE2(set_robust_list,
struct compat_robust_list_head __user *, head,
compat_size_t, len)
{
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
if (unlikely(len != sizeof(*head)))
return -EINVAL;
@@ -342,9 +323,6 @@ COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid,
unsigned long ret;
struct task_struct *p;
- if (!futex_cmpxchg_enabled)
- return -ENOSYS;
-
rcu_read_lock();
ret = -ESRCH;
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [tip: locking/core] futex: Ensure futex_atomic_cmpxchg_inatomic() is present
2021-10-26 10:03 [PATCH 1/2] futex: ensure futex_atomic_cmpxchg_inatomic() is present Arnd Bergmann
2021-10-26 10:03 ` Arnd Bergmann
2021-10-26 12:29 ` [PATCH 1/2] futex: ensure futex_atomic_cmpxchg_inatomic() is present Max Filippov
@ 2021-11-24 23:06 ` tip-bot2 for Arnd Bergmann
2 siblings, 0 replies; 29+ messages in thread
From: tip-bot2 for Arnd Bergmann @ 2021-11-24 23:06 UTC (permalink / raw)
To: linux-tip-commits
Cc: Arnd Bergmann, Thomas Gleixner, Max Filippov, Geert Uytterhoeven,
Rich Felker, x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 3f2bedabb62c6210df63b604dc988d2f7f56f947
Gitweb: https://git.kernel.org/tip/3f2bedabb62c6210df63b604dc988d2f7f56f947
Author: Arnd Bergmann <arnd@arndb.de>
AuthorDate: Tue, 26 Oct 2021 12:03:47 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 25 Nov 2021 00:02:28 +01:00
futex: Ensure futex_atomic_cmpxchg_inatomic() is present
The boot-time detection of futex_atomic_cmpxchg_inatomic() has a bug on
some 32-bit arm builds, and Thomas Gleixner suggested that setting
CONFIG_HAVE_FUTEX_CMPXCHG would avoid the problem, as it is always present
anyway.
Looking into which other architectures could do the same showed that almost
all architectures have it, the exceptions being:
- some old 32-bit MIPS uniprocessor cores without ll/sc
- one xtensa variant with no SMP
- 32-bit SPARC when built for SMP
Fix MIPS And Xtensa by rearranging the generic code to let it be used
as a fallback.
For SPARC, the SMP definition just ends up turning off futex anyway, so
this can be done at Kconfig time instead. Note that sparc32 glibc requires
the CASA instruction for its mutexes anyway, which is only available when
running on SPARCv9 or LEON CPUs, but needs to be implemented in the sparc32
kernel for those.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Rich Felker <dalias@libc.org>
Link: https://lore.kernel.org/r/20211026100432.1730393-1-arnd@kernel.org
---
arch/mips/include/asm/futex.h | 29 ++++++++++++++++++-----------
arch/xtensa/include/asm/futex.h | 8 ++++++--
include/asm-generic/futex.h | 31 +++++++++++--------------------
init/Kconfig | 1 +
4 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/arch/mips/include/asm/futex.h b/arch/mips/include/asm/futex.h
index d852484..9287110 100644
--- a/arch/mips/include/asm/futex.h
+++ b/arch/mips/include/asm/futex.h
@@ -19,7 +19,11 @@
#include <asm/sync.h>
#include <asm/war.h>
-#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
+#define arch_futex_atomic_op_inuser arch_futex_atomic_op_inuser
+#define futex_atomic_cmpxchg_inatomic futex_atomic_cmpxchg_inatomic
+#include <asm-generic/futex.h>
+
+#define __futex_atomic_op(op, insn, ret, oldval, uaddr, oparg) \
{ \
if (cpu_has_llsc && IS_ENABLED(CONFIG_WAR_R10000_LLSC)) { \
__asm__ __volatile__( \
@@ -80,9 +84,11 @@
: "0" (0), GCC_OFF_SMALL_ASM() (*uaddr), "Jr" (oparg), \
"i" (-EFAULT) \
: "memory"); \
- } else \
- ret = -ENOSYS; \
-}
+ } else { \
+ /* fallback for non-SMP */ \
+ ret = arch_futex_atomic_op_inuser_local(op, oparg, oval,\
+ uaddr); \
+ }
static inline int
arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
@@ -94,23 +100,23 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
switch (op) {
case FUTEX_OP_SET:
- __futex_atomic_op("move $1, %z5", ret, oldval, uaddr, oparg);
+ __futex_atomic_op(op, "move $1, %z5", ret, oldval, uaddr, oparg);
break;
case FUTEX_OP_ADD:
- __futex_atomic_op("addu $1, %1, %z5",
+ __futex_atomic_op(op, "addu $1, %1, %z5",
ret, oldval, uaddr, oparg);
break;
case FUTEX_OP_OR:
- __futex_atomic_op("or $1, %1, %z5",
+ __futex_atomic_op(op, "or $1, %1, %z5",
ret, oldval, uaddr, oparg);
break;
case FUTEX_OP_ANDN:
- __futex_atomic_op("and $1, %1, %z5",
+ __futex_atomic_op(op, "and $1, %1, %z5",
ret, oldval, uaddr, ~oparg);
break;
case FUTEX_OP_XOR:
- __futex_atomic_op("xor $1, %1, %z5",
+ __futex_atomic_op(op, "xor $1, %1, %z5",
ret, oldval, uaddr, oparg);
break;
default:
@@ -193,8 +199,9 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
: GCC_OFF_SMALL_ASM() (*uaddr), "Jr" (oldval), "Jr" (newval),
"i" (-EFAULT)
: "memory");
- } else
- return -ENOSYS;
+ } else {
+ return futex_atomic_cmpxchg_inatomic_local(uval, uaddr, oldval, newval);
+ }
*uval = val;
return ret;
diff --git a/arch/xtensa/include/asm/futex.h b/arch/xtensa/include/asm/futex.h
index a1a27b2..fe8f315 100644
--- a/arch/xtensa/include/asm/futex.h
+++ b/arch/xtensa/include/asm/futex.h
@@ -16,6 +16,10 @@
#include <linux/uaccess.h>
#include <linux/errno.h>
+#define arch_futex_atomic_op_inuser arch_futex_atomic_op_inuser
+#define futex_atomic_cmpxchg_inatomic futex_atomic_cmpxchg_inatomic
+#include <asm-generic/futex.h>
+
#if XCHAL_HAVE_EXCLUSIVE
#define __futex_atomic_op(insn, ret, old, uaddr, arg) \
__asm__ __volatile( \
@@ -105,7 +109,7 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
return ret;
#else
- return -ENOSYS;
+ return arch_futex_atomic_op_inuser_local(op, oparg, oval, uaddr);
#endif
}
@@ -156,7 +160,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
return ret;
#else
- return -ENOSYS;
+ return futex_atomic_cmpxchg_inatomic_local(uval, uaddr, oldval, newval);
#endif
}
diff --git a/include/asm-generic/futex.h b/include/asm-generic/futex.h
index f4c3470..30e7fa6 100644
--- a/include/asm-generic/futex.h
+++ b/include/asm-generic/futex.h
@@ -6,15 +6,22 @@
#include <linux/uaccess.h>
#include <asm/errno.h>
+#ifndef futex_atomic_cmpxchg_inatomic
#ifndef CONFIG_SMP
/*
* The following implementation only for uniprocessor machines.
* It relies on preempt_disable() ensuring mutual exclusion.
*
*/
+#define futex_atomic_cmpxchg_inatomic(uval, uaddr, oldval, newval) \
+ futex_atomic_cmpxchg_inatomic_local_generic(uval, uaddr, oldval, newval)
+#define arch_futex_atomic_op_inuser(op, oparg, oval, uaddr) \
+ arch_futex_atomic_op_inuser_local_generic(op, oparg, oval, uaddr)
+#endif /* CONFIG_SMP */
+#endif
/**
- * arch_futex_atomic_op_inuser() - Atomic arithmetic operation with constant
+ * arch_futex_atomic_op_inuser_local() - Atomic arithmetic operation with constant
* argument and comparison of the previous
* futex value with another constant.
*
@@ -28,7 +35,7 @@
* -ENOSYS - Operation not supported
*/
static inline int
-arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr)
+futex_atomic_op_inuser_local(int op, u32 oparg, int *oval, u32 __user *uaddr)
{
int oldval, ret;
u32 tmp;
@@ -75,7 +82,7 @@ out_pagefault_enable:
}
/**
- * futex_atomic_cmpxchg_inatomic() - Compare and exchange the content of the
+ * futex_atomic_cmpxchg_inatomic_local() - Compare and exchange the content of the
* uaddr with newval if the current value is
* oldval.
* @uval: pointer to store content of @uaddr
@@ -87,10 +94,9 @@ out_pagefault_enable:
* 0 - On success
* -EFAULT - User access resulted in a page fault
* -EAGAIN - Atomic operation was unable to complete due to contention
- * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
*/
static inline int
-futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
+futex_atomic_cmpxchg_inatomic_local(u32 *uval, u32 __user *uaddr,
u32 oldval, u32 newval)
{
u32 val;
@@ -112,19 +118,4 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
return 0;
}
-#else
-static inline int
-arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr)
-{
- return -ENOSYS;
-}
-
-static inline int
-futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
- u32 oldval, u32 newval)
-{
- return -ENOSYS;
-}
-
-#endif /* CONFIG_SMP */
#endif
diff --git a/init/Kconfig b/init/Kconfig
index 036b750..3f5aa50 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1579,6 +1579,7 @@ config BASE_FULL
config FUTEX
bool "Enable futex support" if EXPERT
+ depends on !(SPARC32 && SMP)
default y
imply RT_MUTEXES
help
^ permalink raw reply related [flat|nested] 29+ messages in thread
end of thread, other threads:[~2021-11-24 23:06 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 10:03 [PATCH 1/2] futex: ensure futex_atomic_cmpxchg_inatomic() is present Arnd Bergmann
2021-10-26 10:03 ` [PATCH 2/2] futex: remove futex_cmpxchg detection Arnd Bergmann
2021-10-26 10:03 ` Arnd Bergmann
2021-10-26 10:03 ` Arnd Bergmann
2021-10-26 10:03 ` Arnd Bergmann
2021-10-26 10:16 ` Geert Uytterhoeven
2021-10-26 10:16 ` Geert Uytterhoeven
2021-10-26 10:16 ` Geert Uytterhoeven
2021-10-26 10:16 ` Geert Uytterhoeven
2021-10-26 10:38 ` Russell King (Oracle)
2021-10-26 10:38 ` Russell King (Oracle)
2021-10-26 10:38 ` Russell King (Oracle)
2021-10-26 10:38 ` Russell King (Oracle)
2021-10-26 10:43 ` Christian Borntraeger
2021-10-26 10:43 ` Christian Borntraeger
2021-10-26 10:43 ` Christian Borntraeger
2021-10-26 10:43 ` Christian Borntraeger
2021-10-26 12:30 ` Max Filippov
2021-10-26 12:30 ` Max Filippov
2021-10-26 12:30 ` Max Filippov
2021-10-26 12:30 ` Max Filippov
2021-10-26 20:26 ` Rich Felker
2021-10-26 20:26 ` Rich Felker
2021-10-26 20:26 ` Rich Felker
2021-10-26 20:26 ` Rich Felker
2021-10-30 17:37 ` Vineet Gupta
2021-11-24 23:06 ` [tip: locking/core] futex: Remove " tip-bot2 for Arnd Bergmann
2021-10-26 12:29 ` [PATCH 1/2] futex: ensure futex_atomic_cmpxchg_inatomic() is present Max Filippov
2021-11-24 23:06 ` [tip: locking/core] futex: Ensure " tip-bot2 for Arnd Bergmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.