From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7852) id 469F4385C8B1; Thu, 29 Sep 2022 18:41:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 469F4385C8B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664476889; bh=GDbnhd0gr5tE+J2K0gfiNr11vBnNbxuMgxE5EvFsS2M=; h=From:To:Subject:Date:From; b=GRIm7rsUZtzzoCnQhffVYXb+VNxCPxpayd7yYFp2EPQHJ2p0XbqwN3y5+mQ/LZoJe OYjMhtM/5ius+uQe9YHwRc25R2IE2ZppH14vcZJ2UOBg4rKg8qDecFxysaMbmP7H5m LV/els/zl325y6kM2oLH1qN20xvofNxcpiuUoIR0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Sunil Pandey To: glibc-cvs@sourceware.org Subject: [glibc/users/skpgkp2/2.33/master] Avoid extra load with CAS in __pthread_mutex_clocklock_common [BZ #28537] X-Act-Checkin: glibc X-Git-Author: H.J. Lu X-Git-Refname: refs/heads/users/skpgkp2/2.33/master X-Git-Oldrev: f5a70409db67f3a5f035d9d6082d11efcc74910d X-Git-Newrev: 0ec276739a22c0305263941b5213e8c368269ec0 Message-Id: <20220929184129.469F4385C8B1@sourceware.org> Date: Thu, 29 Sep 2022 18:41:29 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0ec276739a22c0305263941b5213e8c368269ec0 commit 0ec276739a22c0305263941b5213e8c368269ec0 Author: H.J. Lu Date: Thu Nov 11 06:54:01 2021 -0800 Avoid extra load with CAS in __pthread_mutex_clocklock_common [BZ #28537] Replace boolean CAS with value CAS to avoid the extra load. Reviewed-by: Szabolcs Nagy (cherry picked from commit 49302b8fdf9103b6fc0a398678668a22fa19574c) Diff: --- nptl/pthread_mutex_timedlock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 8428ebca0f..541ec18938 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -247,12 +247,12 @@ __pthread_mutex_clocklock_common (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) { - oldval = mutex->__data.__lock; + oldval = val; continue; } oldval |= FUTEX_WAITERS;