From patchwork Tue Aug 18 16:10:00 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: 8272 Received: (qmail 120524 invoked by alias); 18 Aug 2015 16:10:12 -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 120427 invoked by uid 89); 18 Aug 2015 16:10:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, 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 Message-ID: <55D358D8.7020303@linux.vnet.ibm.com> Date: Tue, 18 Aug 2015 11:10:00 -0500 From: "Paul E. Murphy" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: "libc-alpha@sourceware.org" Subject: [RFC] Dynamic lock elision support X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15081816-0045-0000-0000-0000011300D7 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. */