* [RFC PATCH 1/3] eal: centralize core parameter parsing
2025-03-13 11:38 [RFC PATCH 0/3] allow easier use of high lcore-ids Bruce Richardson
@ 2025-03-13 11:38 ` Bruce Richardson
2025-03-13 11:38 ` [RFC PATCH 2/3] eal: convert core masks and lists to core sets Bruce Richardson
2025-03-13 11:38 ` [RFC PATCH 3/3] eal: allow automatic mapping of high lcore ids Bruce Richardson
2 siblings, 0 replies; 4+ messages in thread
From: Bruce Richardson @ 2025-03-13 11:38 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
Rather than parsing the lcore parameters as they are encountered, just
save off the lcore parameters and then parse them at the end. This
allows better knowledge of what parameters are available or not when
parsing.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/eal/common/eal_common_options.c | 183 +++++++++++++---------------
1 file changed, 84 insertions(+), 99 deletions(-)
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 79db9a47dd..55c49a923f 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -151,7 +151,13 @@ TAILQ_HEAD_INITIALIZER(devopt_list);
static int main_lcore_parsed;
static int mem_parsed;
-static int core_parsed;
+static struct lcore_options {
+ const char *core_mask_opt;
+ const char *core_list_opt;
+ const char *core_map_opt;
+ const char *service_mask_opt;
+ const char *service_list_opt;
+} lcore_options = {0};
/* Allow the application to print its usage message too if set */
static rte_usage_hook_t rte_application_usage_hook;
@@ -674,7 +680,7 @@ eal_parse_service_coremask(const char *coremask)
if (count == 0)
return -1;
- if (core_parsed && taken_lcore_count != count) {
+ if (taken_lcore_count != count) {
EAL_LOG(WARNING,
"Not all service cores are in the coremask. "
"Please ensure -c or -l includes service cores");
@@ -684,17 +690,6 @@ eal_parse_service_coremask(const char *coremask)
return 0;
}
-static int
-eal_service_cores_parsed(void)
-{
- int idx;
- for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
- if (lcore_config[idx].core_role == ROLE_SERVICE)
- return 1;
- }
- return 0;
-}
-
static int
update_lcore_config(int *cores)
{
@@ -903,7 +898,7 @@ eal_parse_service_corelist(const char *corelist)
if (count == 0)
return -1;
- if (core_parsed && taken_lcore_count != count) {
+ if (taken_lcore_count != count) {
EAL_LOG(WARNING,
"Not all service cores were in the coremask. "
"Please ensure -c or -l includes service cores");
@@ -1673,83 +1668,20 @@ eal_parse_common_option(int opt, const char *optarg,
a_used = 1;
break;
/* coremask */
- case 'c': {
- int lcore_indexes[RTE_MAX_LCORE];
-
- if (eal_service_cores_parsed())
- EAL_LOG(WARNING,
- "Service cores parsed before dataplane cores. Please ensure -c is before -s or -S");
- if (rte_eal_parse_coremask(optarg, lcore_indexes) < 0) {
- EAL_LOG(ERR, "invalid coremask syntax");
- return -1;
- }
- if (update_lcore_config(lcore_indexes) < 0) {
- char *available = available_cores();
-
- EAL_LOG(ERR,
- "invalid coremask, please check specified cores are part of %s",
- available);
- free(available);
- return -1;
- }
-
- if (core_parsed) {
- EAL_LOG(ERR, "Option -c is ignored, because (%s) is set!",
- (core_parsed == LCORE_OPT_LST) ? "-l" :
- (core_parsed == LCORE_OPT_MAP) ? "--lcores" :
- "-c");
- return -1;
- }
-
- core_parsed = LCORE_OPT_MSK;
+ case 'c':
+ lcore_options.core_mask_opt = optarg;
break;
- }
/* corelist */
- case 'l': {
- int lcore_indexes[RTE_MAX_LCORE];
-
- if (eal_service_cores_parsed())
- EAL_LOG(WARNING,
- "Service cores parsed before dataplane cores. Please ensure -l is before -s or -S");
-
- if (eal_parse_corelist(optarg, lcore_indexes) < 0) {
- EAL_LOG(ERR, "invalid core list syntax");
- return -1;
- }
- if (update_lcore_config(lcore_indexes) < 0) {
- char *available = available_cores();
-
- EAL_LOG(ERR,
- "invalid core list, please check specified cores are part of %s",
- available);
- free(available);
- return -1;
- }
-
- if (core_parsed) {
- EAL_LOG(ERR, "Option -l is ignored, because (%s) is set!",
- (core_parsed == LCORE_OPT_MSK) ? "-c" :
- (core_parsed == LCORE_OPT_MAP) ? "--lcores" :
- "-l");
- return -1;
- }
-
- core_parsed = LCORE_OPT_LST;
+ case 'l':
+ lcore_options.core_list_opt = optarg;
break;
- }
/* service coremask */
case 's':
- if (eal_parse_service_coremask(optarg) < 0) {
- EAL_LOG(ERR, "invalid service coremask");
- return -1;
- }
+ lcore_options.service_mask_opt = optarg;
break;
/* service corelist */
case 'S':
- if (eal_parse_service_corelist(optarg) < 0) {
- EAL_LOG(ERR, "invalid service core list");
- return -1;
- }
+ lcore_options.service_list_opt = optarg;
break;
/* size of memory */
case 'm':
@@ -1918,21 +1850,7 @@ eal_parse_common_option(int opt, const char *optarg,
#endif /* !RTE_EXEC_ENV_WINDOWS */
case OPT_LCORES_NUM:
- if (eal_parse_lcores(optarg) < 0) {
- EAL_LOG(ERR, "invalid parameter for --"
- OPT_LCORES);
- return -1;
- }
-
- if (core_parsed) {
- EAL_LOG(ERR, "Option --lcores is ignored, because (%s) is set!",
- (core_parsed == LCORE_OPT_LST) ? "-l" :
- (core_parsed == LCORE_OPT_MSK) ? "-c" :
- "--lcores");
- return -1;
- }
-
- core_parsed = LCORE_OPT_MAP;
+ lcore_options.core_map_opt = optarg;
break;
case OPT_LEGACY_MEM_NUM:
conf->legacy_mem = 1;
@@ -1973,6 +1891,7 @@ eal_parse_common_option(int opt, const char *optarg,
}
+
return 0;
ba_conflict:
@@ -2046,8 +1965,74 @@ eal_adjust_config(struct internal_config *internal_cfg)
struct internal_config *internal_conf =
eal_get_internal_configuration();
- if (!core_parsed)
+ /* handle all the various core options, ignoring order of them.
+ * First check that multiple lcore options (coremask, corelist, coremap) are
+ * not used together. Then check that the service options (coremask, corelist)
+ * are not both set. In both cases error out if multiple options are set.
+ */
+ if ((lcore_options.core_mask_opt && lcore_options.core_list_opt) ||
+ (lcore_options.core_mask_opt && lcore_options.core_map_opt) ||
+ (lcore_options.core_list_opt && lcore_options.core_map_opt)) {
+ EAL_LOG(ERR, "Only one of -c, -l and --"OPT_LCORES" may be given at a time");
+ return -1;
+ }
+ if ((lcore_options.service_mask_opt && lcore_options.service_list_opt)) {
+ EAL_LOG(ERR, "Only one of -s and -S may be given at a time");
+ return -1;
+ }
+
+ if (lcore_options.core_mask_opt) {
+ int lcore_indexes[RTE_MAX_LCORE];
+
+ if (rte_eal_parse_coremask(lcore_options.core_mask_opt, lcore_indexes) < 0) {
+ EAL_LOG(ERR, "invalid coremask syntax");
+ return -1;
+ }
+ if (update_lcore_config(lcore_indexes) < 0) {
+ char *available = available_cores();
+
+ EAL_LOG(ERR,
+ "invalid coremask, please check specified cores are part of %s",
+ available);
+ free(available);
+ return -1;
+ }
+ } else if (lcore_options.core_list_opt) {
+ int lcore_indexes[RTE_MAX_LCORE];
+
+ if (eal_parse_corelist(lcore_options.core_list_opt, lcore_indexes) < 0) {
+ EAL_LOG(ERR, "invalid core list syntax");
+ return -1;
+ }
+ if (update_lcore_config(lcore_indexes) < 0) {
+ char *available = available_cores();
+
+ EAL_LOG(ERR,
+ "invalid core list, please check specified cores are part of %s",
+ available);
+ free(available);
+ return -1;
+ }
+ } else if (lcore_options.core_map_opt) {
+ if (eal_parse_lcores(lcore_options.core_map_opt) < 0) {
+ EAL_LOG(ERR, "invalid parameter for --" OPT_LCORES);
+ return -1;
+ }
+ } else {
eal_auto_detect_cores(cfg);
+ }
+
+ if (lcore_options.service_mask_opt) {
+ if (eal_parse_service_coremask(lcore_options.service_mask_opt) < 0) {
+ EAL_LOG(ERR, "invalid service coremask");
+ return -1;
+ }
+ } else if (lcore_options.service_list_opt) {
+ if (eal_parse_service_corelist(lcore_options.service_list_opt) < 0) {
+ EAL_LOG(ERR, "invalid service core list");
+ return -1;
+ }
+ }
if (internal_conf->process_type == RTE_PROC_AUTO)
internal_conf->process_type = eal_proc_type_detect();
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC PATCH 2/3] eal: convert core masks and lists to core sets
2025-03-13 11:38 [RFC PATCH 0/3] allow easier use of high lcore-ids Bruce Richardson
2025-03-13 11:38 ` [RFC PATCH 1/3] eal: centralize core parameter parsing Bruce Richardson
@ 2025-03-13 11:38 ` Bruce Richardson
2025-03-13 11:38 ` [RFC PATCH 3/3] eal: allow automatic mapping of high lcore ids Bruce Richardson
2 siblings, 0 replies; 4+ messages in thread
From: Bruce Richardson @ 2025-03-13 11:38 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
Rather than directly parsing and working with the core mask and core
list parameters, convert them into core maps, and centralise all core
parsing there. This allows future work to adjust the mappings of cores
when generating that mapping parameter.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
NOTE: this does change the behaviour of the internal API rte_eal_parse
core_mask, used by dlb driver. However, since this is an internal API
changing behaviour should be allowed AFAIK.
---
drivers/event/dlb2/dlb2_priv.h | 2 -
drivers/event/dlb2/pf/base/dlb2_resource.c | 48 ++---
lib/eal/common/eal_common_options.c | 193 ++++-----------------
3 files changed, 53 insertions(+), 190 deletions(-)
diff --git a/drivers/event/dlb2/dlb2_priv.h b/drivers/event/dlb2/dlb2_priv.h
index 52da31ed31..63c0bea155 100644
--- a/drivers/event/dlb2/dlb2_priv.h
+++ b/drivers/event/dlb2/dlb2_priv.h
@@ -737,8 +737,6 @@ void dlb2_event_build_hcws(struct dlb2_port *qm_port,
uint8_t *sched_type,
uint8_t *queue_id);
-/* Extern functions */
-extern int rte_eal_parse_coremask(const char *coremask, int *cores);
/* Extern globals */
extern struct process_local_port_data dlb2_port[][DLB2_NUM_PORT_TYPES];
diff --git a/drivers/event/dlb2/pf/base/dlb2_resource.c b/drivers/event/dlb2/pf/base/dlb2_resource.c
index 3004902118..c4bc248afc 100644
--- a/drivers/event/dlb2/pf/base/dlb2_resource.c
+++ b/drivers/event/dlb2/pf/base/dlb2_resource.c
@@ -922,49 +922,31 @@ dlb2_resource_probe(struct dlb2_hw *hw, const void *probe_args)
{
const struct dlb2_devargs *args = (const struct dlb2_devargs *)probe_args;
const char *mask = args ? args->producer_coremask : NULL;
- int cpu = 0, cnt = 0, cores[RTE_MAX_LCORE], i;
+ int cpu = 0;
if (args) {
mask = (const char *)args->producer_coremask;
}
- if (mask && rte_eal_parse_coremask(mask, cores)) {
- DLB2_HW_ERR(hw, ": Invalid producer coremask=%s\n", mask);
- return -1;
- }
-
+ cpu = rte_get_next_lcore(-1, 1, 0);
hw->num_prod_cores = 0;
- for (i = 0; i < RTE_MAX_LCORE; i++) {
- bool is_pcore = (mask && cores[i] != -1);
-
- if (rte_lcore_is_enabled(i)) {
- if (is_pcore) {
- /*
- * Populate the producer cores from parsed
- * coremask
- */
- hw->prod_core_list[cores[i]] = i;
- hw->num_prod_cores++;
-
- } else if ((++cnt == DLB2_EAL_PROBE_CORE ||
- rte_lcore_count() < DLB2_EAL_PROBE_CORE)) {
- /*
- * If no producer coremask is provided, use the
- * second EAL core to probe
- */
- cpu = i;
- break;
- }
- } else if (is_pcore) {
- DLB2_HW_ERR(hw, "Producer coremask(%s) must be a subset of EAL coremask\n",
- mask);
+ if (mask) {
+ int n = rte_eal_parse_coremask(mask, hw->prod_core_list);
+ if (n <= 0) {
+ DLB2_HW_ERR(hw, ": Invalid producer coremask=%s\n", mask);
return -1;
}
+ hw->num_prod_cores = n;
+ cpu = hw->prod_core_list[0];
+ for (u8 i = 0; i < hw->num_prod_cores; i++) {
+ if (!rte_lcore_is_enabled(hw->prod_core_list[i])) {
+ DLB2_HW_ERR(hw, "Producer coremask(%s) must be a subset of EAL coremask\n",
+ mask);
+ return -1;
+ }
+ }
}
- /* Use the first core in producer coremask to probe */
- if (hw->num_prod_cores)
- cpu = hw->prod_core_list[0];
dlb2_get_pp_allocation(hw, cpu, DLB2_LDB_PORT);
dlb2_get_pp_allocation(hw, cpu, DLB2_DIR_PORT);
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 55c49a923f..807ba760ce 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -690,33 +690,6 @@ eal_parse_service_coremask(const char *coremask)
return 0;
}
-static int
-update_lcore_config(int *cores)
-{
- struct rte_config *cfg = rte_eal_get_configuration();
- unsigned int count = 0;
- unsigned int i;
- int ret = 0;
-
- for (i = 0; i < RTE_MAX_LCORE; i++) {
- if (cores[i] != -1) {
- if (eal_cpu_detected(i) == 0) {
- EAL_LOG(ERR, "lcore %u unavailable", i);
- ret = -1;
- continue;
- }
- cfg->lcore_role[i] = ROLE_RTE;
- count++;
- } else {
- cfg->lcore_role[i] = ROLE_OFF;
- }
- lcore_config[i].core_index = cores[i];
- }
- if (!ret)
- cfg->lcore_count = count;
- return ret;
-}
-
static int
check_core_list(int *lcores, unsigned int count)
{
@@ -759,7 +732,6 @@ int
rte_eal_parse_coremask(const char *coremask, int *cores)
{
const char *coremask_orig = coremask;
- int lcores[RTE_MAX_LCORE];
unsigned int count = 0;
int i, j, idx;
int val;
@@ -803,30 +775,19 @@ rte_eal_parse_coremask(const char *coremask, int *cores)
RTE_MAX_LCORE);
return -1;
}
- lcores[count++] = idx;
+ cores[count++] = idx;
}
}
}
if (count == 0) {
- EAL_LOG(ERR, "No lcores in coremask: [%s]",
- coremask_orig);
+ EAL_LOG(ERR, "No lcores in coremask: [%s]", coremask_orig);
return -1;
}
- if (check_core_list(lcores, count))
+ if (check_core_list(cores, count) != 0)
return -1;
- /*
- * Now that we've got a list of cores no longer than RTE_MAX_LCORE,
- * and no lcore in that list is greater than RTE_MAX_LCORE, populate
- * the cores array.
- */
- do {
- count--;
- cores[lcores[count]] = count;
- } while (count != 0);
-
- return 0;
+ return count;
}
static int
@@ -911,7 +872,6 @@ static int
eal_parse_corelist(const char *corelist, int *cores)
{
unsigned int count = 0, i;
- int lcores[RTE_MAX_LCORE];
char *end = NULL;
int min, max;
int idx;
@@ -949,7 +909,7 @@ eal_parse_corelist(const char *corelist, int *cores)
/* Check if this idx is already present */
for (i = 0; i < count; i++) {
- if (lcores[i] == idx)
+ if (cores[i] == idx)
dup = true;
}
if (dup)
@@ -959,7 +919,7 @@ eal_parse_corelist(const char *corelist, int *cores)
RTE_MAX_LCORE);
return -1;
}
- lcores[count++] = idx;
+ cores[count++] = idx;
}
min = -1;
} else
@@ -967,23 +927,15 @@ eal_parse_corelist(const char *corelist, int *cores)
corelist = end + 1;
} while (*end != '\0');
- if (count == 0)
+ if (count == 0) {
+ EAL_LOG(ERR, "No lcores in corelist");
return -1;
+ }
- if (check_core_list(lcores, count))
+ if (check_core_list(cores, count))
return -1;
- /*
- * Now that we've got a list of cores no longer than RTE_MAX_LCORE,
- * and no lcore in that list is greater than RTE_MAX_LCORE, populate
- * the cores array.
- */
- do {
- count--;
- cores[lcores[count]] = count;
- } while (count != 0);
-
- return 0;
+ return count;
}
/* Changes the lcore id of the main thread */
@@ -1500,75 +1452,6 @@ eal_parse_base_virtaddr(const char *arg)
return 0;
}
-/* caller is responsible for freeing the returned string */
-static char *
-available_cores(void)
-{
- char *str = NULL;
- int previous;
- int sequence;
- char *tmp;
- int idx;
-
- /* find the first available cpu */
- for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
- if (eal_cpu_detected(idx) == 0)
- continue;
- break;
- }
- if (idx >= RTE_MAX_LCORE)
- return NULL;
-
- /* first sequence */
- if (asprintf(&str, "%d", idx) < 0)
- return NULL;
- previous = idx;
- sequence = 0;
-
- for (idx++ ; idx < RTE_MAX_LCORE; idx++) {
- if (eal_cpu_detected(idx) == 0)
- continue;
-
- if (idx == previous + 1) {
- previous = idx;
- sequence = 1;
- continue;
- }
-
- /* finish current sequence */
- if (sequence) {
- if (asprintf(&tmp, "%s-%d", str, previous) < 0) {
- free(str);
- return NULL;
- }
- free(str);
- str = tmp;
- }
-
- /* new sequence */
- if (asprintf(&tmp, "%s,%d", str, idx) < 0) {
- free(str);
- return NULL;
- }
- free(str);
- str = tmp;
- previous = idx;
- sequence = 0;
- }
-
- /* finish last sequence */
- if (sequence) {
- if (asprintf(&tmp, "%s-%d", str, previous) < 0) {
- free(str);
- return NULL;
- }
- free(str);
- str = tmp;
- }
-
- return str;
-}
-
#define HUGE_UNLINK_NEVER "never"
static int
@@ -1981,43 +1864,43 @@ eal_adjust_config(struct internal_config *internal_cfg)
return -1;
}
- if (lcore_options.core_mask_opt) {
- int lcore_indexes[RTE_MAX_LCORE];
-
- if (rte_eal_parse_coremask(lcore_options.core_mask_opt, lcore_indexes) < 0) {
- EAL_LOG(ERR, "invalid coremask syntax");
- return -1;
- }
- if (update_lcore_config(lcore_indexes) < 0) {
- char *available = available_cores();
- EAL_LOG(ERR,
- "invalid coremask, please check specified cores are part of %s",
- available);
- free(available);
- return -1;
- }
- } else if (lcore_options.core_list_opt) {
+ if (lcore_options.core_mask_opt || lcore_options.core_list_opt) {
int lcore_indexes[RTE_MAX_LCORE];
+ int nb_indexes = lcore_options.core_list_opt ?
+ eal_parse_corelist(lcore_options.core_list_opt, lcore_indexes) :
+ rte_eal_parse_coremask(lcore_options.core_mask_opt, lcore_indexes);
- if (eal_parse_corelist(lcore_options.core_list_opt, lcore_indexes) < 0) {
- EAL_LOG(ERR, "invalid core list syntax");
+ if (nb_indexes < 0)
return -1;
- }
- if (update_lcore_config(lcore_indexes) < 0) {
- char *available = available_cores();
- EAL_LOG(ERR,
- "invalid core list, please check specified cores are part of %s",
- available);
- free(available);
- return -1;
+ char *core_map_opt = malloc(RTE_MAX_LCORE * 10);
+ size_t core_map_len = 0;
+ for (i = 0; i < nb_indexes; i++) {
+ if (!eal_cpu_detected(lcore_indexes[i])) {
+ EAL_LOG(ERR, "core %d not present", lcore_indexes[i]);
+ return -1;
+ }
+ int n = snprintf(core_map_opt + core_map_len,
+ (RTE_MAX_LCORE * 10) - core_map_len,
+ "%s%d", i == 0 ? "" : ",", lcore_indexes[i]);
+ if (n < 0 || (size_t)n >= (RTE_MAX_LCORE * 10) - core_map_len) {
+ EAL_LOG(ERR, "core map string too long");
+ return -1;
+ }
+ core_map_len += n;
}
- } else if (lcore_options.core_map_opt) {
+ lcore_options.core_map_opt = core_map_opt;
+ printf("Generated core map: %s\n", lcore_options.core_map_opt);
+ }
+
+ if (lcore_options.core_map_opt) {
if (eal_parse_lcores(lcore_options.core_map_opt) < 0) {
EAL_LOG(ERR, "invalid parameter for --" OPT_LCORES);
return -1;
}
+ if (lcore_options.core_mask_opt || lcore_options.core_list_opt)
+ free(RTE_CAST_PTR(void *,lcore_options.core_map_opt));
} else {
eal_auto_detect_cores(cfg);
}
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC PATCH 3/3] eal: allow automatic mapping of high lcore ids
2025-03-13 11:38 [RFC PATCH 0/3] allow easier use of high lcore-ids Bruce Richardson
2025-03-13 11:38 ` [RFC PATCH 1/3] eal: centralize core parameter parsing Bruce Richardson
2025-03-13 11:38 ` [RFC PATCH 2/3] eal: convert core masks and lists to core sets Bruce Richardson
@ 2025-03-13 11:38 ` Bruce Richardson
2 siblings, 0 replies; 4+ messages in thread
From: Bruce Richardson @ 2025-03-13 11:38 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
To use cores with IDs greater than RTE_MAX_LCORE the user must provide a
mapping of those higher core numbers to ids within the 0 - RTE_MAX_LCORE
range. This can be awkward to do manually when more than a few lcores
are involved, so instead we can provide an extra option to EAL to do
this manually.
This patch therefore introduces the "map-lcore-ids" flag, which
automatically maps all provided lcore numbers to start at zero.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/event/dlb2/pf/base/dlb2_resource.c | 2 +-
lib/eal/common/eal_common_options.c | 32 ++++++++++++++--------
lib/eal/common/eal_options.h | 2 ++
lib/eal/include/rte_eal.h | 2 +-
4 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/drivers/event/dlb2/pf/base/dlb2_resource.c b/drivers/event/dlb2/pf/base/dlb2_resource.c
index c4bc248afc..541a16db24 100644
--- a/drivers/event/dlb2/pf/base/dlb2_resource.c
+++ b/drivers/event/dlb2/pf/base/dlb2_resource.c
@@ -931,7 +931,7 @@ dlb2_resource_probe(struct dlb2_hw *hw, const void *probe_args)
cpu = rte_get_next_lcore(-1, 1, 0);
hw->num_prod_cores = 0;
if (mask) {
- int n = rte_eal_parse_coremask(mask, hw->prod_core_list);
+ int n = rte_eal_parse_coremask(mask, hw->prod_core_list, true);
if (n <= 0) {
DLB2_HW_ERR(hw, ": Invalid producer coremask=%s\n", mask);
return -1;
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 807ba760ce..107b9eaad5 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -106,6 +106,7 @@ eal_long_options[] = {
{OPT_NO_TELEMETRY, 0, NULL, OPT_NO_TELEMETRY_NUM },
{OPT_FORCE_MAX_SIMD_BITWIDTH, 1, NULL, OPT_FORCE_MAX_SIMD_BITWIDTH_NUM},
{OPT_HUGE_WORKER_STACK, 2, NULL, OPT_HUGE_WORKER_STACK_NUM },
+ {OPT_MAP_LCORE_IDS, 0, NULL, OPT_MAP_LCORE_IDS_NUM },
{0, 0, NULL, 0 }
};
@@ -152,6 +153,7 @@ TAILQ_HEAD_INITIALIZER(devopt_list);
static int main_lcore_parsed;
static int mem_parsed;
static struct lcore_options {
+ bool map_lcore_ids;
const char *core_mask_opt;
const char *core_list_opt;
const char *core_map_opt;
@@ -723,13 +725,14 @@ check_core_list(int *lcores, unsigned int count)
if (len > 0)
lcorestr[len - 1] = 0;
EAL_LOG(ERR, "To use high physical core ids, "
- "please use --lcores to map them to lcore ids below RTE_MAX_LCORE, "
+ "please use --map-lcore-ids flag to map core ids automatically, "
+ "or use --lcores to map them manually to lcore ids below RTE_MAX_LCORE, "
"e.g. --lcores %s", lcorestr);
return -1;
}
int
-rte_eal_parse_coremask(const char *coremask, int *cores)
+rte_eal_parse_coremask(const char *coremask, int *cores, bool no_check)
{
const char *coremask_orig = coremask;
unsigned int count = 0;
@@ -784,7 +787,7 @@ rte_eal_parse_coremask(const char *coremask, int *cores)
return -1;
}
- if (check_core_list(cores, count) != 0)
+ if (!no_check && check_core_list(cores, count) != 0)
return -1;
return count;
@@ -869,7 +872,7 @@ eal_parse_service_corelist(const char *corelist)
}
static int
-eal_parse_corelist(const char *corelist, int *cores)
+eal_parse_corelist(const char *corelist, int *cores, bool no_check)
{
unsigned int count = 0, i;
char *end = NULL;
@@ -932,7 +935,7 @@ eal_parse_corelist(const char *corelist, int *cores)
return -1;
}
- if (check_core_list(cores, count))
+ if (!no_check && check_core_list(cores, count))
return -1;
return count;
@@ -1767,6 +1770,9 @@ eal_parse_common_option(int opt, const char *optarg,
return -1;
}
break;
+ case OPT_MAP_LCORE_IDS_NUM:
+ lcore_options.map_lcore_ids = true;
+ break;
/* don't know what to do, leave this to caller */
default:
@@ -1866,10 +1872,11 @@ eal_adjust_config(struct internal_config *internal_cfg)
if (lcore_options.core_mask_opt || lcore_options.core_list_opt) {
- int lcore_indexes[RTE_MAX_LCORE];
+ bool map_ids = lcore_options.map_lcore_ids;
+ int idxs[RTE_MAX_LCORE];
int nb_indexes = lcore_options.core_list_opt ?
- eal_parse_corelist(lcore_options.core_list_opt, lcore_indexes) :
- rte_eal_parse_coremask(lcore_options.core_mask_opt, lcore_indexes);
+ eal_parse_corelist(lcore_options.core_list_opt, idxs, map_ids) :
+ rte_eal_parse_coremask(lcore_options.core_mask_opt, idxs, map_ids);
if (nb_indexes < 0)
return -1;
@@ -1877,13 +1884,16 @@ eal_adjust_config(struct internal_config *internal_cfg)
char *core_map_opt = malloc(RTE_MAX_LCORE * 10);
size_t core_map_len = 0;
for (i = 0; i < nb_indexes; i++) {
- if (!eal_cpu_detected(lcore_indexes[i])) {
- EAL_LOG(ERR, "core %d not present", lcore_indexes[i]);
+ if (!eal_cpu_detected(idxs[i])) {
+ EAL_LOG(ERR, "core %d not present", idxs[i]);
return -1;
}
int n = snprintf(core_map_opt + core_map_len,
(RTE_MAX_LCORE * 10) - core_map_len,
- "%s%d", i == 0 ? "" : ",", lcore_indexes[i]);
+ "%s%d@%d",
+ i == 0 ? "" : ",",
+ map_ids ? i: idxs[i],
+ idxs[i]);
if (n < 0 || (size_t)n >= (RTE_MAX_LCORE * 10) - core_map_len) {
EAL_LOG(ERR, "core map string too long");
return -1;
diff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h
index 95fb4f6108..384c2d016e 100644
--- a/lib/eal/common/eal_options.h
+++ b/lib/eal/common/eal_options.h
@@ -93,6 +93,8 @@ enum {
OPT_FORCE_MAX_SIMD_BITWIDTH_NUM,
#define OPT_HUGE_WORKER_STACK "huge-worker-stack"
OPT_HUGE_WORKER_STACK_NUM,
+#define OPT_MAP_LCORE_IDS "map-lcore-ids"
+ OPT_MAP_LCORE_IDS_NUM,
OPT_LONG_MAX_NUM
};
diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h
index c826e143f1..a53fb29c45 100644
--- a/lib/eal/include/rte_eal.h
+++ b/lib/eal/include/rte_eal.h
@@ -508,7 +508,7 @@ rte_eal_get_runtime_dir(void);
*/
__rte_internal
int
-rte_eal_parse_coremask(const char *coremask, int *cores);
+rte_eal_parse_coremask(const char *coremask, int *cores, bool nocheck);
#ifdef __cplusplus
}
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread