diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-02-20 10:51:25 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-08-12 09:54:27 +0300 |
commit | 410ca734fb864fc3989e01d48e34b5f224ae1465 (patch) | |
tree | 2ff03cb7ca96740431a9c218dd13d2c11c8aa2e8 | |
parent | 53892ba73e0b5d86dc0b7518a7ecd7cf95d386dd (diff) | |
download | libatomic_ops-410ca734fb864fc3989e01d48e34b5f224ae1465.tar.gz |
Repeat black list check on CAS fail in stack_push_explicit_aux_release
(a cherry-pick of commit ae0f8e7e4 from 'release-7_4')
Also, execute the first read in a loop with an acquire barrier, and
place black list checking as close to CAS as possible.
* src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE]
(AO_stack_push_explicit_aux_release): Use acquire barrier to read list
value (stored to next local variable); read list value and store it to
x element before iterating over AO_stack_bl (and, thus, retry iterating
over AO_stack_bl if CAS failed).
-rw-r--r-- | src/atomic_ops_stack.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/atomic_ops_stack.c b/src/atomic_ops_stack.c index d59fac9..e0778c4 100644 --- a/src/atomic_ops_stack.c +++ b/src/atomic_ops_stack.c @@ -56,6 +56,9 @@ AO_stack_push_explicit_aux_release(volatile AO_t *list, AO_t *x, /* No deletions of x can start here, since x is not currently in the */ /* list. */ retry: + do { + next = AO_load_acquire(list); + *x = next; # if AO_BL_SIZE == 2 { /* Start all loads as close to concurrently as possible. */ @@ -91,12 +94,7 @@ AO_stack_push_explicit_aux_release(volatile AO_t *list, AO_t *x, } # endif /* x_bits is not currently being deleted */ - do - { - next = AO_load(list); - *x = next; - } - while (AO_EXPECT_FALSE(!AO_compare_and_swap_release(list, next, x_bits))); + } while (AO_EXPECT_FALSE(!AO_compare_and_swap_release(list, next, x_bits))); } /* |