From a598afba59272191e36b80f6e760bfa9b9b21e53 Mon Sep 17 00:00:00 2001 From: Joyce Kong Date: Wed, 17 Nov 2021 08:21:49 +0000 Subject: [PATCH] test/pmd_perf: use compiler atomic builtins for polling sync Convert rte_atomic usages to compiler atomic built-ins for polling sync in pmd_perf test cases. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang --- app/test/test_pmd_perf.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index aac6c97ceb..0aa9dc1b1c 100644 --- a/app/test/test_pmd_perf.c +++ b/app/test/test_pmd_perf.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include "packet_burst_generator.h" #include "test.h" @@ -525,7 +524,7 @@ main_loop(__rte_unused void *args) return 0; } -static rte_atomic64_t start; +static uint64_t start; static inline int poll_burst(void *args) @@ -563,8 +562,7 @@ poll_burst(void *args) num[portid] = pkt_per_port; } - while (!rte_atomic64_read(&start)) - ; + rte_wait_until_equal_64(&start, 1, __ATOMIC_ACQUIRE); cur_tsc = rte_rdtsc(); while (total) { @@ -616,16 +614,19 @@ exec_burst(uint32_t flags, int lcore) pkt_per_port = MAX_TRAFFIC_BURST; num = pkt_per_port * conf->nb_ports; - rte_atomic64_init(&start); + /* only when polling first */ + if (flags == SC_BURST_POLL_FIRST) + __atomic_store_n(&start, 1, __ATOMIC_RELAXED); + else + __atomic_store_n(&start, 0, __ATOMIC_RELAXED); - /* start polling thread, but not actually poll yet */ + /* start polling thread + * if in POLL_FIRST mode, poll once launched; + * otherwise, not actually poll yet + */ rte_eal_remote_launch(poll_burst, (void *)&pkt_per_port, lcore); - /* Only when polling first */ - if (flags == SC_BURST_POLL_FIRST) - rte_atomic64_set(&start, 1); - /* start xmit */ i = 0; while (num) { @@ -641,7 +642,7 @@ exec_burst(uint32_t flags, int lcore) /* only when polling second */ if (flags == SC_BURST_XMIT_FIRST) - rte_atomic64_set(&start, 1); + __atomic_store_n(&start, 1, __ATOMIC_RELEASE); /* wait for polling finished */ diff_tsc = rte_eal_wait_lcore(lcore); -- 2.20.1