From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7852) id 9540C3857BAE; Wed, 28 Sep 2022 19:11:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9540C3857BAE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664392271; bh=7R8VPpIIJdpc+bPnZmuBZ8orezhzbHOSxLP1p6SnW7A=; h=From:To:Subject:Date:From; b=DxxcQd6wwxhUnO4kLWL9dkBi688PVJLii34yXE8JfGAexSF0eeqyc4MMCaDWKoN5J nBv9r9dVuCqNnFgJrSf5CjHZG+7GmsLHWjnHjhXUXQxsb6GDfsVdfKr7PjA/WXqMmz gBEehpHca6iZG1a56pSHblyEN3Nb+dSLdgyH/Tds= 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] Move assignment out of the CAS condition X-Act-Checkin: glibc X-Git-Author: H.J. Lu X-Git-Refname: refs/heads/users/skpgkp2/2.33/master X-Git-Oldrev: 2b5fe38920c435db3ee6d62be0212a8f6a63efef X-Git-Newrev: 520639f146eecc5baee7b0a9fc8fc3f416bcbd68 Message-Id: <20220928191111.9540C3857BAE@sourceware.org> Date: Wed, 28 Sep 2022 19:11:11 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=520639f146eecc5baee7b0a9fc8fc3f416bcbd68 commit 520639f146eecc5baee7b0a9fc8fc3f416bcbd68 Author: H.J. Lu Date: Fri Nov 12 11:47:42 2021 -0800 Move assignment out of the CAS condition Update commit 49302b8fdf9103b6fc0a398678668a22fa19574c 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. and commit 0b82747dc48d5bf0871bdc6da8cb6eec1256355f Author: H.J. Lu Date: Thu Nov 11 06:31:51 2021 -0800 Avoid extra load with CAS in __pthread_mutex_lock_full [BZ #28537] Replace boolean CAS with value CAS to avoid the extra load. by moving assignment out of the CAS condition. (cherry picked from commit 120ac6d238825452e8024e2f627da33b2508dfd3) Diff: --- nptl/pthread_mutex_lock.c | 7 +++---- nptl/pthread_mutex_timedlock.c | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index ac8a472c08..2895926953 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -296,10 +296,9 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) meantime. */ if ((oldval & FUTEX_WAITERS) == 0) { - int val; - if ((val = atomic_compare_and_exchange_val_acq - (&mutex->__data.__lock, oldval | FUTEX_WAITERS, - oldval)) != oldval) + int val = atomic_compare_and_exchange_val_acq + (&mutex->__data.__lock, oldval | FUTEX_WAITERS, oldval); + if (val != oldval) { oldval = val; continue; diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 541ec18938..22174f74c9 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -247,10 +247,9 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, meantime. */ if ((oldval & FUTEX_WAITERS) == 0) { - int val; - if ((val = atomic_compare_and_exchange_val_acq - (&mutex->__data.__lock, oldval | FUTEX_WAITERS, - oldval)) != oldval) + int val = atomic_compare_and_exchange_val_acq + (&mutex->__data.__lock, oldval | FUTEX_WAITERS, oldval); + if (val != oldval) { oldval = val; continue;