diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-11-11 06:54:01 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-11-12 10:31:31 -0800 |
commit | 49302b8fdf9103b6fc0a398678668a22fa19574c (patch) | |
tree | 1b06b2062260382deeea33957e840e6792fa23eb | |
parent | 0b82747dc48d5bf0871bdc6da8cb6eec1256355f (diff) | |
download | glibc-49302b8fdf9103b6fc0a398678668a22fa19574c.tar glibc-49302b8fdf9103b6fc0a398678668a22fa19574c.tar.gz glibc-49302b8fdf9103b6fc0a398678668a22fa19574c.tar.bz2 glibc-49302b8fdf9103b6fc0a398678668a22fa19574c.zip |
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>
-rw-r--r-- | nptl/pthread_mutex_timedlock.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 57f3f28869..f763cfc7fa 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -233,12 +233,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; |