diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-11-11 06:31:51 -0800 |
---|---|---|
committer | Sunil K Pandey <skpgkp2@gmail.com> | 2022-09-28 13:47:04 -0700 |
commit | f5a70409db67f3a5f035d9d6082d11efcc74910d (patch) | |
tree | 76e4991b0005ae0627b2b3ffa6a6ffca4655387f | |
parent | da7afc97ad9ddc817686d61f046277166ef42644 (diff) | |
download | glibc-f5a70409db67f3a5f035d9d6082d11efcc74910d.tar.gz glibc-f5a70409db67f3a5f035d9d6082d11efcc74910d.tar.xz glibc-f5a70409db67f3a5f035d9d6082d11efcc74910d.zip |
Avoid extra load with CAS in __pthread_mutex_lock_full [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 0b82747dc48d5bf0871bdc6da8cb6eec1256355f)
-rw-r--r-- | nptl/pthread_mutex_lock.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index 319658adc4..0fd7467b97 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -289,12 +289,12 @@ __pthread_mutex_lock_full (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; |