[v2,1/7] ring: replace rte atomics with GCC builtin atomics
Checks
Commit Message
Replace the use of rte_atomic.h types and functions, instead use GCC
supplied C++11 memory model builtins.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/ring/rte_ring_core.h | 1 -
lib/ring/rte_ring_generic_pvt.h | 12 ++++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
@@ -31,7 +31,6 @@
#include <rte_config.h>
#include <rte_memory.h>
#include <rte_lcore.h>
-#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_memzone.h>
#include <rte_pause.h>
@@ -92,8 +92,10 @@
if (is_sp)
r->prod.head = *new_head, success = 1;
else
- success = rte_atomic32_cmpset(&r->prod.head,
- *old_head, *new_head);
+ // NOTE: review for potential ordering optimization
+ success = __atomic_compare_exchange_n(&r->prod.head,
+ old_head, *new_head, 0,
+ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
} while (unlikely(success == 0));
return n;
}
@@ -162,8 +164,10 @@
rte_smp_rmb();
success = 1;
} else {
- success = rte_atomic32_cmpset(&r->cons.head, *old_head,
- *new_head);
+ // NOTE: review for potential ordering optimization
+ success = __atomic_compare_exchange_n(&r->cons.head,
+ old_head, *new_head, 0,
+ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
}
} while (unlikely(success == 0));
return n;