From patchwork Tue Apr 18 21:13:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 97581 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp32959qgf; Tue, 18 Apr 2017 14:13:44 -0700 (PDT) X-Received: by 10.84.211.77 with SMTP id b71mr9222567pli.83.1492550024191; Tue, 18 Apr 2017 14:13:44 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 31si262095plj.317.2017.04.18.14.13.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 14:13:44 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-78713-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-78713-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-78713-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=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; q=dns; s= default; b=rmoqSYsxHk8XMrT6K08qZw0EAAPySrj99s4iMPloP+zQzJKulDZ6+ u9iLE8vcd5j97i48FtI2NJOh2Qj8i63Y5YAwzAO9nKwLzQG4dmX+tajzZmw2zno/ nl6zKdlwDd0G1UCUBPcge1//rztgKUaj42rukbdI3nW4xbZuUmKqtc= 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; s=default; bh=3XCSj/lUcvjyQUHt0rmPTAHegTE=; b=XXCFy5eexuq9iZ+IZ9no6/V1JXh4 YYn4PImhLojh4y7jaFEDQpipGuSgx6379SJFPk+pxQbbQhmeOrVDiSu3sizf1U50 IDvW5GJy2Be1kXuiYOIP8hp95yvg410/Jlbb9/jz4Rc+5raSJFthNz1umxx5VStW WU3Me6IKCiqVVqw= Received: (qmail 41673 invoked by alias); 18 Apr 2017 21:13:32 -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 41644 invoked by uid 89); 18 Apr 2017 21:13:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f180.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=LMHepdZJmT83LgOKy6D1LLLL8yLn71GGoN75UnXBTCg=; b=JNaR0vMt08lg4wTXyuqAygMTpU1qC32PVtuT13HOCm4conbXtJCzjeM4ICyO8BmsxE rKVY6nRrLe8ekwI19ebT8GhXFsLV7i/m68UzQ9Li3Al4Lx9bO0R/e2Xzqv+d9Q9tkLO4 ZGUFnxcfXO/0A4xgszXg+n0UjqYT7PTLLktYnR5nzb9CRQ9EBgi48BYtC+6Tf/Y8Qb+W 4Kv5Ohia1p4S0YmdzTxHtjipeF8IL5JFNnb1BrSV29nBFSLhsCIeFN0Qx2rY6nrKW3a6 doRrhFPTY9O34OWv+oAxjWEDfcDJZr0qSU/f1JA/AhIhrxd2Vry9pc+H98lFv7WmGMeW 6/NA== X-Gm-Message-State: AN3rC/5UoFptOqjI9zeWgKZCA8EEwIV7Xd7TxVphFMWKoe5bVGzCqoZE dLgVlOVOe8/CKM+r+t/OVg== X-Received: by 10.237.35.134 with SMTP id j6mr13863659qtc.256.1492550009757; Tue, 18 Apr 2017 14:13:29 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/2] nptl: Remove __ASSUME_SET_ROBUST_LIST Date: Tue, 18 Apr 2017 18:13:19 -0300 Message-Id: <1492550000-31374-1-git-send-email-adhemerval.zanella@linaro.org> This is another patch that was in my backlog, so I am sending it again on the list since first version was send almost 5 months ago [1]. -- This patch removes the __ASSUME_SET_ROBUST_LIST usage on nptl generic code. The set_robust_list availability is defined by '__set_robust_list_avail' which is now defined regardless. Its initial value is set to -1 and defined to a positive value if both __NR_set_robust_list is defined and the syscall returns correctly. A subsequent patch is intended to remove the Linux definitions of __ASSUME_SET_ROBUST_LIST. Tested on x86_64. * nptl/nptl-init.c (set_robust_list_not_avail): Remove definition. (__pthread_initialize_minimal_internal): Set __set_robust_list_avail to 1 if syscall returns correctly. (__set_robust_list_avail): Define regardless if __ASSUME_SET_ROBUST_LIST is defined or not. * nptl/pthreadP.h (__set_robust_list_avail): Likewise. * nptl/pthread_create.c (START_THREAD_DEFN): Remove __ASSUME_SET_ROBUST_LIST usage. * nptl/pthread_mutex_init.c (__pthread_mutex_init): Likewise. [1] https://sourceware.org/ml/libc-alpha/2016-09/msg00373.html --- nptl/nptl-init.c | 12 +++--------- nptl/pthreadP.h | 2 -- nptl/pthread_create.c | 8 ++------ nptl/pthread_mutex_init.c | 2 -- 4 files changed, 5 insertions(+), 19 deletions(-) -- 2.7.4 diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 2921607..c86b35e 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 +int __set_robust_list_avail = -1; #ifndef __ASSUME_FUTEX_CLOCK_REALTIME /* Nonzero if we do not have FUTEX_CLOCK_REALTIME. */ @@ -308,9 +302,9 @@ __pthread_initialize_minimal_internal (void) INTERNAL_SYSCALL_DECL (err); int res = INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head, sizeof (struct robust_list_head)); - if (INTERNAL_SYSCALL_ERROR_P (res, err)) + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) + __set_robust_list_avail = 1; #endif - set_robust_list_not_avail (); } #ifdef __NR_futex diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 7fc1e50..4125e7f 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -213,10 +213,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 d0d7414..76b0ac4 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -387,18 +387,16 @@ 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 { +#ifdef __NR_set_robust_list INTERNAL_SYSCALL_DECL (err); /* This call should never fail because the initial call in init.c succeeded. */ 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 @@ -508,7 +506,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; @@ -539,7 +536,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 138e144..18724e8 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; } From patchwork Tue Apr 18 21:13:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 97582 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp33011qgf; Tue, 18 Apr 2017 14:13:54 -0700 (PDT) X-Received: by 10.99.178.6 with SMTP id x6mr20345369pge.80.1492550033955; Tue, 18 Apr 2017 14:13:53 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y21si259767pgh.394.2017.04.18.14.13.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 14:13:53 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-78714-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-78714-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-78714-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=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=G58EZgkclsBUmXcRkTqhaplBwjHruL/ CmoyPl6oe/USTju0YB213LeTQC5VmQ4HZwUNJ18VzrHHhs94AMHLMKQwwWzWOOrv xreejkcKz+TPAQHQuOEPt6SwyoT/hFYyPbneqg1IBdC80FLyQ7AG746akls8vcDH 7maQRr5O8N7Q= 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=7UFdfoGEXfrzSTZZ6hMmZjEUszU=; b=xRiYB lzzMdrh236QihPkoPwUv0lXtsQ1hghYBWcSGMXxjtCPvJMobne9LZWPIW3MuySh0 3lUCv7nJZTi23jS/v61oNge3yeYuhK1fjNLzkDM4xqlY50etoROn4PxfCFCesj8q ZkeYMJujPTLvGRCXeWfDNbOxNEqqObgRrsg7YA= Received: (qmail 41685 invoked by alias); 18 Apr 2017 21:13:33 -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 41654 invoked by uid 89); 18 Apr 2017 21:13:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=2420 X-HELO: mail-qt0-f181.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=J5YGlnWhoiukUk6cSleHBfIZZDRKfQjTBo89JRxmGPc=; b=Jb8zSYAI4xX4MiB48emM04jxyeYsbwgufDFmAR8Fh48m8LSbfTogGkcEoJBYX7ymzq kvwRgp4JBn89Up+LJBTVVkxueYYRhuaM3/CxoAs4OrSiGX0X19y2VjxeMy+b5eT/kIdU thzfyKk6ju1/RvpYGdi7brQLdSyf4UnqJmvaafm5KG0SDD62Gf9A1o2PvpqDWHHYC4Ph L3N0rUF76OSu4jZIbETwPZXXahfl8N/bWrfuOKGp8jwbDVNJlglA6pUZbYpjp87LYFJ3 +nfxjGo/iQW4J1HAqq8bj1z92bT2NmlRZMwdNJos4xyJmOPZB2vDD4rfsHQNyL90Tepq BDjg== X-Gm-Message-State: AN3rC/5ikJypOReBzUqinwheeJBxK/TUe+b42O5FrPOQ7QJoG08v2kbn dO5c6nbXa61cI6yuG3Whiw== X-Received: by 10.200.43.146 with SMTP id m18mr9893746qtm.210.1492550011147; Tue, 18 Apr 2017 14:13:31 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/2] linux: Remove __ASSUME_SET_ROBUST_LIST defines Date: Tue, 18 Apr 2017 18:13:20 -0300 Message-Id: <1492550000-31374-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1492550000-31374-1-git-send-email-adhemerval.zanella@linaro.org> References: <1492550000-31374-1-git-send-email-adhemerval.zanella@linaro.org> As for the first part, I am sending this patch again. The onyl change was to rebase again master after __ASSUME_REQUEUE_PI removal (2e4cf77897). -- 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. * 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. --- sysdeps/unix/sysv/linux/arm/kernel-features.h | 7 ------- sysdeps/unix/sysv/linux/kernel-features.h | 5 ----- sysdeps/unix/sysv/linux/mips/kernel-features.h | 6 ------ sysdeps/unix/sysv/linux/sparc/kernel-features.h | 6 ------ 4 files changed, 24 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h index e13b049..1edd988 100644 --- a/sysdeps/unix/sysv/linux/arm/kernel-features.h +++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h @@ -19,13 +19,6 @@ #include_next -/* The ARM kernel before 3.14.3 may or may not support - futex_atomic_cmpxchg_inatomic, depending on kernel - configuration. */ -#if __LINUX_KERNEL_VERSION < 0x030E03 -# undef __ASSUME_SET_ROBUST_LIST -#endif - /* ARM fadvise64_64 reorganize the syscall arguments. */ #define __ASSUME_FADVISE64_64_6ARG 1 diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 233e302..2a25eb6 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/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h index d5d35af..9d533aa 100644 --- a/sysdeps/unix/sysv/linux/mips/kernel-features.h +++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h @@ -21,12 +21,6 @@ #include_next -/* The MIPS kernel does not support futex_atomic_cmpxchg_inatomic if - emulating LL/SC. */ -#if __mips == 1 || defined _MIPS_ARCH_R5900 -# undef __ASSUME_SET_ROBUST_LIST -#endif - /* Define this if your 32-bit syscall API requires 64-bit register pairs to start with an even-number register. */ #if _MIPS_SIM == _ABIO32 diff --git a/sysdeps/unix/sysv/linux/sparc/kernel-features.h b/sysdeps/unix/sysv/linux/sparc/kernel-features.h index c833201..7dc8f11 100644 --- a/sysdeps/unix/sysv/linux/sparc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sparc/kernel-features.h @@ -31,12 +31,6 @@ #include_next -/* 32-bit SPARC kernels do not support - futex_atomic_cmpxchg_inatomic. */ -#if !defined __arch64__ && !defined __sparc_v9__ -# undef __ASSUME_SET_ROBUST_LIST -#endif - #if !defined __arch64__ # undef __ASSUME_ACCEPT_SYSCALL # undef __ASSUME_CONNECT_SYSCALL