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: 508384 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 9335914007F for ; Wed, 19 Aug 2015 02:10:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=szkyIWx7; 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:message-id:date:from:mime-version:to:subject :content-type; q=dns; s=default; b=pWN3aTVEGBxu9Wtn/regnd8GW6UHd WsTNePznfEQdhqEoO7HEloGyIQ7Yp44DeVEHc8dCOxlRuc+J93te+6lHN4YTvWur GmEdQirFjS+IGbv/JB3lOIkGATGtAB6dWXhWvK3ZhCCsSDQ/X0OhiK18OWDj/xZ3 SFU5x8i69YG+jY= 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:message-id:date:from:mime-version:to:subject :content-type; s=default; bh=t5dvco4JMfM9ZfJxTQN19Z2KsO8=; b=szk yIWx79apVD05YK0dyIY6KjgHc83YmDpIQyIMiMP9xvG2Zmj4oGCbJTAnbk/dewgC OgqZGI+0sJie6nY4Vj1OT03kcq0GMvcVcBAleh71yvMxfULbwFbp6UihCFES9bLh OcEpgoFPEWRNbCEHuP05cIzttN1X7qF9oGtmzg14= 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. */