You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
2 years ago
|
commit ed8300c054cae4aeb0bbfa043f5fccc91a4adbf5
|
||
|
Author: H.J. Lu <hjl.tools@gmail.com>
|
||
|
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 <szabolcs.nagy@arm.com>
|
||
|
(cherry picked from commit 49302b8fdf9103b6fc0a398678668a22fa19574c)
|
||
|
|
||
|
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
|
||
|
index 11ad7005d07afc6e..90cede9446e33fcf 100644
|
||
|
--- a/nptl/pthread_mutex_timedlock.c
|
||
|
+++ b/nptl/pthread_mutex_timedlock.c
|
||
|
@@ -234,12 +234,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;
|