From patchwork Wed May 18 21:57:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 68061 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2869341qge; Wed, 18 May 2016 14:58:09 -0700 (PDT) X-Received: by 10.66.112.34 with SMTP id in2mr14330518pab.52.1463608689077; Wed, 18 May 2016 14:58:09 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b66si14738375pfa.42.2016.05.18.14.58.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 May 2016 14:58:09 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-69693-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-69693-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-69693-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; q=dns; s= default; b=hPWI/E7AFpMtrTbSd2nSd3fvMyp0JWkrnMzKIgAIRXTKINxuLCrn4 9tTNL1HapJ5J5JHgWFOofSN7woUV9uCWoqw3/46777GzHFfHYmwoLQg6Me7ALJtW OcEgQo4oyYW4ETf+NY7oECtDuR7UgppZf98iuSKczh0MdCesnlYe90= 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=1wr8gdF3nHeFIK/87yYxvI2JXEk=; b=kS8mgUXD8uZz9xiqcT6hTN8b8geU PXy1vqGJxfEvemLImY8Zt9FWyAWRK2+8RVWBs6Qlc2eC/ogoUnbMV2uEBB5LFHYg ExtaR+EokviaSmNan4sdnyInB7az3QItpk6fIo4JC7LyUHPaqVE/wJ+xT7Gxuy20 Zu49IdebHgLWRJg= Received: (qmail 13781 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 13658 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= X-HELO: mail-yw0-f180.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; bh=4lDsg1sm82vdNxoS7ktIwbXKeM0+3rJk0Qd7HUWrnt4=; b=MFiDGHOOU4zMBUo7LoV8jr+VJNunewaUqhbKKt7UB8kgWSCTsKunniHusxcUSms8tF 98fSY2QXLiZewJBYOEHnMtsBks44TkRc1avEz/JZ/z7PENN1lcBxIQqiu+qBp8ruPEtF R9cjX+pMJyrL1nxr2dszHcKhihANIksjaQRT5eg1k/3+CL1NpNO2w4TTMLKMbbxSLT7J jLVqXD8Yg38czeiWW9ulYEwq4hGytG4pYcuXlE3Iw0zSO39iDJcfrSOvZDfvGLEhAh3N B/BEoaaD5stE3zbnlwxKqItjUHTR6LCaDWbD7+52gEhOLnKzZLfFWP56dgGchoYA0jxS RxDg== X-Gm-Message-State: AOPr4FXK/2JTg7BMKuGusW67SCY8kDb/cpN5/nGxCt14l/hDnLhVG0w9JTRX/e2thrDolkwq X-Received: by 10.37.117.193 with SMTP id q184mr5385386ybc.72.1463608645804; Wed, 18 May 2016 14:57:25 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/3] Remove __ASSUME_FUTEX_LOCK_PI Date: Wed, 18 May 2016 18:57:16 -0300 Message-Id: <1463608638-7215-1-git-send-email-adhemerval.zanella@linaro.org> 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 | 15 +++++++++++++++ nptl/pthread_mutex_init.c | 3 --- sysdeps/unix/sysv/linux/arm/kernel-features.h | 1 - sysdeps/unix/sysv/linux/kernel-features.h | 4 ---- 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 - 7 files changed, 15 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c index 71ac7bc..6e5acb6 100644 --- a/nptl/pthread_mutex_init.c +++ b/nptl/pthread_mutex_init.c @@ -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; } diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h index 0a9ed77..6ca607e 100644 --- a/sysdeps/unix/sysv/linux/arm/kernel-features.h +++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h @@ -23,7 +23,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 diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 5a1b204..43b72b1 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -64,10 +64,6 @@ 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 diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h index 646bc4b..9e7f0e1 100644 --- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h +++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h @@ -51,7 +51,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 diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h index e831645..09d5ece 100644 --- a/sysdeps/unix/sysv/linux/mips/kernel-features.h +++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h @@ -24,7 +24,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 diff --git a/sysdeps/unix/sysv/linux/sparc/kernel-features.h b/sysdeps/unix/sysv/linux/sparc/kernel-features.h index 386f230..69c9c7c 100644 --- a/sysdeps/unix/sysv/linux/sparc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sparc/kernel-features.h @@ -34,7 +34,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