From patchwork Mon Sep 29 19:55:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 394620 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3363A14007B for ; Tue, 30 Sep 2014 05:55:30 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:content-type:content-transfer-encoding; q=dns; s= default; b=OgsnCZRqiYOj5dFhF9V0VaSzV2jGc8qwiHocyGuCTIsSaRt+T8KMB 1wloYFU3cvyleqzLe7OXSjMBSxNuPCfDtkAS5SZZQAzeZP604dYztWPboCOdaIhZ yhF1hKPHL1SzSEJnNNadpZD6aRjAVVDt22bUdjVOngNUcLPAa+jXkI= 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:message-id:date:from:mime-version:to:cc :subject:content-type:content-transfer-encoding; s=default; bh=l vlh1T+jUWlxfRguSrlHdbi4rIg=; b=SVKF/DtJ8hW31n3sAPcBZz8yJG4Gco8J9 N0xoL4MTopt5jr2T76cA+XPvvRanaeubw+LU5owwLtetSJ0Cz/3eTHTmjm7DqAbD oKt29O48IKFbk68yuL5Aoio25Awnob0D23Hc5Vzq3SDYRg9tztSHKHE+3GOQ53C3 dxWdXrFCqs= Received: (qmail 7224 invoked by alias); 29 Sep 2014 19:55:25 -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 7176 invoked by uid 89); 29 Sep 2014 19:55:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, URIBL_BLACK autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Message-ID: <5429B916.4040303@redhat.com> Date: Mon, 29 Sep 2014 15:55:02 -0400 From: "Carlos O'Donell" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: GNU C Library , Andreas Krebbel CC: Andi Kleen , Siddhesh Poyarekar Subject: [PATCH] Elision, both for s390 and x86_64, should be enabled via --enable-lock-elision=yes. Andreas, All lock elision enablement should be controlled by the --enable-lock-elision configure option. I have already written to Andi about this, and he agreed that it's OK for x86_64, and is what we agreed upon at the global level for glibc. Would you agree that this is also OK for s390? The goal is to be able to enable or disable lock elision for all architectures with a single configure option. I understand that this is slightly different from what we do for other features that we simply detect and use. We do it this way for elision to give distributions the flexibility because this feature is quite new and has potential side-effects that perhaps might only be best enabled in a newer version of the distribution. It also gives users the ability to disable it if it's causing problems for applications that are important to their use cases, but that don't work well with elision. In the long term I expect that runtime tunnables will be useful in enabling or disabling elision on a per-application basis. OK to commit for s390? 2014-09-29 Carlos O'Donell * configure.ac: --enable-lock-elision enables or disables all elision for locks, not just mutexes. * configure: Regenerate. * sysdeps/unix/sysv/linux/s390/elision-conf.c (elision_init) [!ENABLE_LOCK_ELISION]: Set __pthread_force_elision to zero. * sysdeps/unix/sysv/linux/x86/elision-conf.c (elision_init) [!ENABLE_LOCK_ELISION]: Set __pthread_force_elision, __elision_available, and __elision_aconf.retry_try_xbegin to zero. diff --git a/configure b/configure index 89566c5..9a9cf08 100755 --- a/configure +++ b/configure @@ -1413,7 +1413,7 @@ Optional Features: initialize __stack_chk_guard canary with a random number at program start --enable-lock-elision=yes/no - Enable lock elision for pthread mutexes by default + Enable hardware lock elision by default --enable-add-ons[=DIRS...] configure and build add-ons in DIR1,DIR2,... search for add-ons if no parameter given diff --git a/configure.ac b/configure.ac index 82d0896..d113772 100644 --- a/configure.ac +++ b/configure.ac @@ -169,7 +169,7 @@ fi AC_ARG_ENABLE([lock-elision], AC_HELP_STRING([--enable-lock-elision[=yes/no]], - [Enable lock elision for pthread mutexes by default]), + [Enable hardware lock elision by default]), [enable_lock_elision=$enableval], [enable_lock_elision=no]) AC_SUBST(enable_lock_elision) diff --git a/sysdeps/unix/sysv/linux/s390/elision-conf.c b/sysdeps/unix/sysv/linux/s390/elision-conf.c index 69c0483..852433e 100644 --- a/sysdeps/unix/sysv/linux/s390/elision-conf.c +++ b/sysdeps/unix/sysv/linux/s390/elision-conf.c @@ -60,11 +60,16 @@ elision_init (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)), char **environ) { +#ifdef ENABLE_LOCK_ELISION /* Set when the CPU and the kernel supports transactional execution. When false elision is never attempted. */ int elision_available = (GLRO (dl_hwcap) & HWCAP_S390_TE) ? 1 : 0; __pthread_force_elision = __libc_enable_secure ? 0 : elision_available; +#else + /* This configuration has elision disabled. */ + __pthread_force_elision = 0; +#endif } #ifdef SHARED diff --git a/sysdeps/unix/sysv/linux/x86/elision-conf.c b/sysdeps/unix/sysv/linux/x86/elision-conf.c index 28e48d9..abc42b7 100644 --- a/sysdeps/unix/sysv/linux/x86/elision-conf.c +++ b/sysdeps/unix/sysv/linux/x86/elision-conf.c @@ -62,12 +62,17 @@ elision_init (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)), char **environ) { - __elision_available = HAS_RTM; #ifdef ENABLE_LOCK_ELISION + __elision_available = HAS_RTM; __pthread_force_elision = __libc_enable_secure ? 0 : __elision_available; -#endif if (!HAS_RTM) - __elision_aconf.retry_try_xbegin = 0; /* Disable elision on rwlocks */ + __elision_aconf.retry_try_xbegin = 0; /* Disable elision on rwlocks. */ +#else + /* This configuration has elision disabled. */ + __elision_available = 0; + __pthread_force_elision = 0; + __elision_aconf.retry_try_xbegin = 0; +#endif } #ifdef SHARED