This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFCv2] Dynamic lock elision support


Narrowing my focus here, we should have a runtime
mechanism to disable elision for those applications
which experience significant degradation from the
non-optional nature of this feature.

I think we can table the discussion of runtime
tunable parameters as it is highly dependent on the
framework which emerges.

In the meantime, there is a need to turn this
off for select workloads. It would be preferable
to add this in such a way that it can be easily
merged into the tunables framework when it
does evolve.

--
Paul M.


On 08/18/2015 11:46 AM, Adhemerval Zanella wrote:
> Hi,
> 
> Andi Kleen has sent some patches to add tunables for lock elision with
> NPTL algorithms:
> 
> http://patchwork.sourceware.org/patch/4358/
> http://patchwork.sourceware.org/patch/4355/
> http://patchwork.sourceware.org/patch/4356/
> http://patchwork.sourceware.org/patch/4359/
> http://patchwork.sourceware.org/patch/4357/
> http://patchwork.sourceware.org/patch/4361/
> http://patchwork.sourceware.org/patch/4360/
> 
> But he has not yet ping or followed up with these.  I also would prefer
> to add tunable to be as platform agnostic as possible, since we have
> 3 architectures that support LE (x86, ppc, zarch).  So I would suggest
> you work on this options and/or adjust the patch on these.
> 
> Also, we may want to avoid a configure flag and enable LE support as
> default for powerpc, but disable as default (enabled through env. vars
> as Andi Kleen patchset).
> 
> On 18-08-2015 13:10, Paul E. Murphy wrote:
>> Elided locks can have mixed overall performance in practice. That is, there is some non-trivial tuning a user might have to do to see the positive benefits. Additionally, when tuning the adaptive lock constants on PPC, my experimentation seems to correlate tuned values with both the number of hardware threads per core, and the behavior of the application.
>>
>> My initial thought is elision should be disabled by default, with an environment variable to toggle both support, and potentially override tuning constants.
>>
>> Paul
>>
> 

>From 78373b09b201ce840ad164d911ee7017f59070f7 Mon Sep 17 00:00:00 2001
From: Paul E. Murphy <murphyp@linux.vnet.ibm.com>
Date: Thu, 27 Aug 2015 18:04:59 -0500
Subject: [PATCH] [RFCv2] Optionally disable TLE

It may be desirable to disable TLE.  While we wait out the
tunables framework, it may be helpeful to have an env var
to turn it off if it is discovered to hamper performance.

My hope is this degenerate usage can be trivially ported
to the tunables framework when it arrives.

This defines the environment variable GLIBC_LOCK_ELISION.
If it is set to "none", will disable TLE for all archs which
support it.

2015-08-28  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>

	* sysdeps/unix/sysv/linux/powerpc/elision-conf.c (elision_init):
	Disable based on env var set to "none".
	* sysdeps/unix/sysv/linux/s390/elision-conf.c (elision_init):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/elision-conf.c (elision_init):
	Likewise.
---
 sysdeps/unix/sysv/linux/powerpc/elision-conf.c |    5 +++++
 sysdeps/unix/sysv/linux/s390/elision-conf.c    |    5 +++++
 sysdeps/unix/sysv/linux/x86/elision-conf.c     |    5 +++++
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
index 5341222..30a3bfd 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
@@ -62,6 +62,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 disable LE */
+  for (; *environ != NULL; environ++)
+    if (strcmp (*environ, "GLIBC_LOCK_ELISION=none") == 0)
+      __pthread_force_elision = 0;
 #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..5fcb343 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_LOCK_ELISION=none") == 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..6690304 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_LOCK_ELISION=none") == 0)
+      __pthread_force_elision = 0;
 #endif
   if (!HAS_CPU_FEATURE (RTM))
     __elision_aconf.retry_try_xbegin = 0; /* Disable elision on rwlocks */
-- 
1.7.1



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]