DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] test: fix race in per lcore test
@ 2025-03-17 14:30 David Marchand
  0 siblings, 0 replies; only message in thread
From: David Marchand @ 2025-03-17 14:30 UTC (permalink / raw)
  To: dev; +Cc: stable, Tyler Retzlaff

In some CI, this unit test can fail, as the main thread may get
rescheduled while lcores execute the callback waiting 100ms.

Bugzilla ID: 1668
Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 app/test/test_per_lcore.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/app/test/test_per_lcore.c b/app/test/test_per_lcore.c
index 63c5c80c24..9c72f0fa21 100644
--- a/app/test/test_per_lcore.c
+++ b/app/test/test_per_lcore.c
@@ -59,17 +59,29 @@ display_vars(__rte_unused void *arg)
 }
 
 static int
-test_per_lcore_delay(__rte_unused void *arg)
+test_per_lcore_delay(void *arg)
 {
+	RTE_ATOMIC(bool) *wait;
+
 	rte_delay_ms(100);
 	printf("wait 100ms on lcore %u\n", rte_lcore_id());
 
+	if (arg == NULL)
+		return 0;
+
+	wait = arg;
+	while (rte_atomic_load_explicit(wait, rte_memory_order_relaxed)) {
+		rte_delay_ms(100);
+		printf("wait 100ms on lcore %u\n", rte_lcore_id());
+	}
+
 	return 0;
 }
 
 static int
 test_per_lcore(void)
 {
+	RTE_ATOMIC(bool) wait = true;
 	unsigned lcore_id;
 	int ret;
 
@@ -86,7 +98,7 @@ test_per_lcore(void)
 	}
 
 	/* test if it could do remote launch twice at the same time or not */
-	ret = rte_eal_mp_remote_launch(test_per_lcore_delay, NULL, SKIP_MAIN);
+	ret = rte_eal_mp_remote_launch(test_per_lcore_delay, &wait, SKIP_MAIN);
 	if (ret < 0) {
 		printf("It fails to do remote launch but it should able to do\n");
 		return -1;
@@ -97,6 +109,7 @@ test_per_lcore(void)
 		printf("It does remote launch successfully but it should not at this time\n");
 		return -1;
 	}
+	rte_atomic_store_explicit(&wait, false, rte_memory_order_relaxed);
 	RTE_LCORE_FOREACH_WORKER(lcore_id) {
 		if (rte_eal_wait_lcore(lcore_id) < 0)
 			return -1;
-- 
2.48.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-17 14:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-17 14:30 [PATCH] test: fix race in per lcore test David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).