diff mbox series

[v3,6/8] test/mempool_perf: use compiler atomics for lcores sync

Message ID 20210720035125.14214-7-joyce.kong@arm.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers show
Series use compiler atomic builtins for test | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Joyce Kong July 20, 2021, 3:51 a.m. UTC
Convert rte_atomic usages to compiler atomic built-ins for lcores
sync in mempool_perf testcases. Meanwhile, remove unnecessary
synchro init as it would be set to 0 when launching cores.

Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_mempool_perf.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/app/test/test_mempool_perf.c b/app/test/test_mempool_perf.c
index d7d0aaa334..8f629736e8 100644
--- a/app/test/test_mempool_perf.c
+++ b/app/test/test_mempool_perf.c
@@ -20,7 +20,6 @@ 
 #include <rte_eal.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
-#include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_mempool.h>
 #include <rte_spinlock.h>
@@ -83,7 +82,7 @@ 
 static int use_external_cache;
 static unsigned external_cache_size = RTE_MEMPOOL_CACHE_MAX_SIZE;
 
-static rte_atomic32_t synchro;
+static uint32_t synchro;
 
 /* number of objects in one bulk operation (get or put) */
 static unsigned n_get_bulk;
@@ -145,7 +144,7 @@  per_lcore_mempool_test(void *arg)
 
 	/* wait synchro for workers */
 	if (lcore_id != rte_get_main_lcore())
-		while (rte_atomic32_read(&synchro) == 0);
+		rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED);
 
 	start_cycles = rte_get_timer_cycles();
 
@@ -198,7 +197,7 @@  launch_cores(struct rte_mempool *mp, unsigned int cores)
 	int ret;
 	unsigned cores_save = cores;
 
-	rte_atomic32_set(&synchro, 0);
+	__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
 
 	/* reset stats */
 	memset(stats, 0, sizeof(stats));
@@ -223,7 +222,7 @@  launch_cores(struct rte_mempool *mp, unsigned int cores)
 	}
 
 	/* start synchro and launch test on main */
-	rte_atomic32_set(&synchro, 1);
+	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
 
 	ret = per_lcore_mempool_test(mp);
 
@@ -288,8 +287,6 @@  test_mempool_perf(void)
 	const char *default_pool_ops;
 	int ret = -1;
 
-	rte_atomic32_init(&synchro);
-
 	/* create a mempool (without cache) */
 	mp_nocache = rte_mempool_create("perf_test_nocache", MEMPOOL_SIZE,
 					MEMPOOL_ELT_SIZE, 0, 0,