Skip to content

Commit

Permalink
Repeat black list check on CAS fail in stack_push_explicit_aux_release
Browse files Browse the repository at this point in the history
(a cherry-pick of commit ae0f8e7 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).
  • Loading branch information
ivmai committed Aug 12, 2022
1 parent 53892ba commit 410ca73
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/atomic_ops_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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)));
}

/*
Expand Down

0 comments on commit 410ca73

Please sign in to comment.