From patchwork Wed May 18 21:57:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 68060 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2869286qge; Wed, 18 May 2016 14:57:59 -0700 (PDT) X-Received: by 10.98.74.142 with SMTP id c14mr14141345pfj.63.1463608679088; Wed, 18 May 2016 14:57:59 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w7si14694843pal.114.2016.05.18.14.57.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 May 2016 14:57:59 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-69692-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-69692-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-69692-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=xdH4zdZX0FSKgZd7k1MmY4oc6MN4lFP mzAoZ+26AkylEUJxQEEhZzp9zGVKvhECtqp4kUY1nqDhZMEzUNe2LIkAY2JGuZUn CY6pfCfbf+5FtD9JCY/K1zleIIDBgLuSWTed1isRy++DSuWZXClm5Ua8bFBwjNuC pb/nQITy1HyI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=kL1oMOluyAaCm3AdNFoN4rBHeKY=; b=LiN9J 0rGDK0rah0qWKJRGY0eHmAvKKh8u1rKkT2dRx2Fu0uXCLUh57iZFOND+UWo6rjSd epjErHrYaCb/4VXomppcHbVe2zE47XMQxyFvfL47ILnkC2qZ1k78h02J0T195snA jX68jyr3SnNcdaidZ+gRAsNidHxjxN8WOXNlZ8= Received: (qmail 13700 invoked by alias); 18 May 2016 21:57:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 13663 invoked by uid 89); 18 May 2016 21:57:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:__stati, 2422, 3846 X-HELO: mail-yw0-f174.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=N5392tauIV5lqRD5mElCfVQ9wRwlgD8CBB0DThn3Uz8=; b=POyWXMzbKKuurE80NykQLvq75mPHKrcts1z5B5rUNZdQzuCmiIP+iVCCYWcnOcc9uF 0JZjmJsTesMiGrVGGisTf7rkriNgL/oGrQLHNiVMhdRkNxeNI2wzXfiMqPulMwID5cx+ 24Hu6NfUzBbadChWjvLSodq5Gj9dbYoITDlI8nzUmeUHddDekr8dbVo5j5stG6KHux2F g+xc0TFayUZFtUwX1leSA/XmWRwPX/VBj/06dsb5LZSQolFJn83YJT0La4UKU6kPaui3 hBhtP7rTpu0yDKcQuJI+aZ+93npPm0Edqe4iM6rnVHxaKiB524H8gtbqwpguWnGp7ha1 mV3A== X-Gm-Message-State: AOPr4FXsUF0VqDjCN3/qaq7jZ/vLjeSkgIWNqJSrloYzPvTFxaScRMf8aOvQUDgJPODbsaBP X-Received: by 10.13.233.1 with SMTP id s1mr5268660ywe.286.1463608646999; Wed, 18 May 2016 14:57:26 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/3] Remove __ASSUME_SET_ROBUST_LIST Date: Wed, 18 May 2016 18:57:17 -0300 Message-Id: <1463608638-7215-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1463608638-7215-1-git-send-email-adhemerval.zanella@linaro.org> References: <1463608638-7215-1-git-send-email-adhemerval.zanella@linaro.org> 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 | 22 ++++++++++++++++++++++ nptl/nptl-init.c | 11 ++--------- nptl/pthreadP.h | 2 -- nptl/pthread_create.c | 8 +------- nptl/pthread_mutex_init.c | 2 -- sysdeps/unix/sysv/linux/arm/kernel-features.h | 1 - sysdeps/unix/sysv/linux/kernel-features.h | 5 ----- sysdeps/unix/sysv/linux/m68k/kernel-features.h | 1 - sysdeps/unix/sysv/linux/mips/kernel-features.h | 1 - sysdeps/unix/sysv/linux/sparc/kernel-features.h | 1 - 10 files changed, 25 insertions(+), 29 deletions(-) -- 2.7.4 diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index bdbdfed..cad14c7 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -48,14 +48,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. */ @@ -328,7 +322,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)); @@ -336,8 +330,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 diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 4edc74b..d479a3e 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -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; diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index a834063..c3f4087 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -271,10 +271,7 @@ START_THREAD_DEFN if (__glibc_unlikely (atomic_exchange_acq (&pd->setxid_futex, 0) == -2)) futex_wake (&pd->setxid_futex, 1, FUTEX_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; @@ -419,7 +414,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. */ diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c index 6e5acb6..6aef890 100644 --- a/nptl/pthread_mutex_init.c +++ b/nptl/pthread_mutex_init.c @@ -91,11 +91,9 @@ __pthread_mutex_init (pthread_mutex_t *mutex, 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; } diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h index 6ca607e..4012751 100644 --- a/sysdeps/unix/sysv/linux/arm/kernel-features.h +++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h @@ -24,7 +24,6 @@ configuration. */ #if __LINUX_KERNEL_VERSION < 0x030E03 # undef __ASSUME_REQUEUE_PI -# undef __ASSUME_SET_ROBUST_LIST #endif /* Define this if your 32-bit syscall API requires 64-bit register diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 43b72b1..45edad5 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -59,11 +59,6 @@ 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 diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h index 9e7f0e1..bec9539 100644 --- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h +++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h @@ -52,5 +52,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 diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h index 09d5ece..3640b5f 100644 --- a/sysdeps/unix/sysv/linux/mips/kernel-features.h +++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h @@ -25,7 +25,6 @@ emulating LL/SC. */ #if __mips == 1 || defined _MIPS_ARCH_R5900 # undef __ASSUME_REQUEUE_PI -# undef __ASSUME_SET_ROBUST_LIST #endif /* Define this if your 32-bit syscall API requires 64-bit register diff --git a/sysdeps/unix/sysv/linux/sparc/kernel-features.h b/sysdeps/unix/sysv/linux/sparc/kernel-features.h index 69c9c7c..dc7c4aa 100644 --- a/sysdeps/unix/sysv/linux/sparc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sparc/kernel-features.h @@ -35,5 +35,4 @@ futex_atomic_cmpxchg_inatomic. */ #if !defined __arch64__ && !defined __sparc_v9__ # undef __ASSUME_REQUEUE_PI -# undef __ASSUME_SET_ROBUST_LIST #endif