[PATCH v5] eal: fix uncheck lcore role
Dengdui Huang
huangdengdui at huawei.com
Thu Aug 7 04:49:36 CEST 2025
Only the lcore whose role is ROLE_RTE or ROLE_SERVICE can be
launched. This patch adds the lcore role check.
In addition, update the function's documentation to explain
the range of lcores.
Fixes: a95d70547c57 ("eal: factorize lcore main loop")
Cc: stable at dpdk.org
Signed-off-by: Dengdui Huang <huangdengdui at huawei.com>
---
lib/eal/common/eal_common_launch.c | 7 +++++++
lib/eal/include/rte_launch.h | 8 +++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/eal/common/eal_common_launch.c b/lib/eal/common/eal_common_launch.c
index a7deac6ecd..be7226e4b6 100644
--- a/lib/eal/common/eal_common_launch.c
+++ b/lib/eal/common/eal_common_launch.c
@@ -36,8 +36,15 @@ RTE_EXPORT_SYMBOL(rte_eal_remote_launch)
int
rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned int worker_id)
{
+ enum rte_lcore_role_t role;
int rc = -EBUSY;
+ role = lcore_config[worker_id].core_role;
+ if (role != ROLE_RTE && role != ROLE_SERVICE) {
+ rc = -EINVAL;
+ goto finish;
+ }
+
/* Check if the worker is in 'WAIT' state. Use acquire order
* since 'state' variable is used as the guard variable.
*/
diff --git a/lib/eal/include/rte_launch.h b/lib/eal/include/rte_launch.h
index f7bf9f6b2d..a2d89e89f1 100644
--- a/lib/eal/include/rte_launch.h
+++ b/lib/eal/include/rte_launch.h
@@ -58,11 +58,13 @@ typedef int (lcore_function_t)(void *);
* @param arg
* The argument for the function.
* @param worker_id
- * The identifier of the lcore on which the function should be executed.
+ * The identifier of the lcore on which the function should be executed,
+ * which MUST be between 0 and RTE_MAX_LCORE-1.
* @return
* - 0: Success. Execution of function f started on the remote lcore.
* - (-EBUSY): The remote lcore is not in a WAIT state.
* - (-EPIPE): Error reading or writing pipe to worker thread
+ * - (-EINVAL): The role of the remote lcore is neither ROLE_RTE nor ROLE_SERVICE.
*/
int rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned worker_id);
@@ -105,7 +107,7 @@ int rte_eal_mp_remote_launch(lcore_function_t *f, void *arg,
* To be executed on the MAIN lcore only.
*
* @param worker_id
- * The identifier of the lcore.
+ * The identifier of the lcore, which MUST be between 0 and RTE_MAX_LCORE-1.
* @return
* The state of the lcore.
*/
@@ -120,7 +122,7 @@ enum rte_lcore_state_t rte_eal_get_lcore_state(unsigned int worker_id);
* the lcore finishes its job and moves to the WAIT state.
*
* @param worker_id
- * The identifier of the lcore.
+ * The identifier of the lcore, which MUST be between 0 and RTE_MAX_LCORE-1.
* @return
* - 0: If the remote launch function was never called on the lcore
* identified by the worker_id.
--
2.33.0
More information about the dev
mailing list