]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Remove __ASSUME_FUTEX_LOCK_PI
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 16 May 2016 13:35:25 +0000 (10:35 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 7 Jun 2016 13:33:38 +0000 (10:33 -0300)
This patch removes __ASSUME_FUTEX_LOCK_PI usage and assumes that
kernel will correctly return if it supports or not
futex_atomic_cmpxchg_inatomic.

Current PI mutex code already has runtime support by calling
prio_inherit_missing and returns ENOTSUP if the futex operation fails
at initialization (it issues a FUTEX_UNLOCK_PI futex operation).

Also, current minimum supported kernel (v3.2) will return ENOSYS if
futex_atomic_cmpxchg_inatomic is not supported in the system:

kernel/futex.c:

2628 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
2629                 u32 __user *uaddr2, u32 val2, u32 val3)
2630 {
2631         int ret = -ENOSYS, cmd = op & FUTEX_CMD_MASK;
[...]
2667         case FUTEX_UNLOCK_PI:
2668                 if (futex_cmpxchg_enabled)
2669                         ret = futex_unlock_pi(uaddr, flags);
[...]
2686         return ret;
2687 }

The futex_cmpxchg_enabled is initialized by calling cmpxchg_futex_value_locked,
which calls futex_atomic_cmpxchg_inatomic.

For ARM futex_atomic_cmpxchg_inatomic will be either defined (if both
CONFIG_CPU_USE_DOMAINS and CONFIG_SMP are not defined) or use the
default generic implementation that returns ENOSYS.

For m68k is uses the default generic implementation.

For mips futex_atomic_cmpxchg_inatomic will return ENOSYS if cpu has no
'cpu_has_llsc' support (defined by each chip supporte inside kernel).

For sparc, 32-bit kernel will just use default generic implementation,
while 64-bit kernel has support.

Tested on ARM (v3.8 kernel) and x86_64.

* nptl/pthread_mutex_init.c [__ASSUME_FUTEX_LOCK_PI]
(prio_inherit_missing): Remove define.
* sysdeps/unix/sysv/linux/arm/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_FUTEX_LOCK_PI):
Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.

ChangeLog
nptl/pthread_mutex_init.c
sysdeps/unix/sysv/linux/arm/kernel-features.h
sysdeps/unix/sysv/linux/kernel-features.h
sysdeps/unix/sysv/linux/m68k/kernel-features.h
sysdeps/unix/sysv/linux/mips/kernel-features.h
sysdeps/unix/sysv/linux/sparc/kernel-features.h

index 666be708d2e6469830740375fe14f6d363d5c210..423d71554c151c88efdc5938b89efc1c025b23af 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2016-06-03  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+       * nptl/pthread_mutex_init.c [__ASSUME_FUTEX_LOCK_PI]
+       (prio_inherit_missing): Remove define.
+       * sysdeps/unix/sysv/linux/arm/kernel-features.h
+       (__ASSUME_FUTEX_LOCK_PI): Likewise.
+       * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_FUTEX_LOCK_PI):
+       Likewise.
+       * sysdeps/unix/sysv/linux/m68k/kernel-features.h
+       (__ASSUME_FUTEX_LOCK_PI): Likewise.
+       * sysdeps/unix/sysv/linux/mips/kernel-features.h
+       (__ASSUME_FUTEX_LOCK_PI): Likewise.
+       * sysdeps/unix/sysv/linux/sparc/kernel-features.h
+       (__ASSUME_FUTEX_LOCK_PI): Likewise.
+
 2016-05-09  Yvan Roux  <yvan.roux@linaro.org>
 
        * stdlib/setenv.c (unsetenv): Fix ambiguous 'else'.
index d71cfef0f7acfaa1f571000a2f6f55e823ff9adc..eb34bbcfa373a2242316af772373c89920f09d50 100644 (file)
@@ -37,7 +37,6 @@ static bool
 prio_inherit_missing (void)
 {
 #ifdef __NR_futex
-# ifndef __ASSUME_FUTEX_LOCK_PI
   static int tpi_supported;
   if (__glibc_unlikely (tpi_supported == 0))
     {
@@ -48,8 +47,6 @@ prio_inherit_missing (void)
       tpi_supported = INTERNAL_SYSCALL_ERRNO (ret, err) == ENOSYS ? -1 : 1;
     }
   return __glibc_unlikely (tpi_supported < 0);
-# endif
-  return false;
 #endif
   return true;
 }
index cb407dbc300c1f302fa04864c30a96176731d145..7b4d9da2029df4f1994fc76eabf573542cf638fd 100644 (file)
@@ -38,7 +38,6 @@
    futex_atomic_cmpxchg_inatomic, depending on kernel
    configuration.  */
 #if __LINUX_KERNEL_VERSION < 0x030E03
-# undef __ASSUME_FUTEX_LOCK_PI
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
index 2ca6f101eca9afa309a6852d3f4b33c28eb46afb..907d8af9a96945cdad1a80ee020ef8b13ff8d894 100644 (file)
    configurations).  */
 #define __ASSUME_SET_ROBUST_LIST       1
 
-/* Support for PI futexes was added in 2.6.18 (but some architectures
-   lack futex_atomic_cmpxchg_inatomic in some configurations).  */
-#define __ASSUME_FUTEX_LOCK_PI 1
-
 /* Support for private futexes was added in 2.6.22.  */
 #define __ASSUME_PRIVATE_FUTEX 1
 
index ae1a11f2a19248d171d29f8bcb5b5f989cc90617..3a44d59f3db2fe9172343b74a913909c700ce329 100644 (file)
@@ -30,7 +30,6 @@
 
 /* No support for PI futexes or robust mutexes before 3.10 for m68k.  */
 #if __LINUX_KERNEL_VERSION < 0x030a00
-# undef __ASSUME_FUTEX_LOCK_PI
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
index 50d93280389ad97f692067a7fc85340cf5251050..ca70d6d0e4986256a7af5370dcc302df6e1a75b0 100644 (file)
@@ -43,7 +43,6 @@
 /* The MIPS kernel does not support futex_atomic_cmpxchg_inatomic if
    emulating LL/SC.  */
 #if __mips == 1 || defined _MIPS_ARCH_R5900
-# undef __ASSUME_FUTEX_LOCK_PI
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
index 94df407e6d958cff34253b831f4e533483bb7bec..6d74242ff54ba0ab700d2e9056bad1be7344bfa9 100644 (file)
@@ -41,7 +41,6 @@
 /* 32-bit SPARC kernels do not support
    futex_atomic_cmpxchg_inatomic.  */
 #if !defined __arch64__ && !defined __sparc_v9__
-# undef __ASSUME_FUTEX_LOCK_PI
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif