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

On minimum supported kernel (v3.2 and v2.6.32 for x86) kernel has:

2418 SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
2419                 size_t, len)
2420 {
2421         if (!futex_cmpxchg_enabled)
2422                 return -ENOSYS;

The patch also adds the __set_robust_list_avail runtime check for all
architectures, since for some the syscall may still return ENOSYS if
futex_atomic_cmpxchg_inatomic is not supported (for instance ARM).

Tested on armhf (with 3.8 kernel) and x86_64.

* nptl/nptl-init.c [__ASSUME_SET_ROBUST_LIST]
(__set_robust_list_avail): Remove define.
[__NR_set_robust_list] (__pthread_initialize_minimal_internal):
Likewise.
* nptl/pthreadP.h [__ASSUME_SET_ROBUST_LIST]
(__set_robust_list_avail): Likewise.
* nptl/pthread_create.c
[__NR_set_robust_list && !__ASSUME_SET_ROBUST_LIST]
(START_THREAD_DEFN): Likewise.
* nptl/pthread_mutex_init.c [!__ASSUME_SET_ROBUST_LIST]
(__pthread_mutex_init): Likewise.
* sysdeps/unix/sysv/linux/arm/kernel-features.h
(__ASSUME_SET_ROBUST_LIST): Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h:
(__ASSUME_SET_ROBUST_LIST): Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h:
(__ASSUME_SET_ROBUST_LIST): Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h:
(__ASSUME_SET_ROBUST_LIST): Likewise.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h:
(__ASSUME_SET_ROBUST_LIST): Likewise.

ChangeLog
nptl/nptl-init.c
nptl/pthreadP.h
nptl/pthread_create.c
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 3919fe9894b22ead37629bf7865342f6593c1d85..aadf824afef5cf227064fc8d6e0f0ff9374e2e49 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,28 @@
 
 2016-06-03  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+       * nptl/nptl-init.c [__ASSUME_SET_ROBUST_LIST]
+       (__set_robust_list_avail): Remove define.
+       [__NR_set_robust_list] (__pthread_initialize_minimal_internal):
+       Likewise.
+       * nptl/pthreadP.h [__ASSUME_SET_ROBUST_LIST]
+       (__set_robust_list_avail): Likewise.
+       * nptl/pthread_create.c
+       [__NR_set_robust_list && !__ASSUME_SET_ROBUST_LIST]
+       (START_THREAD_DEFN): Likewise.
+       * nptl/pthread_mutex_init.c [!__ASSUME_SET_ROBUST_LIST]
+       (__pthread_mutex_init): Likewise.
+       * sysdeps/unix/sysv/linux/arm/kernel-features.h
+       (__ASSUME_SET_ROBUST_LIST): Likewise.
+       * sysdeps/unix/sysv/linux/kernel-features.h:
+       (__ASSUME_SET_ROBUST_LIST): Likewise.
+       * sysdeps/unix/sysv/linux/m68k/kernel-features.h:
+       (__ASSUME_SET_ROBUST_LIST): Likewise.
+       * sysdeps/unix/sysv/linux/mips/kernel-features.h:
+       (__ASSUME_SET_ROBUST_LIST): Likewise.
+       * sysdeps/unix/sysv/linux/sparc/kernel-features.h:
+       (__ASSUME_SET_ROBUST_LIST): Likewise.
+
        * nptl/pthread_mutex_init.c [__ASSUME_FUTEX_LOCK_PI]
        (prio_inherit_missing): Remove define.
        * sysdeps/unix/sysv/linux/arm/kernel-features.h
index 7f2043dc33df5b179ba420713711bce6c4f3eeb7..388c792d2f824b2c0df08a78a52b9b5e8c55fff0 100644 (file)
@@ -46,14 +46,8 @@ int *__libc_multiple_threads_ptr attribute_hidden;
 size_t __static_tls_size;
 size_t __static_tls_align_m1;
 
-#ifndef __ASSUME_SET_ROBUST_LIST
 /* Negative if we do not have the system call and we can use it.  */
 int __set_robust_list_avail;
-# define set_robust_list_not_avail() \
-  __set_robust_list_avail = -1
-#else
-# define set_robust_list_not_avail() do { } while (0)
-#endif
 
 #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
 /* Nonzero if we do not have FUTEX_CLOCK_REALTIME.  */
@@ -329,7 +323,7 @@ __pthread_initialize_minimal_internal (void)
     pd->robust_prev = &pd->robust_head;
 #endif
     pd->robust_head.list = &pd->robust_head;
-#ifdef __NR_set_robust_list
+
     pd->robust_head.futex_offset = (offsetof (pthread_mutex_t, __data.__lock)
                                    - offsetof (pthread_mutex_t,
                                                __data.__list.__next));
@@ -337,8 +331,7 @@ __pthread_initialize_minimal_internal (void)
     int res = INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
                                sizeof (struct robust_list_head));
     if (INTERNAL_SYSCALL_ERROR_P (res, err))
-#endif
-      set_robust_list_not_avail ();
+      __set_robust_list_avail = -1;
   }
 
 #ifdef __NR_futex
index 84a7105848996d98f7350dddd4c8e29a0129a8c8..a4a6ee1906958b0866be86acceca3e4044f0e79a 100644 (file)
@@ -199,10 +199,8 @@ hidden_proto (__pthread_keys)
 /* Number of threads running.  */
 extern unsigned int __nptl_nthreads attribute_hidden;
 
-#ifndef __ASSUME_SET_ROBUST_LIST
 /* Negative if we do not have the system call and we can use it.  */
 extern int __set_robust_list_avail attribute_hidden;
-#endif
 
 /* Thread Priority Protection.  */
 extern int __sched_fifo_min_prio attribute_hidden;
index 71a56193e6de0557a5f9439bdff5e45b5127a0d4..e5087a9441aba76dd3969c962a55412f039fd741 100644 (file)
@@ -271,10 +271,7 @@ START_THREAD_DEFN
   if (__glibc_unlikely (atomic_exchange_acq (&pd->setxid_futex, 0) == -2))
     lll_futex_wake (&pd->setxid_futex, 1, LLL_PRIVATE);
 
-#ifdef __NR_set_robust_list
-# ifndef __ASSUME_SET_ROBUST_LIST
-  if (__set_robust_list_avail >= 0)
-# endif
+  if (__glibc_likely (__set_robust_list_avail >= 0))
     {
       INTERNAL_SYSCALL_DECL (err);
       /* This call should never fail because the initial call in init.c
@@ -282,7 +279,6 @@ START_THREAD_DEFN
       INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
                        sizeof (struct robust_list_head));
     }
-#endif
 
 #ifdef SIGCANCEL
   /* If the parent was running cancellation handlers while creating
@@ -388,7 +384,6 @@ START_THREAD_DEFN
      the breakpoint reports TD_THR_RUN state rather than TD_THR_ZOMBIE.  */
   atomic_bit_set (&pd->cancelhandling, EXITING_BIT);
 
-#ifndef __ASSUME_SET_ROBUST_LIST
   /* If this thread has any robust mutexes locked, handle them now.  */
 # ifdef __PTHREAD_MUTEX_HAVE_PREV
   void *robust = pd->robust_head.list;
@@ -418,7 +413,6 @@ START_THREAD_DEFN
        }
       while (robust != (void *) &pd->robust_head);
     }
-#endif
 
   /* Mark the memory of the stack as usable to the kernel.  We free
      everything except for the space used for the TCB itself.  */
index eb34bbcfa373a2242316af772373c89920f09d50..2bc1f881fa9828958f633b896eae041468104bc6 100644 (file)
@@ -92,11 +92,9 @@ __pthread_mutex_init (mutex, mutexattr)
 
   if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0)
     {
-#ifndef __ASSUME_SET_ROBUST_LIST
       if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_PSHARED) != 0
          && __set_robust_list_avail < 0)
        return ENOTSUP;
-#endif
 
       mutex->__data.__kind |= PTHREAD_MUTEX_ROBUST_NORMAL_NP;
     }
index 7b4d9da2029df4f1994fc76eabf573542cf638fd..5de2b18953c557135c2f7c8e6a93b4888d879f7d 100644 (file)
@@ -39,5 +39,4 @@
    configuration.  */
 #if __LINUX_KERNEL_VERSION < 0x030E03
 # undef __ASSUME_REQUEUE_PI
-# undef __ASSUME_SET_ROBUST_LIST
 #endif
index 907d8af9a96945cdad1a80ee020ef8b13ff8d894..63a2f0c35b09b8ec40214984d9498b2543e35c2f 100644 (file)
    they were introduced in 2.6.17-rc1, on SH in 2.6.19-rc1.  */
 #define __ASSUME_ATFCTS        1
 
-/* Support for inter-process robust mutexes was added in 2.6.17 (but
-   some architectures lack futex_atomic_cmpxchg_inatomic in some
-   configurations).  */
-#define __ASSUME_SET_ROBUST_LIST       1
-
 /* Support for private futexes was added in 2.6.22.  */
 #define __ASSUME_PRIVATE_FUTEX 1
 
index 3a44d59f3db2fe9172343b74a913909c700ce329..10bc87e35734f5004a184215b81c4d3e7746f451 100644 (file)
@@ -31,5 +31,4 @@
 /* No support for PI futexes or robust mutexes before 3.10 for m68k.  */
 #if __LINUX_KERNEL_VERSION < 0x030a00
 # undef __ASSUME_REQUEUE_PI
-# undef __ASSUME_SET_ROBUST_LIST
 #endif
index ca70d6d0e4986256a7af5370dcc302df6e1a75b0..813c2465290ba8f03a85916d3f68b1efcdbf9767 100644 (file)
@@ -44,5 +44,4 @@
    emulating LL/SC.  */
 #if __mips == 1 || defined _MIPS_ARCH_R5900
 # undef __ASSUME_REQUEUE_PI
-# undef __ASSUME_SET_ROBUST_LIST
 #endif
index 6d74242ff54ba0ab700d2e9056bad1be7344bfa9..5b6582ef16e71d7073160f2d3aa6a47a9a2be589 100644 (file)
@@ -42,5 +42,4 @@
    futex_atomic_cmpxchg_inatomic.  */
 #if !defined __arch64__ && !defined __sparc_v9__
 # undef __ASSUME_REQUEUE_PI
-# undef __ASSUME_SET_ROBUST_LIST
 #endif