This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Add GLIBC_PTHREAD_ELISION_ENABLE tunable
- From: "Paul E. Murphy" <murphyp at linux dot vnet dot ibm dot com>
- To: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, "Carlos O'Donell" <carlos at redhat dot com>, Steve Munroe <sjmunroe at us dot ibm dot com>, Tulio Magno Quites Machado Filho <tuliom at linux dot vnet dot ibm dot com>, stli at linux dot vnet dot ibm dot com
- Cc: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Date: Fri, 11 Sep 2015 14:57:20 -0500
- Subject: [PATCH] Add GLIBC_PTHREAD_ELISION_ENABLE tunable
- Authentication-results: sourceware.org; auth=none
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 <murphyp@linux.vnet.ibm.com>
* 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 */
--
1.7.1