DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: Tyler Retzlaff <roretzla@linux.microsoft.com>,
	David Marchand <david.marchand@redhat.com>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Reshma Pattan <reshma.pattan@intel.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH 09/11] test: convert threads creation
Date: Wed,  6 Sep 2023 18:12:26 +0200	[thread overview]
Message-ID: <20230906162226.1618088-10-thomas@monjalon.net> (raw)
In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net>

Calls to pthread for thread creation are replaced with the rte_thread API.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/test/process.h     | 10 +++++-----
 app/test/test_lcores.c |  9 ++++-----
 app/test/test_pdump.c  |  6 +++---
 app/test/test_pdump.h  |  2 +-
 4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/app/test/process.h b/app/test/process.h
index 1f073b9c5c..af7bc3e0de 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -28,8 +28,8 @@
 
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
-#include <pthread.h>
-extern void *send_pkts(void *empty);
+#include <rte_thread.h>
+extern uint32_t send_pkts(void *empty);
 extern uint16_t flag_for_send_pkts;
 #endif
 #endif
@@ -49,7 +49,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
 	char path[32];
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
-	pthread_t thread;
+	rte_thread_t thread;
 	int rc;
 #endif
 #endif
@@ -136,7 +136,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
 	if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
-		rc = pthread_create(&thread, NULL, &send_pkts, NULL);
+		rc = rte_thread_create(&thread, NULL, send_pkts, NULL);
 		if (rc != 0) {
 			rte_panic("Cannot start send pkts thread: %s\n",
 				  strerror(rc));
@@ -151,7 +151,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
 #ifdef RTE_NET_RING
 	if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
 		flag_for_send_pkts = 0;
-		pthread_join(thread, NULL);
+		rte_thread_join(thread, NULL);
 	}
 #endif
 #endif
diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index 0c96faa4cb..22225a9fd3 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -2,7 +2,6 @@
  * Copyright (c) 2020 Red Hat, Inc.
  */
 
-#include <pthread.h>
 #include <string.h>
 
 #include <rte_common.h>
@@ -341,7 +340,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
 	return -1;
 }
 
-static void *ctrl_thread_loop(void *arg)
+static uint32_t ctrl_thread_loop(void *arg)
 {
 	struct thread_context *t = arg;
 
@@ -350,7 +349,7 @@ static void *ctrl_thread_loop(void *arg)
 	/* Set the thread state to DONE */
 	t->state = Thread_DONE;
 
-	return NULL;
+	return 0;
 }
 
 static int
@@ -362,8 +361,8 @@ test_ctrl_thread(void)
 	/* Create one control thread */
 	t = &ctrl_thread_context;
 	t->state = Thread_INIT;
-	if (rte_ctrl_thread_create((pthread_t *)&t->id, "dpdk-test-ctrlt",
-					NULL, ctrl_thread_loop, t) != 0)
+	if (rte_thread_create_control(&t->id, "dpdk-test-ctrlt",
+				ctrl_thread_loop, t) != 0)
 		return -1;
 
 	/* Wait till the control thread exits.
diff --git a/app/test/test_pdump.c b/app/test/test_pdump.c
index ea03056b47..adf49f0b54 100644
--- a/app/test/test_pdump.c
+++ b/app/test/test_pdump.c
@@ -136,8 +136,8 @@ test_pdump_uninit(void)
 	return ret;
 }
 
-void *
-send_pkts(void *empty)
+uint32_t
+send_pkts(void *empty __rte_unused)
 {
 	int ret = 0;
 	struct rte_mbuf *pbuf[NUM_PACKETS] = { };
@@ -161,7 +161,7 @@ send_pkts(void *empty)
 
 	rte_eth_dev_stop(portid);
 	test_put_mbuf_to_pool(mp, pbuf);
-	return empty;
+	return 0;
 }
 
 /*
diff --git a/app/test/test_pdump.h b/app/test/test_pdump.h
index abef9a85ec..8746d61269 100644
--- a/app/test/test_pdump.h
+++ b/app/test/test_pdump.h
@@ -9,7 +9,7 @@
 #define NUM_ITR 3
 
 /* sample test to send packets to the pdump client recursively */
-void *send_pkts(void *port);
+uint32_t send_pkts(void *empty);
 
 /* Sample test to create setup for the pdump server tests */
 int test_pdump_init(void);
