From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: david.marchand@redhat.com, mb@smartsharesystems.com,
stephen@networkplumber.org,
Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH v3 2/4] eal: merge corelist and core mapping options
Date: Fri, 2 May 2025 16:11:32 +0100 [thread overview]
Message-ID: <20250502151134.536799-3-bruce.richardson@intel.com> (raw)
In-Reply-To: <20250502151134.536799-1-bruce.richardson@intel.com>
The "-l" EAL parameter supported a subset of the features that were
provided by the "--lcores" long option. There is no need to have two
different options with different behaviour in this case, so we can just
eliminate the special-case handling for "-l", and have it as a shortened
form of "--lcores".
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
doc/guides/linux_gsg/eal_args.include.rst | 10 +-
.../prog_guide/env_abstraction_layer.rst | 3 +-
lib/eal/common/eal_common_options.c | 135 ++----------------
lib/eal/common/eal_options.h | 4 +-
4 files changed, 21 insertions(+), 131 deletions(-)
diff --git a/doc/guides/linux_gsg/eal_args.include.rst b/doc/guides/linux_gsg/eal_args.include.rst
index 7ffd2e2535..01fe6a3006 100644
--- a/doc/guides/linux_gsg/eal_args.include.rst
+++ b/doc/guides/linux_gsg/eal_args.include.rst
@@ -4,16 +4,14 @@
Lcore-related options
~~~~~~~~~~~~~~~~~~~~~
-* ``-l <core list>``
+* ``-l/--lcores <core list>``
List of cores to run on
- The argument format is ``<c1>[-c2][,c3[-c4],...]``
- where ``c1``, ``c2``, etc are core indexes between 0 and 128.
+ Simplest argument format is ``<c1>[-c2][,c3[-c4],...]``
+ where ``c1``, ``c2``, etc are core indexes between 0 and ``RTE_MAX_LCORE`` (default 128).
-* ``--lcores <core map>``
-
- Map lcore set to physical cpu set
+ This argument can also be used to map lcore set to physical cpu set
The argument format is::
diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst
index 04214a05b2..fca9cc0afa 100644
--- a/doc/guides/prog_guide/env_abstraction_layer.rst
+++ b/doc/guides/prog_guide/env_abstraction_layer.rst
@@ -729,7 +729,7 @@ As EAL pthreads usually bind 1:1 to the physical CPU, the *_lcore_id* is typical
When using multiple pthreads, however, the binding is no longer always 1:1 between an EAL pthread and a specified physical CPU.
The EAL pthread may have affinity to a CPU set, and as such the *_lcore_id* will not be the same as the CPU ID.
-For this reason, there is an EAL long option '--lcores' defined to assign the CPU affinity of lcores.
+For this reason, there is an EAL option ``--lcores`` (or just ``-l``) defined to assign the CPU affinity of lcores.
For a specified lcore ID or ID group, the option allows setting the CPU set for that EAL pthread.
The format pattern:
@@ -753,7 +753,6 @@ If a '\@cpu_set' value is not supplied, the value of 'cpu_set' will default to t
lcore 8 runs on cpuset 0x100 (cpu 8).
Using this option, for each given lcore ID, the associated CPUs can be assigned.
-It's also compatible with the pattern of corelist('-l') option.
non-EAL pthread support
~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 19c5997c7c..ed514ec1d1 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -46,7 +46,6 @@
#define BITS_PER_HEX 4
#define LCORE_OPT_LST 1
#define LCORE_OPT_MSK 2
-#define LCORE_OPT_MAP 3
const char
eal_short_options[] =
@@ -921,85 +920,6 @@ eal_parse_service_corelist(const char *corelist)
return 0;
}
-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;
-
- for (idx = 0; idx < RTE_MAX_LCORE; idx++)
- cores[idx] = -1;
-
- /* Remove all blank characters ahead */
- while (isblank(*corelist))
- corelist++;
-
- /* Get list of cores */
- min = -1;
- do {
- while (isblank(*corelist))
- corelist++;
- if (*corelist == '\0')
- return -1;
- errno = 0;
- idx = strtol(corelist, &end, 10);
- if (errno || end == NULL)
- return -1;
- if (idx < 0)
- return -1;
- while (isblank(*end))
- end++;
- if (*end == '-') {
- min = idx;
- } else if ((*end == ',') || (*end == '\0')) {
- max = idx;
- if (min == -1)
- min = idx;
- for (idx = min; idx <= max; idx++) {
- bool dup = false;
-
- /* Check if this idx is already present */
- for (i = 0; i < count; i++) {
- if (lcores[i] == idx)
- dup = true;
- }
- if (dup)
- continue;
- if (count >= RTE_MAX_LCORE) {
- EAL_LOG(ERR, "Too many lcores provided. Cannot exceed RTE_MAX_LCORE (%d)",
- RTE_MAX_LCORE);
- return -1;
- }
- lcores[count++] = idx;
- }
- min = -1;
- } else
- return -1;
- corelist = end + 1;
- } while (*end != '\0');
-
- if (count == 0)
- return -1;
-
- if (check_core_list(lcores, 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;
-}
-
/* Changes the lcore id of the main thread */
static int
eal_parse_main_lcore(const char *arg)
@@ -1703,10 +1623,10 @@ eal_parse_common_option(int opt, const char *optarg,
}
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");
+ if (core_parsed == LCORE_OPT_MSK)
+ EAL_LOG(ERR, "Option '-c' passed multiple times to EAL");
+ else
+ EAL_LOG(ERR, "Option -c is ignored, because option -l/--lcores used");
return -1;
}
@@ -1715,31 +1635,20 @@ eal_parse_common_option(int opt, const char *optarg,
}
/* 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);
+ if (eal_parse_lcores(optarg) < 0) {
+ EAL_LOG(ERR, "invalid parameter for -l/--" OPT_LCORES);
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");
+ if (core_parsed == LCORE_OPT_LST)
+ EAL_LOG(ERR, "Core list option passed multiple times to EAL");
+ else
+ EAL_LOG(ERR, "Option '-l/--lcores' is ignored, because coremask option used");
return -1;
}
@@ -1926,23 +1835,6 @@ 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;
- break;
case OPT_LEGACY_MEM_NUM:
conf->legacy_mem = 1;
break;
@@ -2214,10 +2106,11 @@ eal_common_usage(void)
printf("[options]\n\n"
"EAL common options:\n"
" -c COREMASK Hexadecimal bitmask of cores to run on\n"
- " -l CORELIST List of cores to run on\n"
- " The argument format is <c1>[-c2][,c3[-c4],...]\n"
+ " -l, --"OPT_LCORES" CORELIST\n"
+ " List of cores to run on\n"
+ " The basic argument format is <c1>[-c2][,c3[-c4],...]\n"
" where c1, c2, etc are core indexes between 0 and %d\n"
- " --"OPT_LCORES" COREMAP Map lcore set to physical cpu set\n"
+ " Can also be used to map lcore set to physical cpu set\n"
" The argument format is\n"
" '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
" lcores and cpus list are grouped by '(' and ')'\n"
diff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h
index 95fb4f6108..7b84b7d778 100644
--- a/lib/eal/common/eal_options.h
+++ b/lib/eal/common/eal_options.h
@@ -17,6 +17,8 @@ enum {
OPT_DEV_ALLOW_NUM = 'a',
#define OPT_DEV_BLOCK "block"
OPT_DEV_BLOCK_NUM = 'b',
+#define OPT_LCORES "lcores"
+ OPT_LCORES_NUM = 'l',
/* first long only option value must be >= 256, so that we won't
* conflict with short options */
@@ -31,8 +33,6 @@ enum {
OPT_HUGE_DIR_NUM,
#define OPT_HUGE_UNLINK "huge-unlink"
OPT_HUGE_UNLINK_NUM,
-#define OPT_LCORES "lcores"
- OPT_LCORES_NUM,
#define OPT_LOG_COLOR "log-color"
OPT_LOG_COLOR_NUM,
#define OPT_LOG_LEVEL "log-level"
--
2.45.2
next prev parent reply other threads:[~2025-05-02 15:12 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` [RFC PATCH 3/3] eal: allow automatic mapping of high lcore ids Bruce Richardson
2025-03-24 17:30 ` [PATCH v2 0/3] allow easier use of high lcore-ids Bruce Richardson
2025-03-24 17:30 ` [PATCH v2 1/3] eal: centralize core parameter parsing Bruce Richardson
2025-04-07 6:58 ` David Marchand
2025-03-24 17:30 ` [PATCH v2 2/3] eal: convert core masks and lists to core sets Bruce Richardson
2025-04-07 6:59 ` David Marchand
2025-03-24 17:30 ` [PATCH v2 3/3] eal: allow automatic mapping of high lcore ids Bruce Richardson
2025-04-01 14:06 ` [PATCH v2 0/3] allow easier use of high lcore-ids Bruce Richardson
2025-04-07 7:04 ` David Marchand
2025-04-07 9:48 ` Bruce Richardson
2025-04-07 10:15 ` Morten Brørup
2025-04-07 10:40 ` Bruce Richardson
2025-04-07 11:32 ` Morten Brørup
2025-04-07 11:56 ` Bruce Richardson
2025-04-07 12:25 ` Morten Brørup
2025-04-07 12:41 ` Bruce Richardson
2025-04-07 13:18 ` Morten Brørup
2025-04-07 13:24 ` Bruce Richardson
2025-04-07 15:14 ` Stephen Hemminger
2025-04-07 15:38 ` Bruce Richardson
2025-05-02 15:11 ` [PATCH v3 0/4] rework and expand EAL lcore options Bruce Richardson
2025-05-02 15:11 ` [PATCH v3 1/4] eal: deprecate old coremask-based EAL parameters Bruce Richardson
2025-05-02 15:51 ` Stephen Hemminger
2025-05-02 16:00 ` Bruce Richardson
2025-05-03 6:09 ` Morten Brørup
2025-05-02 15:11 ` Bruce Richardson [this message]
2025-05-02 15:11 ` [PATCH v3 3/4] doc: provide examples of using lcores EAL parameter Bruce Richardson
2025-05-02 15:11 ` [PATCH v3 4/4] eal: add option for auto-mapping cpu ids to low lcore ids 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=20250502151134.536799-3-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=stephen@networkplumber.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;
as well as URLs for NNTP newsgroup(s).