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]

[RFC] Dynamic lock elision support


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
diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
index 5341222..157b987 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
@@ -56,12 +56,33 @@ int __pthread_force_elision attribute_hidden;
 
 static void
 elision_init (int argc __attribute__ ((unused)),
-	      char **argv  __attribute__ ((unused)),
-	      char **environ)
+              char **argv  __attribute__ ((unused)),
+              char **environ)
 {
 #ifdef ENABLE_LOCK_ELISION
+  char *elide_env = getenv ("NPTL_ENABLE_ELISION");
+  bool  enable_elision = elide_env && !(elide_env[0] == '0' && elide_env[1] == 0);
   int elision_available = (GLRO (dl_hwcap2) & PPC_FEATURE2_HAS_HTM) ? 1 : 0;
   __pthread_force_elision = __libc_enable_secure ? 0 : elision_available;
+
+  /* Only force elision if the user has requested it */
+  __pthread_force_elision = __pthread_force_elision && enable_elision;
+
+  /* Allow the paramater to supply tuning values */
+  if (enable_elision) {
+    sscanf (elide_env,
+            "%d,%d,%d,%d,%d",
+            &__elision_aconf.skip_lock_busy,
+            &__elision_aconf.skip_lock_internal_abort,
+            &__elision_aconf.skip_lock_out_of_tbegin_retries,
+            &__elision_aconf.try_tbegin,
+            &__elision_aconf.skip_trylock_internal_abort);
+
+    /* Explicitly disable elision if try_tbegin is 0
+       Not all elision code will respect a 0 value */
+    if (!__elision_aconf.try_tbegin)
+      __pthread_force_elision = 0;
+  }
 #endif
   if (!__pthread_force_elision)
     /* Disable elision on rwlocks.  */

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