[PATCH V2 01/15] eal: add interface to check if lcore is EAL managed

Huisong Li lihuisong at huawei.com
Thu May 7 04:42:16 CEST 2026


Add a new helper function rte_lcore_is_eal_managed() to determine
if a logical core is managed by EAL.

This interface returns true if the lcore role is either ROLE_RTE
(standard worker/main cores) or ROLE_SERVICE (service cores).

Signed-off-by: Huisong Li <lihuisong at huawei.com>
---
 lib/eal/common/eal_common_lcore.c | 11 +++++++++++
 lib/eal/include/rte_lcore.h       | 11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/lib/eal/common/eal_common_lcore.c b/lib/eal/common/eal_common_lcore.c
index 39411f9370..dfbd96875a 100644
--- a/lib/eal/common/eal_common_lcore.c
+++ b/lib/eal/common/eal_common_lcore.c
@@ -102,6 +102,17 @@ int rte_lcore_is_enabled(unsigned int lcore_id)
 	return cfg->lcore_role[lcore_id] == ROLE_RTE;
 }
 
+RTE_EXPORT_SYMBOL(rte_lcore_is_eal_managed)
+int rte_lcore_is_eal_managed(unsigned int lcore_id)
+{
+	struct rte_config *cfg = rte_eal_get_configuration();
+
+	if (lcore_id >= RTE_MAX_LCORE)
+		return 0;
+	return cfg->lcore_role[lcore_id] == ROLE_RTE ||
+		cfg->lcore_role[lcore_id] == ROLE_SERVICE;
+}
+
 RTE_EXPORT_SYMBOL(rte_get_next_lcore)
 unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap)
 {
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 10f965b4f0..cbfd50a936 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -195,6 +195,17 @@ rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id);
  */
 int rte_lcore_is_enabled(unsigned int lcore_id);
 
+/**
+ * Test if an lcore is ROLE_RTE or ROLE_SERVICE.
+ *
+ * @param lcore_id
+ *   The identifier of the lcore, which MUST be between 0 and
+ *   RTE_MAX_LCORE-1.
+ * @return
+ *   True if the given lcore is ROLE_RTE or ROLE_SERVICE; false otherwise.
+ */
+int rte_lcore_is_eal_managed(unsigned int lcore_id);
+
 /**
  * Get the next enabled lcore ID.
  *
-- 
2.33.0



More information about the dev mailing list