From patchwork Fri Sep 11 19:57:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 517003 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 ACBA914012C for ; Sat, 12 Sep 2015 05:57:37 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=mwC55Ire; dkim-atps=neutral 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:subject:to:cc:message-id:date :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=gRdzffoMwYE8i/aCqoDt0AG0FbssFl7wB6KD2SFJk1m/1+AKsg9/V pPLnSjq8gdRGK4kA7IdIVyRlSZkf2UxegOOXUBspbmERW8s4cEeg9A2Sl91xMopG /Ja/dvcM/YGTdy/zok7efpFwnWzHFlpGi1oBHHYXzU2l5VCjxmGKQI= 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:subject:to:cc:message-id:date :mime-version:content-type:content-transfer-encoding; s=default; bh=W24okTBtsrFlTaRwyln7AvwyKhk=; b=mwC55IreChsTLrH37yleqzyCJvxW B3vWKERnq31nsX07Z4eqFNeBxira7Wyv3Bm2Spojv1RseTkAgTpUxKmyrQcBbEok tRamD8qY1cgf6h3zyhOevBGiO4neU9rrDxhYARcgpaCz+2QMb21wiL0fRCYnex7r e5SUiNnaPmChC7E= Received: (qmail 23241 invoked by alias); 11 Sep 2015 19:57:29 -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 23230 invoked by uid 89); 11 Sep 2015 19:57:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: e18.ny.us.ibm.com X-MailFrom: murphyp@linux.vnet.ibm.com X-RcptTo: libc-alpha@sourceware.org From: "Paul E. Murphy" Subject: [PATCH] Add GLIBC_PTHREAD_ELISION_ENABLE tunable To: "libc-alpha@sourceware.org" , "Carlos O'Donell" , Steve Munroe , Tulio Magno Quites Machado Filho , stli@linux.vnet.ibm.com Cc: Adhemerval Zanella Message-ID: <55F33220.8050105@linux.vnet.ibm.com> Date: Fri, 11 Sep 2015 14:57:20 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15091119-0045-0000-0000-00000161D988 Some related discussions below: https://sourceware.org/ml/libc-alpha/2015-09/msg00128.html https://sourceware.org/ml/libc-alpha/2015-09/msg00065.html https://sourceware.org/ml/libc-alpha/2015-09/msg00130.html ---8<--- This tunable controls the usage of transactional lock elision within the nptl. This also defines a new manual section to describe the tunable, and any future tunables. powerpc now disables TLE by default, and uses the tunable to optionally enable the feature if desired. 2015-09-09 Paul E. Murphy * manual/Makefile (chapters): Add tunables.texi. * manual/into.texi: Add reference to Tunables. * manual/probes.texi: Enforce tunables.texi chapter location. * manual/tunables.texi: New file. * sysdeps/unix/sysv/linux/powerpc/elision-conf.c (elision-init): Add tunable to enable elision. * sysdeps/unix/sysv/linux/390/elision-conf.c (elision-init): Add tunable to disable Likewise. * sysdeps/unix/sysv/linux/x86/elision-conf.c (elision-init): Likewise. --- manual/Makefile | 3 +- manual/intro.texi | 3 ++ manual/probes.texi | 2 +- manual/tunables.texi | 36 ++++++++++++++++++++++++ sysdeps/unix/sysv/linux/powerpc/elision-conf.c | 6 +++- sysdeps/unix/sysv/linux/s390/elision-conf.c | 5 +++ sysdeps/unix/sysv/linux/x86/elision-conf.c | 5 +++ 7 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 manual/tunables.texi diff --git a/manual/Makefile b/manual/Makefile index cdb6763..6b2adb0 100644 --- a/manual/Makefile +++ b/manual/Makefile @@ -38,7 +38,8 @@ chapters = $(addsuffix .texi, \ message search pattern io stdio llio filesys \ pipe socket terminal syslog math arith time \ resource setjmp signal startup process ipc job \ - nss users sysinfo conf crypt debug threads probes) + nss users sysinfo conf crypt debug threads probes\ + tunables) add-chapters = $(wildcard $(foreach d, $(add-ons), ../$d/$d.texi)) appendices = lang.texi header.texi install.texi maint.texi platform.texi \ contrib.texi diff --git a/manual/intro.texi b/manual/intro.texi index d4045f2..bcd4f5b 100644 --- a/manual/intro.texi +++ b/manual/intro.texi @@ -1475,6 +1475,9 @@ various operating system limits. Most of these parameters are provided for compatibility with POSIX. @item +@ref{Tunables}, describes the tunables and their usage. + +@item @ref{Language Features}, contains information about library support for standard parts of the C language, including things like the @code{sizeof} operator and the symbolic constant @code{NULL}, how to write functions diff --git a/manual/probes.texi b/manual/probes.texi index 7dd56d8..110dc8d 100644 --- a/manual/probes.texi +++ b/manual/probes.texi @@ -1,5 +1,5 @@ @node Internal Probes -@c @node Internal Probes, , POSIX Threads, Top +@c @node Internal Probes, Tunables, POSIX Threads, Top @c %MENU% Probes to monitor libc internal behavior @chapter Internal probes diff --git a/manual/tunables.texi b/manual/tunables.texi new file mode 100644 index 0000000..140fc99 --- /dev/null +++ b/manual/tunables.texi @@ -0,0 +1,36 @@ +@node Tunables +@c @node Tunables, , , Top +@c %MENU% Available tuning parameters +@chapter Tunables + +This chapter describes the @glibcadj{} tunables available to the user. + +A tunable is an environment variable prefixed with GLIBC_ which may alter +the performance characteristics of a feature provided by the @glibcadj{}. It +should be noted that tunables behave as any other environment variable. Thus +the user is cautioned about the effects these may have when inherited. + +@strong{Warning}, tunables are not part of the @glibcadj{} stable ABI, and they +are subject to change or removal across releases. + +@menu +* POSIX Thread Tunables:: Tunables controlling the default behavior of pthreads +@end menu + +@node POSIX Thread Tunables +@section POSIX Thread Tunables + +@subsection @code{GLIBC_PTHREAD_ELISION_ENABLE} +This variable controls whether transactional lock elision is enabled at +runtime. This feature may not be available on all platforms, and requires a +library explicitly built with support. The default state of this tunable is +dependent on the architecture and the configuration of the library. For +instance, powerpc will not elide locks without explicitly setting this +tunable. The following values are honored by this variable: + +@table @code +@item yes +Enable lock elision if supported by the hardware and underlying platform +@item no +Disable all usage of lock elision +@end table diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c index 5341222..13d5b6d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c +++ b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c @@ -61,7 +61,11 @@ elision_init (int argc __attribute__ ((unused)), { #ifdef ENABLE_LOCK_ELISION int elision_available = (GLRO (dl_hwcap2) & PPC_FEATURE2_HAS_HTM) ? 1 : 0; - __pthread_force_elision = __libc_enable_secure ? 0 : elision_available; + + /* Check environment to see if we should enable LE. */ + for (; *environ != NULL; environ++) + if (strcmp (*environ, "GLIBC_PTHREAD_ELISION_ENABLE=yes") == 0) + __pthread_force_elision = __libc_enable_secure ? 0 : elision_available; #endif if (!__pthread_force_elision) /* Disable elision on rwlocks. */ diff --git a/sysdeps/unix/sysv/linux/s390/elision-conf.c b/sysdeps/unix/sysv/linux/s390/elision-conf.c index e1ff599..f50df9f 100644 --- a/sysdeps/unix/sysv/linux/s390/elision-conf.c +++ b/sysdeps/unix/sysv/linux/s390/elision-conf.c @@ -64,6 +64,11 @@ elision_init (int argc __attribute__ ((unused)), When false elision is never attempted. */ int elision_available = (GLRO (dl_hwcap) & HWCAP_S390_TE) ? 1 : 0; + /* Check environment to see if we should disable LE. */ + for (; *environ != NULL; environ++) + if (strcmp (*environ, "GLIBC_PTHREAD_ELISION_ENABLE=no") == 0) + __pthread_force_elision = 0; + __pthread_force_elision = __libc_enable_secure ? 0 : elision_available; } diff --git a/sysdeps/unix/sysv/linux/x86/elision-conf.c b/sysdeps/unix/sysv/linux/x86/elision-conf.c index 4a73382..73cd37e 100644 --- a/sysdeps/unix/sysv/linux/x86/elision-conf.c +++ b/sysdeps/unix/sysv/linux/x86/elision-conf.c @@ -65,6 +65,11 @@ elision_init (int argc __attribute__ ((unused)), __elision_available = HAS_CPU_FEATURE (RTM); #ifdef ENABLE_LOCK_ELISION __pthread_force_elision = __libc_enable_secure ? 0 : __elision_available; + + /* Check environment to see if we should disable LE. */ + for (; *environ != NULL; environ++) + if (strcmp (*environ, "GLIBC_PTHREAD_ELISION_ENABLE=no") == 0) + __pthread_force_elision = 0; #endif if (!HAS_CPU_FEATURE (RTM)) __elision_aconf.retry_try_xbegin = 0; /* Disable elision on rwlocks */