From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: techboard@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>
Subject: [RFC PATCH 17/44] eal: make lcore role a field in lcore config struct
Date: Wed, 29 Apr 2026 17:58:09 +0100 [thread overview]
Message-ID: <20260429165845.2136843-18-bruce.richardson@intel.com> (raw)
In-Reply-To: <20260429165845.2136843-1-bruce.richardson@intel.com>
Rather than having a separate array for lcore role, just make the role a
field in the lcore_cfg struct.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/eal/common/eal_common_lcore.c | 28 ++++++++++++++--------------
lib/eal/common/eal_common_options.c | 26 +++++++++++++-------------
lib/eal/common/eal_internal_cfg.h | 2 +-
lib/eal/common/rte_service.c | 6 +++---
4 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/lib/eal/common/eal_common_lcore.c b/lib/eal/common/eal_common_lcore.c
index 457c4c91a0..1ec1dc080a 100644
--- a/lib/eal/common/eal_common_lcore.c
+++ b/lib/eal/common/eal_common_lcore.c
@@ -88,7 +88,7 @@ rte_eal_lcore_role(unsigned int lcore_id)
if (lcore_id >= RTE_MAX_LCORE)
return ROLE_OFF;
- return runtime_state->lcore_role[lcore_id];
+ return runtime_state->lcore_cfg[lcore_id].role;
}
RTE_EXPORT_SYMBOL(rte_lcore_has_role)
@@ -100,7 +100,7 @@ rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role)
if (lcore_id >= RTE_MAX_LCORE)
return 0;
- return runtime_state->lcore_role[lcore_id] == role;
+ return runtime_state->lcore_cfg[lcore_id].role == role;
}
RTE_EXPORT_SYMBOL(rte_lcore_is_enabled)
@@ -110,7 +110,7 @@ int rte_lcore_is_enabled(unsigned int lcore_id)
if (lcore_id >= RTE_MAX_LCORE)
return 0;
- return runtime_state->lcore_role[lcore_id] == ROLE_RTE;
+ return runtime_state->lcore_cfg[lcore_id].role == ROLE_RTE;
}
RTE_EXPORT_SYMBOL(rte_get_next_lcore)
@@ -322,7 +322,7 @@ rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,
if (callback->init == NULL)
goto no_init;
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
- if (runtime_state->lcore_role[lcore_id] == ROLE_OFF)
+ if (runtime_state->lcore_cfg[lcore_id].role == ROLE_OFF)
continue;
if (callback_init(callback, lcore_id) == 0)
continue;
@@ -330,7 +330,7 @@ rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,
* previous lcore.
*/
while (lcore_id-- != 0) {
- if (runtime_state->lcore_role[lcore_id] == ROLE_OFF)
+ if (runtime_state->lcore_cfg[lcore_id].role == ROLE_OFF)
continue;
callback_uninit(callback, lcore_id);
}
@@ -362,7 +362,7 @@ rte_lcore_callback_unregister(void *handle)
if (callback->uninit == NULL)
goto no_uninit;
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
- if (runtime_state->lcore_role[lcore_id] == ROLE_OFF)
+ if (runtime_state->lcore_cfg[lcore_id].role == ROLE_OFF)
continue;
callback_uninit(callback, lcore_id);
}
@@ -384,9 +384,9 @@ eal_lcore_non_eal_allocate(void)
rte_rwlock_write_lock(&lcore_lock);
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
- if (runtime_state->lcore_role[lcore_id] != ROLE_OFF)
+ if (runtime_state->lcore_cfg[lcore_id].role != ROLE_OFF)
continue;
- runtime_state->lcore_role[lcore_id] = ROLE_NON_EAL;
+ runtime_state->lcore_cfg[lcore_id].role = ROLE_NON_EAL;
runtime_state->lcore_count++;
break;
}
@@ -407,7 +407,7 @@ eal_lcore_non_eal_allocate(void)
}
EAL_LOG(DEBUG, "Initialization refused for lcore %u.",
lcore_id);
- runtime_state->lcore_role[lcore_id] = ROLE_OFF;
+ runtime_state->lcore_cfg[lcore_id].role = ROLE_OFF;
runtime_state->lcore_count--;
lcore_id = RTE_MAX_LCORE;
goto out;
@@ -424,11 +424,11 @@ eal_lcore_non_eal_release(unsigned int lcore_id)
struct lcore_callback *callback;
rte_rwlock_write_lock(&lcore_lock);
- if (runtime_state->lcore_role[lcore_id] != ROLE_NON_EAL)
+ if (runtime_state->lcore_cfg[lcore_id].role != ROLE_NON_EAL)
goto out;
TAILQ_FOREACH(callback, &lcore_callbacks, next)
callback_uninit(callback, lcore_id);
- runtime_state->lcore_role[lcore_id] = ROLE_OFF;
+ runtime_state->lcore_cfg[lcore_id].role = ROLE_OFF;
runtime_state->lcore_count--;
out:
rte_rwlock_write_unlock(&lcore_lock);
@@ -444,7 +444,7 @@ rte_lcore_iterate(rte_lcore_iterate_cb cb, void *arg)
rte_rwlock_read_lock(&lcore_lock);
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
- if (runtime_state->lcore_role[lcore_id] == ROLE_OFF)
+ if (runtime_state->lcore_cfg[lcore_id].role == ROLE_OFF)
continue;
ret = cb(lcore_id, arg);
if (ret != 0)
@@ -509,7 +509,7 @@ lcore_dump_cb(unsigned int lcore_id, void *arg)
cpuset = eal_cpuset_to_str(&runtime_state->lcore_cfg[lcore_id].cpuset);
fprintf(f, "lcore %u, socket %u, role %s, cpuset %s\n", lcore_id,
rte_lcore_to_socket_id(lcore_id),
- lcore_role_str(runtime_state->lcore_role[lcore_id]),
+ lcore_role_str(runtime_state->lcore_cfg[lcore_id].role),
cpuset != NULL ? cpuset : "<unknown>");
free(cpuset);
free(usage_str);
@@ -575,7 +575,7 @@ lcore_telemetry_info_cb(unsigned int lcore_id, void *arg)
rte_tel_data_start_dict(info->d);
rte_tel_data_add_dict_int(info->d, "lcore_id", lcore_id);
rte_tel_data_add_dict_int(info->d, "socket", rte_lcore_to_socket_id(lcore_id));
- rte_tel_data_add_dict_string(info->d, "role", lcore_role_str(runtime_state->lcore_role[lcore_id]));
+ rte_tel_data_add_dict_string(info->d, "role", lcore_role_str(runtime_state->lcore_cfg[lcore_id].role));
cpuset = rte_tel_data_alloc();
if (cpuset == NULL)
return -ENOMEM;
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 3535e467c6..83e0d986a5 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -885,10 +885,10 @@ eal_parse_service_coremask(const char *coremask)
return -1;
}
- if (runtime_state->lcore_role[idx] == ROLE_RTE)
+ if (runtime_state->lcore_cfg[idx].role == ROLE_RTE)
taken_lcore_count++;
- runtime_state->lcore_role[idx] = ROLE_SERVICE;
+ runtime_state->lcore_cfg[idx].role = ROLE_SERVICE;
count++;
}
}
@@ -921,7 +921,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)
/* set everything to disabled first, then set up values */
for (i = 0; i < RTE_MAX_LCORE; i++) {
- runtime_state->lcore_role[i] = ROLE_OFF;
+ runtime_state->lcore_cfg[i].role = ROLE_OFF;
runtime_state->lcore_cfg[i].core_index = -1;
}
@@ -949,7 +949,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)
continue;
}
- runtime_state->lcore_role[lcore_id] = ROLE_RTE;
+ runtime_state->lcore_cfg[lcore_id].role = ROLE_RTE;
runtime_state->lcore_cfg[lcore_id].core_index = count;
CPU_ZERO(&runtime_state->lcore_cfg[lcore_id].cpuset);
CPU_SET(i, &runtime_state->lcore_cfg[lcore_id].cpuset);
@@ -1122,11 +1122,11 @@ eal_parse_service_corelist(const char *corelist)
if (min == RTE_MAX_LCORE)
min = idx;
for (idx = min; idx <= max; idx++) {
- if (runtime_state->lcore_role[idx] != ROLE_SERVICE) {
- if (runtime_state->lcore_role[idx] == ROLE_RTE)
+ if (runtime_state->lcore_cfg[idx].role != ROLE_SERVICE) {
+ if (runtime_state->lcore_cfg[idx].role == ROLE_RTE)
taken_lcore_count++;
- runtime_state->lcore_role[idx] = ROLE_SERVICE;
+ runtime_state->lcore_cfg[idx].role = ROLE_SERVICE;
count++;
}
}
@@ -1149,7 +1149,7 @@ eal_parse_service_corelist(const char *corelist)
rte_cpuset_t service_cpuset;
CPU_ZERO(&service_cpuset);
for (i = 0; i < RTE_MAX_LCORE; i++) {
- if (runtime_state->lcore_role[i] == ROLE_SERVICE)
+ if (runtime_state->lcore_cfg[i].role == ROLE_SERVICE)
CPU_SET(i, &service_cpuset);
}
if (CPU_COUNT(&service_cpuset) > 0) {
@@ -1179,12 +1179,12 @@ eal_parse_main_lcore(const char *arg)
return -1;
/* ensure main core is not used as service core */
- if (runtime_state->lcore_role[cfg->main_lcore] == ROLE_SERVICE) {
+ if (runtime_state->lcore_cfg[cfg->main_lcore].role == ROLE_SERVICE) {
EAL_LOG(ERR, "Error: Main lcore is used as a service core");
return -1;
}
/* check that we have the core recorded in the core list */
- if (runtime_state->lcore_role[cfg->main_lcore] != ROLE_RTE) {
+ if (runtime_state->lcore_cfg[cfg->main_lcore].role != ROLE_RTE) {
EAL_LOG(ERR, "Error: Main lcore is not enabled for DPDK");
return -1;
}
@@ -1373,7 +1373,7 @@ eal_parse_lcores(const char *lcores)
/* Reset lcore config */
for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
- runtime_state->lcore_role[idx] = ROLE_OFF;
+ runtime_state->lcore_cfg[idx].role = ROLE_OFF;
runtime_state->lcore_cfg[idx].core_index = -1;
CPU_ZERO(&runtime_state->lcore_cfg[idx].cpuset);
runtime_state->lcore_cfg[idx].first_cpu = UINT16_MAX;
@@ -1436,9 +1436,9 @@ eal_parse_lcores(const char *lcores)
continue;
set_count--;
- if (runtime_state->lcore_role[idx] != ROLE_RTE) {
+ if (runtime_state->lcore_cfg[idx].role != ROLE_RTE) {
runtime_state->lcore_cfg[idx].core_index = count;
- runtime_state->lcore_role[idx] = ROLE_RTE;
+ runtime_state->lcore_cfg[idx].role = ROLE_RTE;
count++;
}
diff --git a/lib/eal/common/eal_internal_cfg.h b/lib/eal/common/eal_internal_cfg.h
index d46d3f59d3..41a1437435 100644
--- a/lib/eal/common/eal_internal_cfg.h
+++ b/lib/eal/common/eal_internal_cfg.h
@@ -116,6 +116,7 @@ struct eal_platform_info {
*/
struct lcore_cfg {
int core_index; /**< relative index, starting from 0 */
+ enum rte_lcore_role_t role; /**< role assigned to this lcore */
rte_cpuset_t cpuset; /**< cpu set which the lcore affinity to */
uint16_t first_cpu; /**< lowest CPU set in cpuset, UINT16_MAX if none */
/* Fields for executing code on a remote lcore */
@@ -138,7 +139,6 @@ struct eal_runtime_state {
volatile unsigned int init_complete;
/**< indicates whether EAL has completed initialization */
uint32_t lcore_count; /**< Number of active lcore IDs (role != ROLE_OFF). */
- enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE]; /**< State of cores. */
struct lcore_cfg lcore_cfg[RTE_MAX_LCORE];
};
diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c
index 36ef2d32a7..e28e17f8d5 100644
--- a/lib/eal/common/rte_service.c
+++ b/lib/eal/common/rte_service.c
@@ -108,7 +108,7 @@ rte_service_init(void)
const struct rte_config *cfg = rte_eal_get_configuration();
const struct eal_runtime_state *runtime_state = eal_get_runtime_state();
for (i = 0; i < RTE_MAX_LCORE; i++) {
- if (runtime_state->lcore_role[i] == ROLE_SERVICE) {
+ if (runtime_state->lcore_cfg[i].role == ROLE_SERVICE) {
if ((unsigned int)i == cfg->main_lcore)
continue;
rte_service_lcore_add(i);
@@ -712,7 +712,7 @@ set_lcore_state(uint32_t lcore, int32_t state)
{
struct eal_runtime_state *runtime_state = eal_get_runtime_state();
struct core_state *cs = RTE_LCORE_VAR_LCORE(lcore, lcore_states);
- runtime_state->lcore_role[lcore] = state;
+ runtime_state->lcore_cfg[lcore].role = state;
/* update per-lcore optimized state tracking */
cs->is_service_core = (state == ROLE_SERVICE);
@@ -1124,7 +1124,7 @@ rte_service_dump(FILE *f, uint32_t id)
fprintf(f, "Service Cores Summary\n");
for (i = 0; i < RTE_MAX_LCORE; i++) {
- if (runtime_state->lcore_role[i] != ROLE_SERVICE)
+ if (runtime_state->lcore_cfg[i].role != ROLE_SERVICE)
continue;
service_dump_calls_per_lcore(f, i);
--
2.51.0
next prev parent reply other threads:[~2026-04-29 17:01 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 16:57 [RFC PATCH 00/44] Allow intitializing EAL without argc/argv Bruce Richardson
2026-04-29 16:57 ` [RFC PATCH 01/44] eal: define new functionally distinct config structs Bruce Richardson
2026-04-29 19:03 ` Stephen Hemminger
2026-04-30 7:56 ` Bruce Richardson
2026-04-29 16:57 ` [RFC PATCH 02/44] eal: move memory request fields to user config Bruce Richardson
2026-04-29 16:57 ` [RFC PATCH 03/44] eal: move NUMA " Bruce Richardson
2026-04-29 16:57 ` [RFC PATCH 04/44] eal: move hugepage policy " Bruce Richardson
2026-04-29 16:57 ` [RFC PATCH 05/44] eal: move process " Bruce Richardson
2026-04-29 16:57 ` [RFC PATCH 06/44] eal: move advanced user config options to user cfg struct Bruce Richardson
2026-04-29 16:57 ` [RFC PATCH 07/44] eal: move hugepage size info to platform info struct Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 08/44] telemetry: make cpuset init parameter const Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 09/44] eal: move runtime state to appropriate structure Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 10/44] eal: record details of all cpus in platform info Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 11/44] eal: use platform info for lcore lookups Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 12/44] eal: add RTE_CPU_FFS macro Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 13/44] eal: store lcore configuration in runtime data Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 14/44] eal: cleanup CPU init function Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 15/44] eal: move numa node information to platform info struct Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 16/44] eal: move lcore role and count to runtime state Bruce Richardson
2026-04-29 16:58 ` Bruce Richardson [this message]
2026-04-29 16:58 ` [RFC PATCH 18/44] eal: move main lcore setting to runtime config struct Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 19/44] eal: move iova mode and process type to runtime cfg Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 20/44] eal: move memory config pointer to runtime state struct Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 21/44] eal: remove rte_config structure Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 22/44] eal: separate runtime state update from arg parsing Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 23/44] eal: move devopt_list staging list into user_cfg Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 24/44] eal: separate plugin paths from loaded plugin objects Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 25/44] eal: simplify internal driver path iteration APIs Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 26/44] eal: move trace config into user config struct Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 27/44] eal: record service cores in " Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 28/44] eal: store user-provided lcore info " Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 29/44] eal: clarify docs on params taking lcore IDs Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 30/44] eal: remove internal config reset function Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 31/44] eal: move functions setting runtime state Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 32/44] eal: initialize platform info on first use Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 33/44] eal: remove duplicated scan of sysfs for hugepage details Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 34/44] eal: add utilities for working with user config struct Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 35/44] eal: split EAL init into two stages Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 36/44] eal: provide hooks for init with externally supplied config Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 37/44] eal_cfg: add new library to programmatically init DPDK Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 38/44] eal_cfg: configure defaults for easier testing and use Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 39/44] app/test: enable testing init using EAL config lib Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 40/44] eal_cfg: add basic setters and getters Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 41/44] eal_cfg: add hugepage memory configuration Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 42/44] eal_cfg: support configuring lcores Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 43/44] eal_cfg: support device and driver lists Bruce Richardson
2026-04-29 16:58 ` [RFC PATCH 44/44] eal_cfg: add APIs for configuring remaining init settings Bruce Richardson
2026-04-29 21:40 ` [RFC PATCH 00/44] Allow intitializing EAL without argc/argv Stephen Hemminger
2026-04-29 22:04 ` Stephen Hemminger
2026-04-30 8:00 ` Bruce Richardson
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=20260429165845.2136843-18-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=techboard@dpdk.org \
/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