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>,
	Anatoly Burakov <anatoly.burakov@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
	Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
	Dmitry Malloy <dmitrym@microsoft.com>,
	Pallavi Kadam <pallavi.kadam@intel.com>
Subject: [PATCH 10/11] eal: remove deprecated thread functions
Date: Wed,  6 Sep 2023 18:12:27 +0200	[thread overview]
Message-ID: <20230906162226.1618088-11-thomas@monjalon.net> (raw)
In-Reply-To: <20230906162226.1618088-1-thomas@monjalon.net>

The deprecated functions rte_thread_setname() and rte_ctrl_thread_create()
are replaced with the new rte_thread API:

	rte_thread_setname()
can be replaced with
	rte_thread_set_name()
or	rte_thread_set_prefixed_name()

	rte_ctrl_thread_create()
can be replaced with
	rte_thread_create_control()
or	rte_thread_create_internal_control()

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 .../prog_guide/env_abstraction_layer.rst      |  2 +-
 doc/guides/rel_notes/deprecation.rst          |  5 --
 doc/guides/rel_notes/release_23_11.rst        |  4 +-
 lib/eal/common/eal_common_thread.c            | 66 +------------------
 lib/eal/freebsd/eal_thread.c                  |  7 --
 lib/eal/include/rte_lcore.h                   | 42 ------------
 lib/eal/linux/eal_thread.c                    | 16 -----
 lib/eal/version.map                           |  2 -
 lib/eal/windows/eal_thread.c                  |  8 ---
 9 files changed, 6 insertions(+), 146 deletions(-)

diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst
index 89014789de..6debf54efb 100644
--- a/doc/guides/prog_guide/env_abstraction_layer.rst
+++ b/doc/guides/prog_guide/env_abstraction_layer.rst
@@ -756,7 +756,7 @@ Control Thread API
 ~~~~~~~~~~~~~~~~~~
 
 It is possible to create Control Threads using the public API
-``rte_ctrl_thread_create()``.
+``rte_thread_create_control()``.
 Those threads can be used for management/infrastructure tasks and are used
 internally by DPDK for multi process support and interrupt handling.
 
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 3e48908b51..8c8873006d 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -29,11 +29,6 @@ Deprecation Notices
   are renamed to ``rte_tel_data_add_array_uint`` and ``rte_tel_data_add_dict_uint`` respectively.
   As such, the old function names are deprecated and will be removed in a future release.
 
-* eal: The functions ``rte_thread_setname`` and ``rte_ctrl_thread_create``
-  are planned to be deprecated starting with the 23.07 release, subject to
-  the replacement API rte_thread_set_name and rte_thread_create_control being
-  marked as stable, and planned to be removed by the 23.11 release.
-
 * eal: ``RTE_CPUFLAG_NUMFLAGS`` will be removed in DPDK 23.11 release.
   This is to allow new CPU features to be added without ABI breakage.
 
diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index d7562fd646..9746809a66 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -115,7 +115,9 @@ API Changes
 
 * eal: The thread API has changed.
   The function ``rte_thread_create_control()`` does not take attributes anymore.
-  The whole thread API was promoted to stable level.
+  The whole thread API was promoted to stable level,
+  except ``rte_thread_setname()`` and ``rte_ctrl_thread_create()`` which are
+  replaced with ``rte_thread_set_name()`` and ``rte_thread_create_control()``.
 
 
 ABI Changes
diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 31c37e3102..78f643af73 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -248,7 +248,7 @@ struct rte_thread_ctrl_params {
 	enum __rte_ctrl_thread_status ctrl_thread_status;
 };
 
-static int ctrl_thread_init(void *arg)
+static int control_thread_init(void *arg)
 {
 	struct internal_config *internal_conf =
 		eal_get_internal_configuration();
@@ -273,80 +273,18 @@ static int ctrl_thread_init(void *arg)
 	return 0;
 }
 
-static void *ctrl_thread_start(void *arg)
-{
-	struct rte_thread_ctrl_params *params = arg;
-	void *start_arg = params->arg;
-	void *(*start_routine)(void *) = params->u.ctrl_start_routine;
-
-	if (ctrl_thread_init(arg) != 0)
-		return NULL;
-
-	return start_routine(start_arg);
-}
-
 static uint32_t control_thread_start(void *arg)
 {
 	struct rte_thread_ctrl_params *params = arg;
 	void *start_arg = params->arg;
 	rte_thread_func start_routine = params->u.control_start_routine;
 
-	if (ctrl_thread_init(arg) != 0)
+	if (control_thread_init(arg) != 0)
 		return 0;
 
 	return start_routine(start_arg);
 }
 
