DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: stable@dpdk.org, Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH] test: fix race in per lcore test
Date: Mon, 17 Mar 2025 15:30:15 +0100	[thread overview]
Message-ID: <20250317143015.2559854-1-david.marchand@redhat.com> (raw)

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


                 reply	other threads:[~2025-03-17 14:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250317143015.2559854-1-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=roretzla@linux.microsoft.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).