[v6,08/10] test/test-pmd: declare lcore_count atomic

Message ID 1740414265-12217-9-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Accepted
Delegated to: David Marchand
Headers
Series enable "app" to be compiled with MSVC |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Feb. 24, 2025, 4:24 p.m. UTC
Compiling with MSVC results in the error below:

app/test/test_ring_perf.c(197): error C7712: address argument to atomic
    operation must be a pointer to an atomic integer,
    'volatile unsigned int *' is not valid

The fix is to mark lcore_count as atomic.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
---
 app/test/test_ring_perf.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
  

Patch

diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index 57cd04a124..9a2a481458 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -34,7 +34,7 @@  struct lcore_pair {
 	unsigned c1, c2;
 };
 
-static volatile unsigned lcore_count = 0;
+static RTE_ATOMIC(unsigned int) lcore_count;
 
 static void
 test_ring_print_test_string(unsigned int api_type, int esize,
@@ -193,13 +193,10 @@  enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)
 	unsigned int n_remaining;
 	const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i];
 
-#ifdef RTE_USE_C11_MEM_MODEL
-	if (rte_atomic_fetch_add_explicit(&lcore_count, 1, rte_memory_order_relaxed) + 1 != 2)
-#else
-	if (__sync_add_and_fetch(&lcore_count, 1) != 2)
-#endif
-		while(lcore_count != 2)
+	if (rte_atomic_fetch_add_explicit(&lcore_count, 1, rte_memory_order_relaxed) + 1 != 2) {
+		while (rte_atomic_load_explicit(&lcore_count, rte_memory_order_relaxed) != 2)
 			rte_pause();
+	}
 
 	burst = test_ring_calloc(MAX_BURST, p->ring_params->elem_size);
 	if (burst == NULL)
@@ -272,7 +269,7 @@  run_on_core_pair(struct lcore_pair *cores,
 	struct ring_params *ring_params = param1->ring_params;
 
 	for (i = 0; i < RTE_DIM(bulk_sizes); i++) {
-		lcore_count = 0;
+		rte_atomic_store_explicit(&lcore_count, 0, rte_memory_order_relaxed);
 		ring_params->bulk_sizes_i = i;
 		if (cores->c1 == rte_get_main_lcore()) {
 			rte_eal_remote_launch(dequeue_bulk, param2, cores->c2);