-int
-rte_ctrl_thread_create(pthread_t *thread, const char *name,
-		const pthread_attr_t *attr,
-		void *(*start_routine)(void *), void *arg)
-{
-	struct rte_thread_ctrl_params *params;
-	enum __rte_ctrl_thread_status ctrl_thread_status;
-	int ret;
-
-	params = malloc(sizeof(*params));
-	if (!params)
-		return -ENOMEM;
-
-	params->u.ctrl_start_routine = start_routine;
-	params->arg = arg;
-	params->ret = 0;
-	params->ctrl_thread_status = CTRL_THREAD_LAUNCHING;
-
-	ret = pthread_create(thread, attr, ctrl_thread_start, (void *)params);
-	if (ret != 0) {
-		free(params);
-		return -ret;
-	}
-
-	if (name != NULL)
-		rte_thread_set_name((rte_thread_t){(uintptr_t)*thread}, name);
-
-	/* Wait for the control thread to initialize successfully */
-	while ((ctrl_thread_status =
-			__atomic_load_n(&params->ctrl_thread_status,
-			__ATOMIC_ACQUIRE)) == CTRL_THREAD_LAUNCHING) {
-		/* Yield the CPU. Using sched_yield call requires maintaining
-		 * another implementation for Windows as sched_yield is not
-		 * supported on Windows.
-		 */
-		rte_delay_us_sleep(1);
-	}
-
-	/* Check if the control thread encountered an error */
-	if (ctrl_thread_status == CTRL_THREAD_ERROR) {
-		/* ctrl thread is exiting */
-		rte_thread_join((rte_thread_t){(uintptr_t)*thread}, NULL);
-	}
-
-	ret = params->ret;
-	free(params);
-
-	return -ret;
-}
-
 int
 rte_thread_create_control(rte_thread_t *thread, const char *name,
 		rte_thread_func start_routine, void *arg)
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index ba9b25c2c0..6f97a3c2c1 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -42,10 +42,3 @@ void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name)
 
 	pthread_set_name_np((pthread_t)thread_id.opaque_id, truncated);
 }
-
-int rte_thread_setname(pthread_t id, const char *name)
-{
-	/* this BSD function returns no error */
-	pthread_set_name_np(id, name);
-	return 0;
-}
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 6ce810b876..7deae47af3 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -385,20 +385,6 @@ void rte_lcore_register_usage_cb(rte_lcore_usage_cb cb);
 void
 rte_lcore_dump(FILE *f);
 
-/**
- * Set thread names.
- *
- * @note It fails with glibc < 2.12.
- *
- * @param id
- *   Thread id.
- * @param name
- *   Thread name to set.
- * @return
- *   On success, return 0; otherwise return a negative value.
- */
-int rte_thread_setname(pthread_t id, const char *name);
-
 /**
  * Register current non-EAL thread as a lcore.
  *
@@ -421,34 +407,6 @@ rte_thread_register(void);
 void
 rte_thread_unregister(void);
 
-/**
- * Create a control thread.
- *
- * Creates a control thread with the given name and attributes. The
- * affinity of the new thread is based on the CPU affinity retrieved
- * at the time rte_eal_init() was called, the dataplane and service
- * lcores are then excluded. If setting the name of the thread fails,
- * the error is ignored and a debug message is logged.
- *
- * @param thread
- *   Filled with the thread id of the new created thread.
- * @param name
- *   The name of the control thread (max 16 characters including '\0').
- * @param attr
- *   Attributes for the new thread.
- * @param start_routine
- *   Function to be executed by the new thread.
- * @param arg
- *   Argument passed to start_routine.
- * @return
- *   On success, returns 0; on error, it returns a negative value
- *   corresponding to the error number.
- */
-int
-rte_ctrl_thread_create(pthread_t *thread, const char *name,
-		const pthread_attr_t *attr,
-		void *(*start_routine)(void *), void *arg);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index b9a126f3a8..880070c627 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -39,19 +39,3 @@ void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name)
 	if (ret != 0)
 		RTE_LOG(DEBUG, EAL, "Failed to set thread name\n");
 }
-
-int rte_thread_setname(pthread_t id, const char *name)
-{
-	int ret = ENOSYS;
-#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
-#if __GLIBC_PREREQ(2, 12)
-	char truncated[16];
-
-	strlcpy(truncated, name, sizeof(truncated));
-	ret = pthread_setname_np(id, truncated);
-#endif
-#endif
-	RTE_SET_USED(id);
-	RTE_SET_USED(name);
-	return -ret;
-}
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 6d32c19286..915057b325 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -20,7 +20,6 @@ DPDK_24 {
 	rte_cpu_get_flag_enabled;
 	rte_cpu_get_flag_name;
 	rte_cpu_is_supported; # WINDOWS_NO_EXPORT
-	rte_ctrl_thread_create;
 	rte_cycles_vmware_tsc_map; # WINDOWS_NO_EXPORT
 	rte_delay_us;
 	rte_delay_us_block;
@@ -278,7 +277,6 @@ DPDK_24 {
 	rte_thread_set_affinity_by_id;
 	rte_thread_set_name;
 	rte_thread_set_priority;
-	rte_thread_setname;
 	rte_thread_unregister;
 	rte_thread_value_get;
 	rte_thread_value_set;
diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c
index 464d510838..9e3df200b9 100644
--- a/lib/eal/windows/eal_thread.c
+++ b/lib/eal/windows/eal_thread.c
@@ -76,11 +76,3 @@ rte_sys_gettid(void)
 {
 	return GetCurrentThreadId();
 }
-
-int
-rte_thread_setname(__rte_unused pthread_t id, __rte_unused const char *name)
-{
-	/* TODO */
-	/* This is a stub, not the expected result */
-	return 0;
-}
-- 
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 ` [PATCH 09/11] test: convert threads creation Thomas Monjalon
2023-09-08  4:12   ` Tyler Retzlaff
2023-09-06 16:12 ` Thomas Monjalon [this message]
2023-09-08  4:22   ` [PATCH 10/11] eal: remove deprecated thread functions 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-11-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=dmitrym@microsoft.com \
    --cc=ferruh.yigit@amd.com \
    --cc=navasile@linux.microsoft.com \
    --cc=pallavi.kadam@intel.com \
    --cc=roretzla@linux.microsoft.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 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).