From patchwork Tue Dec 13 08:54:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 87809 Delivered-To: patch@linaro.org Received: by 10.182.112.6 with SMTP id im6csp2090371obb; Tue, 13 Dec 2016 00:55:22 -0800 (PST) X-Received: by 10.84.133.129 with SMTP id f1mr191378397plf.64.1481619322406; Tue, 13 Dec 2016 00:55:22 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id a96si47361840pli.200.2016.12.13.00.55.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Dec 2016 00:55:22 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-75823-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-75823-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-75823-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:mime-version:content-type :message-id; q=dns; s=default; b=IGMxLrxI6Zr2NOUKzPGjAaYD/C2g3zb Z2xCXS238yilFNEayTMnSFhW7APa5apkfbwo80XINoM/5YZFRmspe76iSqo8xEno ok18039b8rDIZUAAltGOSgklr3Hd5C/sltj/R8gR73nMoEXaTkRjLM/AwRMhEk47 FsR/y/oXnQlU= 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:to:from:subject:date:mime-version:content-type :message-id; s=default; bh=wwrA5zTbSccJdMy/OUlJF9ywjFk=; b=DU0DI p7lkXV13o5+JSFS/Ii+jDv0Rah2UdKU56wQQDSAY6rAdN32GBBnNaeQOnQobekJN AlXrREeKKK0u+FBo9l9UsRAJUZ1afzH+33/rO1+npCmY6c3+9U5yz7zqeHbHv3XV 3ghkPg7KPvl9Hgci4paItuFJiluBy/eYr2SoTQ= Received: (qmail 440 invoked by alias); 13 Dec 2016 08:55:11 -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 130706 invoked by uid 89); 13 Dec 2016 08:55:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=acquired, jumps X-HELO: mx0a-001b2d01.pphosted.com To: libc-alpha@sourceware.org From: Stefan Liebler Subject: [PATCH] Add __glibc_unlikely hint in lll_trylock, lll_cond_trylock. Date: Tue, 13 Dec 2016 09:54:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16121308-0020-0000-0000-00000246BA2A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16121308-0021-0000-0000-00001EA83CFE Message-Id: <4adc080f-9975-4ee0-003e-675f3c9f1203@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-13_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612130155 Hi, the macros lll_trylock, lll_cond_trylock are extended by a __glibc_unlikely hint. Now the trylock macros are based on the same assumption about a free/busy lock as lll_lock. With the hint gcc emits code in e.g. pthread_mutex_trylock which does not use jumps if the lock is free. Without the hint it had to jump away if the lock is free. Tested on s390x, ppc. Okay to commit? Bye Stefan ChangeLog: * sysdeps/nptl/lowlevellock.h (lll_trylock, lll_cond_trylock): Add __glibc_unlikely hint. commit 2e11862aaf6d563518780a470b97b59a6e0b2717 Author: Stefan Liebler Date: Tue Dec 13 09:14:09 2016 +0100 Add __glibc_unlikely hint in lll_trylock, lll_cond_trylock. The macros lll_trylock, lll_cond_trylock are extended by an __glibc_unlikely hint. Now the trylock macros are based on the same assumption about a free/busy lock as lll_lock. With the hint gcc emits code in e.g. pthread_mutex_trylock which does not use jumps if the lock is free. Without the hint it had to jump away if the lock is free. Tested on s390x, ppc. ChangeLog: * sysdeps/nptl/lowlevellock.h (lll_trylock, lll_cond_trylock): Add __glibc_unlikely hint. diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h index 3890145..b77043b 100644 --- a/sysdeps/nptl/lowlevellock.h +++ b/sysdeps/nptl/lowlevellock.h @@ -64,13 +64,13 @@ 0. Otherwise leave lock unchanged and return non-zero to indicate that the lock was not acquired. */ #define lll_trylock(lock) \ - atomic_compare_and_exchange_bool_acq (&(lock), 1, 0) + __glibc_unlikely (atomic_compare_and_exchange_bool_acq (&(lock), 1, 0)) /* If LOCK is 0 (not acquired), set to 2 (acquired, possibly with waiters) and return 0. Otherwise leave lock unchanged and return non-zero to indicate that the lock was not acquired. */ #define lll_cond_trylock(lock) \ - atomic_compare_and_exchange_bool_acq (&(lock), 2, 0) + __glibc_unlikely (atomic_compare_and_exchange_bool_acq (&(lock), 2, 0)) extern void __lll_lock_wait_private (int *futex) attribute_hidden; extern void __lll_lock_wait (int *futex, int private) attribute_hidden;