@@ -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.
@@ -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.
@@ -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
@@ -235,25 +235,22 @@ enum __rte_ctrl_thread_status {
CTRL_THREAD_ERROR /* Control thread encountered an error */
};
-struct rte_thread_ctrl_params {
- union {
- void *(*ctrl_start_routine)(void *arg);
- rte_thread_func control_start_routine;
- } u;
+struct control_thread_params {
+ rte_thread_func start_routine;
void *arg;
int ret;
/* Control thread status.
* If the status is CTRL_THREAD_ERROR, 'ret' has the error code.
*/
- enum __rte_ctrl_thread_status ctrl_thread_status;
+ enum __rte_ctrl_thread_status status;
};
-static int ctrl_thread_init(void *arg)
+static int control_thread_init(void *arg)
{
struct internal_config *internal_conf =
eal_get_internal_configuration();
rte_cpuset_t *cpuset = &internal_conf->ctrl_cpuset;
- struct rte_thread_ctrl_params *params = arg;
+ struct control_thread_params *params = arg;
__rte_thread_init(rte_lcore_id(), cpuset);
/* Set control thread socket ID to SOCKET_ID_ANY
@@ -262,96 +259,34 @@ static int ctrl_thread_init(void *arg)
RTE_PER_LCORE(_socket_id) = SOCKET_ID_ANY;
params->ret = rte_thread_set_affinity_by_id(rte_thread_self(), cpuset);
if (params->ret != 0) {
- __atomic_store_n(¶ms->ctrl_thread_status,
+ __atomic_store_n(¶ms->status,
CTRL_THREAD_ERROR, __ATOMIC_RELEASE);
return 1;
}
- __atomic_store_n(¶ms->ctrl_thread_status,
+ __atomic_store_n(¶ms->status,
CTRL_THREAD_RUNNING, __ATOMIC_RELEASE);
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;
+ struct control_thread_params *params = arg;
void *start_arg = params->arg;
- rte_thread_func start_routine = params->u.control_start_routine;
+ rte_thread_func start_routine = params->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(¶ms->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)
{
- struct rte_thread_ctrl_params *params;
+ struct control_thread_params *params;
enum __rte_ctrl_thread_status ctrl_thread_status;
int ret;
@@ -359,10 +294,10 @@ rte_thread_create_control(rte_thread_t *thread, const char *name,
if (params == NULL)
return -ENOMEM;
- params->u.control_start_routine = start_routine;
+ params->start_routine = start_routine;
params->arg = arg;
params->ret = 0;
- params->ctrl_thread_status = CTRL_THREAD_LAUNCHING;
+ params->status = CTRL_THREAD_LAUNCHING;
ret = rte_thread_create(thread, NULL, control_thread_start, params);
if (ret != 0) {
@@ -375,7 +310,7 @@ rte_thread_create_control(rte_thread_t *thread, const char *name,
/* Wait for the control thread to initialize successfully */
while ((ctrl_thread_status =
- __atomic_load_n(¶ms->ctrl_thread_status,
+ __atomic_load_n(¶ms->status,
__ATOMIC_ACQUIRE)) == CTRL_THREAD_LAUNCHING) {
rte_delay_us_sleep(1);
}
@@ -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;
-}
@@ -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
@@ -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;
-}
@@ -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;
@@ -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;
-}