[09/11] test: convert threads creation

Message ID 20230906162226.1618088-10-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series rework thread management |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Sept. 6, 2023, 4:12 p.m. UTC
  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(-)
  

Comments

Tyler Retzlaff Sept. 8, 2023, 4:12 a.m. UTC | #1
On Wed, Sep 06, 2023 at 06:12:26PM +0200, Thomas Monjalon wrote:
> Calls to pthread for thread creation are replaced with the rte_thread API.
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  

Patch

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);