-- 
2.42.0


  parent reply	other threads:[~2023-09-06 16:24 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 16:12 [PATCH 00/11] rework thread management Thomas Monjalon
2023-09-06 16:12 ` [PATCH 01/11] devtools: warn when adding some pthread calls Thomas Monjalon
2023-09-07  8:20   ` David Marchand
2023-09-06 16:12 ` [PATCH 02/11] eal: rename thread name length definition Thomas Monjalon
2023-09-08  4:00   ` Tyler Retzlaff
2023-09-06 16:12 ` [PATCH 03/11] eal: remove attributes from control thread creation Thomas Monjalon
2023-09-08  4:02   ` Tyler Retzlaff
2023-09-06 16:12 ` [PATCH 04/11] eal: promote thread API as stable Thomas Monjalon
2023-09-08  4:04   ` Tyler Retzlaff
2023-09-06 16:12 ` [PATCH 05/11] eal: force prefix for internal threads Thomas Monjalon
2023-09-07  8:28   ` David Marchand
2023-09-07  8:50     ` Morten Brørup
2023-09-07  8:53       ` David Marchand
2023-09-07  8:55         ` David Marchand
2023-09-07 11:10           ` Morten Brørup
2023-09-11 16:26             ` Thomas Monjalon
2023-09-11 21:32               ` Morten Brørup
2023-09-06 16:12 ` [PATCH 06/11] lib: convert to internal control threads Thomas Monjalon
2023-09-06 16:12 ` [PATCH 07/11] drivers: " Thomas Monjalon
2023-09-11 13:35   ` Andrew Rybchenko
2023-09-06 16:12 ` [PATCH 08/11] examples: convert to normal " Thomas Monjalon
2023-09-08  4:10   ` Tyler Retzlaff
2023-09-06 16:12 ` Thomas Monjalon [this message]
2023-09-08  4:12   ` [PATCH 09/11] test: convert threads creation Tyler Retzlaff
2023-09-06 16:12 ` [PATCH 10/11] eal: remove deprecated thread functions Thomas Monjalon
2023-09-08  4:22   ` Tyler Retzlaff
2023-09-11 16:13     ` Thomas Monjalon
2023-09-12  0:49       ` Tyler Retzlaff
2023-09-06 16:12 ` [PATCH 11/11] lib: remove pthread.h from includes Thomas Monjalon
2023-09-08  4:25   ` Tyler Retzlaff
2023-09-08  4:49     ` Ajit Khaparde
2023-09-10  2:55   ` Xu, Rosen
2023-09-07  8:30 ` [PATCH 00/11] rework thread management Morten Brørup
2023-09-08  4:26   ` Tyler Retzlaff
2023-09-13 10:34 ` [PATCH v2 " Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 01/11] devtools: warn when adding some pthread calls Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 02/11] eal: rename thread name length definition Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 03/11] eal: remove attributes from control thread creation Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 04/11] eal: promote thread API as stable Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 05/11] eal: force prefix for internal threads Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 06/11] lib: convert to internal control threads Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 07/11] drivers: " Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 08/11] examples: convert to normal " Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 09/11] test: convert threads creation Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 10/11] eal: remove deprecated thread functions Thomas Monjalon
2023-09-13 10:34   ` [PATCH v2 11/11] lib: remove pthread.h from includes Thomas Monjalon
2023-09-13 11:28 ` [PATCH v3 00/11] rework thread management Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 01/11] devtools: warn when adding some pthread calls Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 02/11] eal: rename thread name length definition Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 03/11] eal: remove attributes from control thread creation Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 04/11] eal: promote thread API as stable Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 05/11] eal: force prefix for internal threads Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 06/11] lib: convert to internal control threads Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 07/11] drivers: " Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 08/11] examples: convert to normal " Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 09/11] test: convert threads creation Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 10/11] eal: remove deprecated thread functions Thomas Monjalon
2023-09-13 11:28   ` [PATCH v3 11/11] lib: remove pthread.h from includes Thomas Monjalon
2023-09-17 12:26   ` [PATCH v3 00/11] rework thread management Konstantin Ananyev
2023-09-22 13:46   ` 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=20230906162226.1618088-10-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=reshma.pattan@intel.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=stephen@networkplumber.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).