From patchwork Mon Aug 11 14:26:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernard Ogden X-Patchwork-Id: 379001 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 0CD6E140143 for ; Tue, 12 Aug 2014 00:22:49 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Y4iVETKVgB0lRI4uqwBsTyrkKEcPXz1 fB4N4+IHBxIqdHH5W25hH3+VLMFujWXx92/Oz99b4z44hhkwhg3B1T9flM1S4qlL kF2b7kLj6bmi7f68tVObUvdoNDT/DgXy/SZHX21PYVDiu6bStb+7/FICSM95VB7N v2amYGEg+/GQ= 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:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=zj+viELLQ/zQUshxmmmkZ3qhFZ4=; b=svD4d aUvoQInZ2uRQX9aAVNkAfDIB+fdRHRvcCGHLku3ZMtCzTVckbw2Kr96G/7nQ279l NMGNNBbIt7ktVi8T6xbBLjc/enTMCRIK7TndYXb8oVfgQroSfWtr6moR2T0N8hN1 m5waUxS+y/1g0FqPTBO96WxBuZSvaYr7nKa/bE= Received: (qmail 27279 invoked by alias); 11 Aug 2014 14:22:44 -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 27267 invoked by uid 89); 11 Aug 2014 14:22:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f43.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lkNEMvCskd9rDstDYDzZHftbkPocD+BDOn6C4wcTszk=; b=E/fFh1wBq+EKWcmp4l1wqH0uKH1Z79pQBQOas5tsbF6lW8w3nnqfZEkBEPJRakJUtR dmpNqYSjQ5EkWHFT7dBnyZRSafZLZt3B42Gs/9N3u1wx+A601JhApjt2az7xsZqNfGXS HRdL8DUxxxQOOHiVLyjCkNr9fwB6v8nh5iNaqhySDc6mFmuTyGftXqshQAGNx4Rx0aNj osMDtPkEdoi+VJyOgHxK10lHVSHAOaXiLGvnuRfN1ylUdxfhkOOPWN5fVFywlg6ozTBr MfPdsU8IDVwtyDo1bxn+zwwUCd7soArgmkH4yjqaMnhNJc3IFpzETYWfJQsoFGORvhdN tWYQ== X-Gm-Message-State: ALoCoQnFGtTiDAmQlexKq7QrUjUJf8yL16sEBgLZAbJHMN3cyAwRl/221pYlHiLaZSbpu5gQFwnm X-Received: by 10.180.108.13 with SMTP id hg13mr26563116wib.28.1407766959255; Mon, 11 Aug 2014 07:22:39 -0700 (PDT) From: Bernard Ogden To: will.newton@linaro.org, roland@hack.frob.com, libc-alpha@sourceware.org Cc: Bernard Ogden Subject: [PATCH] [BZ #16892] Check value of futex before updating in __lll_timedlock Date: Mon, 11 Aug 2014 15:26:48 +0100 Message-Id: <1407767208-20900-1-git-send-email-bernie.ogden@linaro.org> In-Reply-To: References: Retrying with git send-email. Patch unchanged other than whitespace fix. 2014-08-07 Bernard Ogden [BZ #16892] * sysdeps/nptl/lowlevellock.h (__lll_timedlock): Use atomic_compare_and_exchange_bool_acq rather than atomic_exchange_acq. diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h index 548a9c8..28f4ba3 100644 --- a/sysdeps/nptl/lowlevellock.h +++ b/sysdeps/nptl/lowlevellock.h @@ -88,12 +88,15 @@ extern int __lll_timedlock_wait (int *futex, const struct timespec *, extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *, int private) attribute_hidden; +/* Take futex if it is untaken. + Otherwise block until either we get the futex or abstime runs out. */ #define __lll_timedlock(futex, abstime, private) \ ({ \ int *__futex = (futex); \ int __val = 0; \ \ - if (__glibc_unlikely (atomic_exchange_acq (__futex, 1))) \ + if (__glibc_unlikely \ + (atomic_compare_and_exchange_bool_acq (__futex, 1, 0))) \ __val = __lll_timedlock_wait (__futex, abstime, private); \ __val; \ })