From 0df8e2d2c9ac4d38c6d4c27c0e865c1695e5348d Mon Sep 17 00:00:00 2001 From: Steven Lariau Date: Fri, 25 Sep 2020 18:43:35 +0100 Subject: [PATCH] stack: fix inconsistent weak/strong CAS Fix cmpexchange usage of weak / strong. The generated code is the same on x86 and ARM (there is no weak cmpexchange), but the old usage was inconsistent. For push and pop update size, weak is used because cmpexchange is inside a loop. For pop update root, strong is used even though cmpexchange is inside a loop, because there may be a lot of operations to do in a loop iteration (locate the new head). Signed-off-by: Steven Lariau Reviewed-by: Dharmik Thakkar Reviewed-by: Ruifeng Wang Acked-by: Gage Eads --- lib/librte_stack/rte_stack_lf_c11.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_stack/rte_stack_lf_c11.h b/lib/librte_stack/rte_stack_lf_c11.h index 999359f081..1e0ea0bef4 100644 --- a/lib/librte_stack/rte_stack_lf_c11.h +++ b/lib/librte_stack/rte_stack_lf_c11.h @@ -96,7 +96,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list, /* len is updated on failure */ if (__atomic_compare_exchange_n(&list->len, &len, len - num, - 0, __ATOMIC_ACQUIRE, + 1, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) break; } @@ -149,7 +149,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list, (rte_int128_t *)&list->head, (rte_int128_t *)&old_head, (rte_int128_t *)&new_head, - 1, __ATOMIC_RELEASE, + 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED); } while (success == 0); -- 2.20.1