futex: Remove futex_cmpxchg detection
authorArnd Bergmann <arnd@arndb.de>
Tue, 26 Oct 2021 10:03:48 +0000 (12:03 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 24 Nov 2021 23:02:28 +0000 (00:02 +0100)
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
15 files changed:
arch/arc/Kconfig
arch/arm/Kconfig
arch/arm64/Kconfig
arch/csky/Kconfig
arch/m68k/Kconfig
arch/riscv/Kconfig
arch/s390/Kconfig
arch/sh/Kconfig
arch/um/Kconfig
arch/um/kernel/skas/uaccess.c
arch/xtensa/Kconfig
init/Kconfig
kernel/futex/core.c
kernel/futex/futex.h
kernel/futex/syscalls.c

index b4ae6058902afd52c554fe5e5e6be68fc7ada2bb..f74d9860a4420c6e9ecf1f611d232c028232468e 100644 (file)
@@ -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
index f0f9e8bec83acfa6ca3108664f8f815e0715bd34..2948487346dc9627f26ec7d76130a9fb5d1ca514 100644 (file)
@@ -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
index c4207cf9bb17ffb28147c51ce6a38ed54c01c4ff..5e2dfef78956ac974facac542862b1536d5e1f61 100644 (file)
@@ -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
index aed2b3e734ee0977f9f861915dd606b7ba28e80f..132f43f12dd851ce7af45ab662e928fece901d73 100644 (file)
@@ -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
index 0b50da08a9c56fc691aa1e918e5b641ae2dc7fae..15a793c5b2dc428d2e7d945189f36366a441f2b7 100644 (file)
@@ -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
index 821252b65f89065c4b5aa922e134a3f012d57f10..09abf62ae0ad4da02c0d1ff2594f20bb964c05dc 100644 (file)
@@ -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
index 8857ec3b97eb887d4bc78ecc8462b942b2b62071..f614562d74f0576416c7f8f5ad1f5b054dfbc7b7 100644 (file)
@@ -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
index 70afb30e0b321183e908c30851e91b0fbe4b57e2..2474a04ceac438975fcb0acb8daf730fbbb1edbe 100644 (file)
@@ -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
index c18b45f75d41f7105de150734c09d42106fea8eb..c906250d49706c77879189f6e507d4c40d4e036d 100644 (file)
@@ -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
index a509be91102604a58e43d16cc8b6014e054ddc74..9e37a7c05990d3207f66938236d30eea1d9757f4 100644 (file)
@@ -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,
index 0e56bad058faee6bc0776f09f284dbdd9bbf47b1..8ac599aa6d994780f67445646ef0a571de0bed53 100644 (file)
@@ -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
index 3f5aa5063f555910021d25e33b8219bf12eb211c..76d89db5657be2b4c0712a0307dd64ad0aec360f 100644 (file)
@@ -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
index 25d8a88b32e5b0566723c6d8064053ae87755d50..926c2bb752bc88717bf8b1ff899c7b139a26b6ad 100644 (file)
 #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);
index 040ae4277cb0cad0070e468da015d28b06c94418..c264cbeab71c6c1c5147b95170e6ff4855b7989d 100644 (file)
 #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
index 6f91a07a6a8360bb6bea1a6b4c60898db64ab349..086a22d1adb78f4a53760bc8e975c55a5cd6a186 100644 (file)
@@ -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;