|
|
190885 |
From 77950da440c2b12c153b77ab8b4d1d00c88ca3a9 Mon Sep 17 00:00:00 2001
|
|
|
190885 |
From: "H.J. Lu" <hjl.tools@gmail.com>
|
|
|
190885 |
Date: Fri, 12 Nov 2021 11:47:42 -0800
|
|
|
190885 |
Subject: [PATCH] Move assignment out of the CAS condition
|
|
|
190885 |
|
|
|
190885 |
Update
|
|
|
190885 |
|
|
|
190885 |
commit 49302b8fdf9103b6fc0a398678668a22fa19574c
|
|
|
190885 |
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
|
190885 |
Date: Thu Nov 11 06:54:01 2021 -0800
|
|
|
190885 |
|
|
|
190885 |
Avoid extra load with CAS in __pthread_mutex_clocklock_common [BZ #28537]
|
|
|
190885 |
|
|
|
190885 |
Replace boolean CAS with value CAS to avoid the extra load.
|
|
|
190885 |
|
|
|
190885 |
and
|
|
|
190885 |
|
|
|
190885 |
commit 0b82747dc48d5bf0871bdc6da8cb6eec1256355f
|
|
|
190885 |
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
|
190885 |
Date: Thu Nov 11 06:31:51 2021 -0800
|
|
|
190885 |
|
|
|
190885 |
Avoid extra load with CAS in __pthread_mutex_lock_full [BZ #28537]
|
|
|
190885 |
|
|
|
190885 |
Replace boolean CAS with value CAS to avoid the extra load.
|
|
|
190885 |
|
|
|
190885 |
by moving assignment out of the CAS condition.
|
|
|
190885 |
|
|
|
190885 |
(cherry picked from commit 120ac6d238825452e8024e2f627da33b2508dfd3)
|
|
|
190885 |
---
|
|
|
190885 |
nptl/pthread_mutex_lock.c | 7 +++----
|
|
|
190885 |
nptl/pthread_mutex_timedlock.c | 7 +++----
|
|
|
190885 |
2 files changed, 6 insertions(+), 8 deletions(-)
|
|
|
190885 |
|
|
|
190885 |
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
|
|
|
190885 |
index eb4d8baa..a633d95e 100644
|
|
|
190885 |
--- a/nptl/pthread_mutex_lock.c
|
|
|
190885 |
+++ b/nptl/pthread_mutex_lock.c
|
|
|
190885 |
@@ -299,10 +299,9 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
|
|
|
190885 |
meantime. */
|
|
|
190885 |
if ((oldval & FUTEX_WAITERS) == 0)
|
|
|
190885 |
{
|
|
|
190885 |
- int val;
|
|
|
190885 |
- if ((val = atomic_compare_and_exchange_val_acq
|
|
|
190885 |
- (&mutex->__data.__lock, oldval | FUTEX_WAITERS,
|
|
|
190885 |
- oldval)) != oldval)
|
|
|
190885 |
+ int val = atomic_compare_and_exchange_val_acq
|
|
|
190885 |
+ (&mutex->__data.__lock, oldval | FUTEX_WAITERS, oldval);
|
|
|
190885 |
+ if (val != oldval)
|
|
|
190885 |
{
|
|
|
190885 |
oldval = val;
|
|
|
190885 |
continue;
|
|
|
190885 |
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
|
|
|
190885 |
index c4627ef6..a76c30b7 100644
|
|
|
190885 |
--- a/nptl/pthread_mutex_timedlock.c
|
|
|
190885 |
+++ b/nptl/pthread_mutex_timedlock.c
|
|
|
190885 |
@@ -269,10 +269,9 @@ __pthread_mutex_timedlock (pthread_mutex_t *mutex,
|
|
|
190885 |
meantime. */
|
|
|
190885 |
if ((oldval & FUTEX_WAITERS) == 0)
|
|
|
190885 |
{
|
|
|
190885 |
- int val;
|
|
|
190885 |
- if ((val = atomic_compare_and_exchange_val_acq
|
|
|
190885 |
- (&mutex->__data.__lock, oldval | FUTEX_WAITERS,
|
|
|
190885 |
- oldval)) != oldval)
|
|
|
190885 |
+ int val = atomic_compare_and_exchange_val_acq
|
|
|
190885 |
+ (&mutex->__data.__lock, oldval | FUTEX_WAITERS, oldval);
|
|
|
190885 |
+ if (val != oldval)
|
|
|
190885 |
{
|
|
|
190885 |
oldval = val;
|
|
|
190885 |
continue;
|
|
|
190885 |
--
|
|
|
190885 |
GitLab
|
|
|
190885 |
|