[PATCH 03/17] stack: use previous value atomic fetch operations

Tyler Retzlaff roretzla at linux.microsoft.com
Thu Mar 2 01:47:34 CET 2023


Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch when we have no interest in the
result of the operation.

Reduces unnecessary codegen that provided the result of the atomic
operation that was not used.

Change brings closer alignment with atomics available in C11 standard
and will reduce review effort when they are integrated.

Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
---
 lib/stack/rte_stack_lf_c11.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/stack/rte_stack_lf_c11.h b/lib/stack/rte_stack_lf_c11.h
index 8403196..687a6f6 100644
--- a/lib/stack/rte_stack_lf_c11.h
+++ b/lib/stack/rte_stack_lf_c11.h
@@ -66,7 +66,7 @@
 	/* Ensure the stack modifications are not reordered with respect
 	 * to the LIFO len update.
 	 */
-	__atomic_add_fetch(&list->len, num, __ATOMIC_RELEASE);
+	__atomic_fetch_add(&list->len, num, __ATOMIC_RELEASE);
 }
 
 static __rte_always_inline struct rte_stack_lf_elem *
-- 
1.8.3.1



More information about the dev mailing list