From 4773be58753ab83711f9fba871dc67b8a87fc516 Mon Sep 17 00:00:00 2001 From: Joyce Kong Date: Wed, 13 Oct 2021 13:54:06 -0500 Subject: [PATCH] examples/server_node_efd: use compiler atomics for sync Convert rte_atomic32_test_and_set to compiler CAS atomic operation for display_stats sync. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang --- examples/server_node_efd/server/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/server_node_efd/server/main.c b/examples/server_node_efd/server/main.c index 0d0d5679e4..fd72882e3a 100644 --- a/examples/server_node_efd/server/main.c +++ b/examples/server_node_efd/server/main.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -178,10 +177,12 @@ static int sleep_lcore(__rte_unused void *dummy) { /* Used to pick a display thread - static, so zero-initialised */ - static rte_atomic32_t display_stats; + static uint32_t display_stats; /* Only one core should display stats */ - if (rte_atomic32_test_and_set(&display_stats)) { + uint32_t display_init = 0; + if (__atomic_compare_exchange_n(&display_stats, &display_init, 1, 0, + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) { const unsigned int sleeptime = 1; printf("Core %u displaying statistics\n", rte_lcore_id()); -- 2.20.1