From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org, david.marchand@redhat.com, dmitry.kozliuk@gmail.com
Cc: Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH 2/2] test: enable lcores test on Windows
Date: Mon, 5 Dec 2022 16:39:29 -0800 [thread overview]
Message-ID: <1670287169-15325-3-git-send-email-roretzla@linux.microsoft.com> (raw)
In-Reply-To: <1670287169-15325-1-git-send-email-roretzla@linux.microsoft.com>
Stop using pthread and convert the test to use EAL thread APIs. Because
the EAL thread APIs provide more than just a stub for thread join on
Windows the tests now pass and need not be skipped.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
app/test/test_lcores.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index a6bb412..5b43aa5 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -8,17 +8,18 @@
#include <rte_common.h>
#include <rte_errno.h>
#include <rte_lcore.h>
+#include <rte_thread.h>
#include "test.h"
struct thread_context {
enum { Thread_INIT, Thread_ERROR, Thread_DONE } state;
bool lcore_id_any;
- pthread_t id;
+ rte_thread_t id;
unsigned int *registered_count;
};
-static void *thread_loop(void *arg)
+static uint32_t thread_loop(void *arg)
{
struct thread_context *t = arg;
unsigned int lcore_id;
@@ -55,7 +56,7 @@ static void *thread_loop(void *arg)
if (t->state != Thread_ERROR)
t->state = Thread_DONE;
- return NULL;
+ return 0;
}
static int
@@ -77,7 +78,7 @@ static void *thread_loop(void *arg)
t->state = Thread_INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
break;
non_eal_threads_count++;
}
@@ -96,7 +97,7 @@ static void *thread_loop(void *arg)
t->state = Thread_INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) == 0) {
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) == 0) {
non_eal_threads_count++;
printf("non-EAL threads count: %u\n", non_eal_threads_count);
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -110,7 +111,7 @@ static void *thread_loop(void *arg)
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != Thread_DONE)
ret = -1;
}
@@ -262,7 +263,7 @@ struct limit_lcore_context {
t->state = Thread_INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = false;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -285,7 +286,7 @@ struct limit_lcore_context {
t->state = Thread_INIT;
t->registered_count = ®istered_count;
t->lcore_id_any = true;
- if (pthread_create(&t->id, NULL, thread_loop, t) != 0)
+ if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
goto cleanup_threads;
non_eal_threads_count++;
while (__atomic_load_n(®istered_count, __ATOMIC_ACQUIRE) !=
@@ -309,7 +310,7 @@ struct limit_lcore_context {
ret = 0;
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
if (t->state != Thread_DONE)
ret = -1;
}
@@ -330,7 +331,7 @@ struct limit_lcore_context {
__atomic_store_n(®istered_count, 0, __ATOMIC_RELEASE);
for (i = 0; i < non_eal_threads_count; i++) {
t = &thread_contexts[i];
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
}
error:
if (handle[1] != NULL)
@@ -361,7 +362,7 @@ static void *ctrl_thread_loop(void *arg)
/* Create one control thread */
t = &ctrl_thread_context;
t->state = Thread_INIT;
- if (rte_ctrl_thread_create(&t->id, "test_ctrl_threads",
+ if (rte_ctrl_thread_create((pthread_t *)&t->id, "test_ctrl_threads",
NULL, ctrl_thread_loop, t) != 0)
return -1;
@@ -369,7 +370,7 @@ static void *ctrl_thread_loop(void *arg)
* This also acts as the barrier such that the memory operations
* in control thread are visible to this thread.
*/
- pthread_join(t->id, NULL);
+ rte_thread_join(t->id, NULL);
/* Check if the control thread set the correct state */
if (t->state != Thread_DONE)
@@ -384,9 +385,6 @@ static void *ctrl_thread_loop(void *arg)
unsigned int eal_threads_count = 0;
unsigned int i;
- if (RTE_EXEC_ENV_IS_WINDOWS)
- return TEST_SKIPPED;
-
for (i = 0; i < RTE_MAX_LCORE; i++) {
if (!rte_lcore_has_role(i, ROLE_OFF))
eal_threads_count++;
--
1.8.3.1
next prev parent reply other threads:[~2022-12-06 0:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 0:39 [PATCH 0/2] enable lcores test on Windows Tyler Retzlaff
2022-12-06 0:39 ` [PATCH 1/2] eal: add missing call marking memory config complete Tyler Retzlaff
2022-12-14 16:52 ` Stephen Hemminger
2022-12-15 9:59 ` David Marchand
2022-12-15 18:07 ` Tyler Retzlaff
2022-12-06 0:39 ` Tyler Retzlaff [this message]
2022-12-14 16:53 ` [PATCH 2/2] test: enable lcores test on Windows Stephen Hemminger
2022-12-12 20:36 ` [PATCH 0/2] " Tyler Retzlaff
2022-12-16 17:16 ` [PATCH v2 0/2] Enable the lcores test on Windows instead of skipping it Tyler Retzlaff
2022-12-16 17:16 ` [PATCH v2 1/2] eal: add missing call marking memory config complete Tyler Retzlaff
2022-12-16 17:16 ` [PATCH v2 2/2] test: enable lcores test on Windows Tyler Retzlaff
2022-12-21 15:03 ` [PATCH v2 0/2] Enable the lcores test on Windows instead of skipping it David Marchand
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=1670287169-15325-3-git-send-email-roretzla@linux.microsoft.com \
--to=roretzla@linux.microsoft.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.