From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id 0C5AA385782A for ; Fri, 12 Nov 2021 18:50:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C5AA385782A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nefkom.net Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HrSMv4Tdxz1sHHf; Fri, 12 Nov 2021 19:50:51 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HrSMv3kPyz1qqkZ; Fri, 12 Nov 2021 19:50:51 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id p1DV_9U5TzlJ; Fri, 12 Nov 2021 19:50:50 +0100 (CET) X-Auth-Info: hbAj54JXQ0IKRcuOpC//tjmUpzKiYCLkuqMs/lrrij8XJeYdzsoiLwXNjVZojEVA Received: from igel.home (ppp-46-244-178-12.dynamic.mnet-online.de [46.244.178.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 12 Nov 2021 19:50:50 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id 3D2802C3936; Fri, 12 Nov 2021 19:50:50 +0100 (CET) From: Andreas Schwab To: "H.J. Lu" Cc: libc-alpha@sourceware.org, Florian Weimer , Oleh Derevenko , Arjan van de Ven , "Paul A . Clarke" , Noah Goldstein Subject: Re: [PATCH v6 2/4] Avoid extra load with CAS in __pthread_mutex_lock_full [BZ #28537] References: <20211111162428.2286605-1-hjl.tools@gmail.com> <20211111162428.2286605-3-hjl.tools@gmail.com> X-Yow: I left my WALLET in the BATHROOM!! Date: Fri, 12 Nov 2021 19:50:50 +0100 In-Reply-To: <20211111162428.2286605-3-hjl.tools@gmail.com> (H. J. Lu's message of "Thu, 11 Nov 2021 08:24:26 -0800") Message-ID: <87zgq9rywl.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Nov 2021 18:50:54 -0000 On Nov 11 2021, H.J. Lu wrote: > diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c > index 72058c719c..762059b230 100644 > --- a/nptl/pthread_mutex_lock.c > +++ b/nptl/pthread_mutex_lock.c > @@ -304,12 +304,12 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) > meantime. */ > if ((oldval & FUTEX_WAITERS) == 0) > { > - if (atomic_compare_and_exchange_bool_acq (&mutex->__data.__lock, > - oldval | FUTEX_WAITERS, > - oldval) > - != 0) > + int val; > + if ((val = atomic_compare_and_exchange_val_acq > + (&mutex->__data.__lock, oldval | FUTEX_WAITERS, > + oldval)) != oldval) Please move the assignment out of the condition. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."