[PATCH v8 17/18] eal: allow lcore id remapping with core lists

Bruce Richardson bruce.richardson at intel.com
Thu Oct 2 19:43:14 CEST 2025


Allow the "-R" flag to be used with core lists so that we can specify
lists with core ids >= RTE_MAX_LCORE in them, e.g. -l 140-148. In order
to do so, we limit the use of the "@" symbol for per-core remapping when
specifying a core list for automatic/global remapping, rather than
dealing with the situation of some cores being manually remapped and
others automatically.

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 doc/guides/linux_gsg/eal_args.include.rst | 22 +++++++++++++++++
 doc/guides/rel_notes/release_25_11.rst    | 11 +++++++++
 lib/eal/common/eal_common_options.c       | 29 ++++++++++++++++++++---
 3 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/doc/guides/linux_gsg/eal_args.include.rst b/doc/guides/linux_gsg/eal_args.include.rst
index 0b17879d42..4a3c4d9b5f 100644
--- a/doc/guides/linux_gsg/eal_args.include.rst
+++ b/doc/guides/linux_gsg/eal_args.include.rst
@@ -67,6 +67,28 @@ Lcore-related options
     At a given instance only one core option ``--lcores``, ``-l`` or ``-c`` can
     be used.
 
+*  ``-R, --remap-lcore-ids [<start lcore id>]``
+
+   Enable automatic remapping of lcore-ids to a contiguous set starting from 0,
+   or from a user-provided value.
+
+   When this flag is passed, the lcores specified by core mask or core list options
+   are taken as the physical cores on which the application will run,
+   and one thread will be started per core, with sequential lcore-ids.
+
+   For example: ``dpdk-test -l 20-24 -R``
+   will start 5 threads with lcore-ids 0 to 4 on physical cores 20 to 24.
+
+   Another example: ``dpdk-test -l 140-144 -R=10``
+   will start 5 threads with lcore-ids 10 to 14 on physical cores 140 to 144.
+
+.. note::
+
+    When using with the ``--lcores`` option, only simple core lists are allowed.
+    The ``@`` symbol to bind lcores to physical cpus,
+    and the use of ``()`` for core groupings,
+    are not allowed when ``-R`` or ``--remap-lcore-ids`` is also used.
+
 *   ``--main-lcore <core ID>``
 
     Core ID that is used as main.
diff --git a/doc/guides/rel_notes/release_25_11.rst b/doc/guides/rel_notes/release_25_11.rst
index f73bab1227..4443ebbe92 100644
--- a/doc/guides/rel_notes/release_25_11.rst
+++ b/doc/guides/rel_notes/release_25_11.rst
@@ -55,6 +55,17 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added automatic lcore-id remapping option.**
+
+  Added the EAL option ``--remap-lcore-ids`` or ``-R``
+  to enable automatic remapping of lcore-ids to a contiguous set starting from 0,
+  or from a user-provided value.
+  When this flag is passed, the lcores specified by core mask or core list options
+  are taken as the physical cores on which the application will run,
+  and one thread will be started per core, with sequential lcore-ids.
+  For example: ``dpdk-test -l 140-144 -R``
+  will start 5 threads with lcore-ids 0 to 4 on physical cores 140 to 144.
+
 * **Added speed 800G.**
 
   Added Ethernet link speed for 800 Gb/s as it is well standardized in IEEE,
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 86351535ee..c754c19511 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -1937,9 +1937,32 @@ eal_parse_args(void)
 		}
 		core_parsed = 1;
 	} else if (args.lcores != NULL) {
-		if (eal_parse_lcores(args.lcores) < 0) {
-			EAL_LOG(ERR, "invalid lcore list: '%s'", args.lcores);
-			return -1;
+		if (!remap_lcores) {
+			if (eal_parse_lcores(args.lcores) < 0) {
+				EAL_LOG(ERR, "invalid lcore list: '%s'", args.lcores);
+				return -1;
+			}
+		} else {
+			rte_cpuset_t cpuset;
+
+			if (strchr(args.lcores, '@') != NULL || strchr(args.lcores, '(') != NULL) {
+				EAL_LOG(ERR, "cannot use '@' or core groupings '()' in lcore list when remapping lcores");
+				return -1;
+			}
+			if (rte_argparse_parse_type(args.lcores,
+					RTE_ARGPARSE_VALUE_TYPE_CORELIST, &cpuset) != 0) {
+				EAL_LOG(ERR, "Error parsing lcore list: '%s'", args.lcores);
+				return -1;
+			}
+
+			if (update_lcore_config(&cpuset, remap_lcores, lcore_id_base) < 0) {
+				char *available = available_cores();
+
+				EAL_LOG(ERR, "invalid coremask '%s', please check specified cores are part of %s",
+						args.coremask, available);
+				free(available);
+				return -1;
+			}
 		}
 		core_parsed = 1;
 	}
-- 
2.48.1



More information about the dev mailing list