Introduce Topology NUMA grouping for lcores
v3 cover Introduce Topology NUMA grouping for lcores
One of the way to increase core density in a given physical package is to use easy to replicate tiles. These tiles are either core complexes or core complexes with IO (memory and PCIe). This results to possibility of having two types NUMA topology.
- CPU topology & IO topology
- CPU+IO topology
For platforms like
- AMD SoC EPYC, core complexes are in separate CPU domain and IO are in different NUMA domain (except for zen1 Naples)
- Intel 4th Xeon (SPR) & above, the CPU+IO NUMA partitioning is achieved by BIOS option SNC as 1, 2 or 4.
- Ampere One allow CPU NUMA paritioning by BIOS option SLC.
- while other platforms has 2 or 4 cores sharing same L2 cache.
Grouping DPDK logical cores within the same Cache and IO, helps to leverage application same cache or IO locality. For applications to leverage cache or IO locality, ones needs to use lcores sharing same topology. This approach ensures more consistent latencies by minimizing the dispersion of lcores across different tiles.
Using lcores in same NUMA domain shows imporvement for applications
- using pipline staging
- each lcore processing part of payload
- eventual hit in either L2 or L3
Library dependency: hwloc
Topology Flags:
---------------
- RTE_LCORE_DOMAIN_L1: to group cores sharing same L1 cache
- RTE_LCORE_DOMAIN_SMT: same as RTE_LCORE_DOMAIN_L1
- RTE_LCORE_DOMAIN_L2: group cores sharing same L2 cache
- RTE_LCORE_DOMAIN_L3: group cores sharing same L3 cache
- RTE_LCORE_DOMAIN_IO: group cores sharing same IO
< Function: Purpose >
---------------------
- rte_get_domain_count: get domain count based on Topology Flag
- rte_lcore_count_from_domain: get valid lcores count under each domain
- rte_get_lcore_in_domain: valid lcore id based on index
- rte_get_next_lcore_from_domain: next valid lcore within domain
- rte_get_next_lcore_from_next_domain: next valid lcore from next domain
Note:
1. Topology is NUMA grouping.
2. Domain is various sub-groups within a specific Topology.
Topology example: L1, L2, L3, IO
Domian example: IO-A, IO-B
< MACRO: Purpose >
------------------
- RTE_LCORE_FOREACH_DOMAIN: iterate lcores from all domains
- RTE_LCORE_FOREACH_WORKER_DOMAIN: iterate worker lcores from all domains
- RTE_LCORE_FORN_NEXT_DOMAIN: iterate domain select n'th lcore
- RTE_LCORE_FORN_WORKER_NEXT_DOMAIN: iterate domain for worker n'th lcore.
Future work (after merge):
--------------------------
- dma-perf per IO NUMA
- eventdev per L3 NUMA
- pipeline per SMT|L3 NUMA
- distributor per L3 for Port-Queue
- l2fwd-power per SMT
- testpmd option for IO NUMA per port
Platform tested on:
-------------------
- INTEL(R) XEON(R) PLATINUM 8562Y+ (support IO numa 1 & 2)
- AMD EPYC 8534P (supports IO numa 1 & 2)
- AMD EPYC 9554 (supports IO numa 1, 2, 4)
Logs:
-----
1. INTEL(R) XEON(R) PLATINUM 8562Y+:
- SNC=1
Domain (IO): at index (0) there are 48 core, with (0) at index 0
- SNC=2
Domain (IO): at index (0) there are 24 core, with (0) at index 0 Domain (IO): at index (1) there are 24 core, with (12) at index 0
2. AMD EPYC 8534P:
- NPS=1:
Domain (IO): at index (0) there are 128 core, with (0) at index 0
- NPS=2:
Domain (IO): at index (0) there are 64 core, with (0) at index 0 Domain (IO): at index (1) there are 64 core, with (32) at index 0
Vipin Varghese (3):
eal/lcore: add topology based functions
test/lcore: enable tests for topology
examples: add lcore topology API calls
app/test/test_lcores.c | 189 ++++++++++ config/meson.build | 18 + examples/helloworld/main.c | 142 +++++++- examples/l2fwd/main.c | 56 ++- examples/skeleton/basicfwd.c | 22 ++ lib/eal/common/eal_common_lcore.c | 580 ++++++++++++++++++++++++++++++ lib/eal/common/eal_private.h | 48 +++ lib/eal/freebsd/eal.c | 10 + lib/eal/include/rte_lcore.h | 168 +++++++++ lib/eal/linux/eal.c | 11 + lib/eal/meson.build | 4 + lib/eal/version.map | 9 + lib/eal/windows/eal.c | 12 + 13 files changed, 1259 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1
RFC v3 1/3 eal/lcore: add topology based functions
Introduce topology aware lcore mapping into lcore API. With higher core density, more and more cores are categorized into various chiplets based on IO (memory and PCIe) and Last Level Cache (mainly L3).
Using hwloc library, the dpdk available lcores can be grouped into various groups nameley L1, L2, L3 and IO. This patch introduces functions and MACRO that helps to identify such groups.
Internal API:
- rte_eal_topology_init
- rte_eal_topology_release
- get_domain_lcore_mapping
External Experimental API:
- rte_domain_count
- rte_lcore_count_from_domain
- rte_get_lcore_from_domain
- rte_get_next_lcore_from_domain
- rte_get_next_lcore_from_next_domain
v2 changes: focuses on rte_lcore api for getting topology
- use hwloc instead of sysfs exploration - Mattias Rönnblom
- L1, L2 and IO domain mapping - Ferruh, Vipin
- new API marked experimental - Stephen Hemminger
--- config/meson.build | 18 + lib/eal/common/eal_common_lcore.c | 580 ++++++++++++++++++++++++++++++ lib/eal/common/eal_private.h | 48 +++ lib/eal/freebsd/eal.c | 10 + lib/eal/include/rte_lcore.h | 168 +++++++++ lib/eal/linux/eal.c | 11 + lib/eal/meson.build | 4 + lib/eal/version.map | 9 + lib/eal/windows/eal.c | 12 + 9 files changed, 860 insertions(+)
config/meson.build +18 -0
@@ -240,6 +240,24 @@ if find_libnuma endif endif +has_libhwloc = false +find_libhwloc = true + +if meson.is_cross_build() and not meson.get_cross_property('hwloc', true) + # don't look for libhwloc if explicitly disabled in cross build + find_libhwloc = false +endif + +if find_libhwloc + hwloc_dep = cc.find_library('hwloc', required: false) + if hwloc_dep.found() and cc.has_header('hwloc.h') + dpdk_conf.set10('RTE_HAS_LIBHWLOC', true) + has_libhwloc = true + add_project_link_arguments('-lhwloc', language: 'c') + dpdk_extra_ldflags += '-lhwloc' + endif +endif + has_libfdt = false fdt_dep = cc.find_library('fdt', required: false) if fdt_dep.found() and cc.has_header('fdt.h')
lib/eal/common/eal_common_lcore.c +580 -0
592 lines not on this page · raw message
lib/eal/common/eal_private.h +48 -0
66 lines not on this page · raw message
lib/eal/freebsd/eal.c +10 -0
@@ -73,6 +73,8 @@ struct lcore_config lcore_config[RTE_MAX_LCORE];/* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; +/* holds topology information */ +struct topology_config topo_cnfg;int eal_clean_runtime_dir (void )
@@ -912,6 +914,12 @@ rte_eal_init(int argc, char **argv)return -1 ; } +if (rte_eal_topology_init ()) { +rte_eal_init_alert ("Cannot invoke topology!!!" ); + rte_errno =ENOTSUP ; +return -1 ; + } +eal_mcfg_complete ();return fctret;
@@ -932,6 +940,8 @@ rte_eal_cleanup(void)struct internal_config *internal_conf =eal_get_internal_configuration (); + +rte_eal_topology_release ();rte_service_finalize ();rte_mp_channel_cleanup ();eal_bus_cleanup ();
lib/eal/include/rte_lcore.h +168 -0
192 lines not on this page · raw message
lib/eal/linux/eal.c +11 -0
@@ -65,6 +65,9 @@* duration of the program, as we hold a write lock on it in the primary proc */ static int mem_cfg_fd =-1 ; +/* holds topology information */ +struct topology_config topo_cnfg; +static struct flock wr_lock = { .l_type =F_WRLCK , .l_whence =SEEK_SET ,
@@ -1311,6 +1314,12 @@ rte_eal_init(int argc, char **argv)return -1 ; } +if (rte_eal_topology_init ()) { +rte_eal_init_alert ("Cannot invoke topology!!!" ); + rte_errno =ENOTSUP ; +return -1 ; + } +eal_mcfg_complete ();return fctret;
@@ -1352,6 +1361,8 @@ rte_eal_cleanup(void)struct internal_config *internal_conf =eal_get_internal_configuration (); +rte_eal_topology_release (); +if (rte_eal_process_type () ==RTE_PROC_PRIMARY && internal_conf->hugepage_file.unlink_existing)rte_memseg_walk (mark_freeable,NULL );
lib/eal/meson.build +4 -0
@@ -31,3 +31,7 @@ endif if is_freebsd annotate_locks = false endif + +if has_libhwloc + dpdk_conf.set10('RTE_EAL_HWLOC_TOPOLOGY_PROBE', true) +endif
lib/eal/version.map +9 -0
@@ -399,6 +399,13 @@ EXPERIMENTAL { # added in 24.11 rte_bitset_to_str; + + # added in 25.03 + rte_get_domain_count; + rte_lcore_count_from_domain; + rte_get_lcore_in_domain; + rte_get_next_lcore_from_domain; + rte_get_next_lcore_from_next_domain; }; INTERNAL {
@@ -408,6 +415,8 @@ INTERNAL { rte_bus_unregister; rte_eal_get_baseaddr; rte_eal_parse_coremask; + rte_eal_topology_init; + rte_eal_topology_release; rte_firmware_read; rte_intr_allow_others; rte_intr_cap_multiple;
lib/eal/windows/eal.c +12 -0
@@ -40,6 +40,10 @@ static int mem_cfg_fd = -1;/* internal configuration (per-core) */ struct lcore_config lcore_config[RTE_MAX_LCORE ]; +/* holds topology information */ +struct topology_config topo_cnfg; + +/* Detect if we are a primary or a secondary process */ enum rte_proc_type_t eal_proc_type_detect (void )
@@ -262,6 +266,8 @@ rte_eal_cleanup(void)struct internal_config *internal_conf =eal_get_internal_configuration (); +rte_eal_topology_release (); +eal_intr_thread_cancel ();eal_mem_virt2iova_cleanup ();eal_bus_cleanup ();
@@ -505,6 +511,12 @@ rte_eal_init(int argc, char **argv)rte_eal_mp_remote_launch (sync_func,NULL ,SKIP_MAIN );rte_eal_mp_wait_lcore (); +if (rte_eal_topology_init ()) { +rte_eal_init_alert ("Cannot invoke topology!!!" ); + rte_errno =ENOTSUP ; +return -1 ; + } +eal_mcfg_complete ();return fctret;
Signature · 1 line
2.34.1
Re: [RFC v3 1/3] eal/lcore: add topology based functions
Review
Quoted 2 lines · On Wed, 30 Oct 2024 11:11:31 +0530 Vipin Varghese <[email protected]>…
topo_cnfg.l3[j] = (struct
core_domain_mapping*)(quoted diff) +1
-0+ malloc(sizeof(struct core_domain_mapping));
Minor nit, no need to cast return value from malloc(). In C void * can be assigned to a type directly.
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Snipped
Quoted 9 lines
Quoted 2 lines · On Wed, 30 Oct 2024 11:11:31 +0530 Vipin Varghese <[email protected]>…
topo_cnfg.l3[j] = (struct
core_domain_mapping*)
+malloc(sizeof(struct core_domain_mapping));Minor nit, no need to cast return value from
malloc(). In C void * can be assigned to a type directly.
Thank you Stephen, will address this with v4
Re: [RFC v3 1/3] eal/lcore: add topology based functions
In reply to Vipin Vargheselib/eal/common/eal_common_lcore.c socket_id_cmp(const void *a, const void *b) · line 707
Quoted 4 lines · On Wed, 30 Oct 2024 11:11:31 +0530 Vipin Varghese <[email protected]>…
lib/eal/common/eal_common_lcore.c +4
-0+if (topo_cnfg.io) { +free (topo_cnfg.io); + topo_cnfg.io =NULL ; + }
No need to check for NULL before calling free.
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Snipped
Quoted 10 lines
lib/eal/common/eal_common_lcore.c socket_id_cmp(const void *a, const void *b) · line 707
Quoted 4 lines · On Wed, 30 Oct 2024 11:11:31 +0530 Vipin Varghese <[email protected]>…
lib/eal/common/eal_common_lcore.c +4
-0+if (topo_cnfg.io) { +free (topo_cnfg.io); + topo_cnfg.io =NULL ; + }No need to check for NULL before calling free.
Thank you Stepehen on this, the reason why we specifically added to address 2 scenarios
1. as pointed out by Wathsala where System Level Cache will be disabled; where L3 will be not available at all
2. for version where hwloc does not detect the specific cache level.
By checking the NULL we can avoid such cases.
Note: I will recheck and add|remove this in v4
Re: [RFC v3 1/3] eal/lcore: add topology based functions
In reply to Stephen HemmingerQuoted 9 lines · Stephen Hemminger
lib/eal/common/eal_common_lcore.c socket_id_cmp(const void *a, const void *b) · line 707
Quoted 4 lines · On Wed, 30 Oct 2024 11:11:31 +0530 Vipin Varghese <[email protected]>…
lib/eal/common/eal_common_lcore.c +4
-0+if (topo_cnfg.io) { +free (topo_cnfg.io); + topo_cnfg.io =NULL ; + }No need to check for NULL before calling free.
If you do need to check for NULL, do it explicitly.
if (topo_cnfg.io != NULL) /../
Re: [RFC v3 1/3] eal/lcore: add topology based functions
In reply to Vipin Vargheselib/eal/common/eal_private.h struct lcore_config { · line 61
Quoted 5 lines · On Wed, 30 Oct 2024 11:11:31 +0530 Vipin Varghese <[email protected]>…
lib/eal/common/eal_private.h +5
-0+/* domain count */ +uint16_t l1_count; +uint16_t l2_count; +uint8_t l3_count; +uint8_t io_count;
Make them all uint16_t, the space is there already.
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Snipped
Quoted 8 lines
lib/eal/common/eal_private.h struct lcore_config { · line 61
Quoted 6 lines
lib/eal/common/eal_private.h +5
-0+/* domain count */ +uint16_t l1_count; +uint16_t l2_count; +uint8_t l3_count; +uint8_t io_count;Make them all
uint16_t, the space is there already.
Thank you, fixing this in v4
Re: [RFC v3 1/3] eal/lcore: add topology based functions
In reply to Vipin VargheseQuoted 15 lines · On Wed, 30 Oct 2024 11:11:31 +0530 Vipin Varghese <[email protected]>…
lib/eal/common/eal_private.h +15
-0+struct topology_config { +#ifdef RTE_EAL_HWLOC_TOPOLOGY_PROBE +hwloc_topology_t topology; +#endif + +/* domain count */ +uint16_t l1_count; +uint16_t l2_count; +uint8_t l3_count; +uint8_t io_count; + +/* total cores under all domain */ +uint16_t l1_core_count; +uint16_t l2_core_count; +uint16_t l3_core_count;
lib/eal/common/eal_private.h struct lcore_config { · line 76
Quoted 10 lines
lib/eal/common/eal_private.h +10
-0+uint16_t io_core_count; + +/* two dimensional array for each domain */ +struct core_domain_mapping **l1; +struct core_domain_mapping **l2; +struct core_domain_mapping **l3; +struct core_domain_mapping **io; +}; +extern struct topology_config topo_cnfg; +
To work with primary/secondary process model, it might be better to keep this info in hugpage/shared memory. I.e put topology_config into space allocated with rte_malloc() and populated by primary process.
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Snipped
Quoted 21 lines
Quoted 21 lines
lib/eal/common/eal_private.h +20
-0+struct topology_config { +#ifdef RTE_EAL_HWLOC_TOPOLOGY_PROBE +hwloc_topology_t topology; +#endif + +/* domain count */ +uint16_t l1_count; +uint16_t l2_count; +uint8_t l3_count; +uint8_t io_count; + +/* total cores under all domain */ +uint16_t l1_core_count; +uint16_t l2_core_count; +uint16_t l3_core_count; +uint16_t io_core_count; + +/* two dimensional array for each domain */ +struct core_domain_mapping **l1; +struct core_domain_mapping **l2;
Quoted 8 lines
lib/eal/common/eal_private.h struct lcore_config { · line 76
Quoted 4 lines
lib/eal/common/eal_private.h +4
-0+struct core_domain_mapping **l3; +struct core_domain_mapping **io; };extern struct +topology_config topo_cnfg; +To work with primary/secondary process model, it might be better to keep this info in hugpage/shared memory. I.e put
topology_configinto space allocated withrte_malloc()and populated by primary process.
Initially we did use rte_memzone_reserve and moved it under rte_cnfg structure for primary and secondary.
Exploring on the use cases we noticed in multiprocessor scenarios, lcore of the primary did not share. Hence we moved to using malloc as local allocator.
We can easily move to rte_malloc, but do we need to share the HW topology based lcore grouping to multi-process?
RE: [RFC v3 1/3] eal/lcore: add topology based functions
In reply to Vipin VargheseQuoted 8 lines
From: Vipin Varghese [mailto:[email protected]]
Sent: Wednesday, 30 October 2024 06.42Introduce topology aware lcore mapping into lcore API. With higher core density, more and more cores are categorized into various chiplets based on IO (memory and PCIe) and Last Level Cache (mainly L3).
Quoted 4 lines
Using hwloc library, the dpdk available lcores can be grouped into various groups nameley L1, L2, L3 and IO. This patch introduces functions and MACRO that helps to identify such groups.
Does the API need to be prepared for L4 cache?
https://www.anandtech.com/show/16924/did-ibm-just-preview-the-future-of-caches
And - just a thought:
Since this library and the Cache Stashing (PCIe TLP) library are somewhat related, would it be beneficial to combine them into one patch series, primarily to make their APIs more uniform?
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Snipped
Quoted 3 lines
Does the API need to be prepared for L4 cache?
https://www.anandtech.com/show/16924/did-ibm-just-preview-the-future-of-caches
Thank you for the pointer, yes initial patch was considering L4 cache too. But I was not able to get hold of system or get someone to test this with L4. Hence removed the L4 instance from dpdk_topology structure.
We can introduce into v4. Can we get someone from IBM to confirm the same?
Quoted 5 lines
And - just a thought:
Since this library and the Cache Stashing (PCIe TLP) library are somewhat related, would it be beneficial to combine them into one patch series, primarily to make their APIs more uniform?
There was initial zoom invite for understanding and usage, we expected a follow up on the same to close the loop. Based on my current understanding, the API to be used as hints to PMD should be passing lcore id only. Hence these can be independent.
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Quoted 10 lines
Quoted 2 lines
Does the API need to be prepared for L4 cache?
https://www.anandtech.com/show/16924/did-ibm-just-preview-the-future-of-caches
Thank you for the pointer, yes initial patch was considering L4 cache too. But I was not able to get hold of system or get someone to test this with L4.
Hence removed the L4 instance fromdpdk_topologystructure.We can introduce into v4. Can we get someone from IBM to confirm the same?
If any of the CPU folks think L4 cache might become relevant in the foreseeable future, it should be added to the API without testing at this time. Adding it now would prevent API breakage whenever L4 cache actually becomes relevant. Otherwise please don't support for it - considering it would be dead and untested code.
Quoted 6 lines
Quoted 4 lines
And - just a thought:
Since this library and the Cache Stashing (PCIe TLP) library aresomewhat related,
Quoted 1 line
would it be beneficial to combine them into one patch series,
Quoted 8 lines
primarily to make their
Quoted 1 line
APIs more uniform?
There was initial zoom invite for understanding and usage, we expected a follow up on the same to close the loop.
Based on my current understanding, the API to be used as hints to PMD should be passinglcore idonly.
Hence these can be independent.
The Cache Stashing hints API uses a more specific destination than just "lcore id".
The implementations of this Topology library and the Cache Stashing library may be completely independent, but the structure describing a location in the topology could be common.
Maybe I should say this differently:
Wathsala and other folks working on the Cache Stashing API, you need to keep a close eye on this Topology patch series! We might expect the Cache Stashing API to reuse relevant structures from it.
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Snipped
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Does the API need to be prepared for L4 cache?
https://www.anandtech.com/show/16924/did-ibm-just-preview-the-future
-of-caches
Thank you for the pointer, yes initial patch was considering L4 cache too. But I was not able to get hold of system or get someone to test this with L4.
Hence removed the L4 instance fromdpdk_topologystructure.
Quoted 5 lines
Quoted 2 lines
We can introduce into v4. Can we get someone from IBM to confirm the same?
If any of the CPU folks think L4 cache might become relevant in the foreseeable future, it should be added to the API without testing at this time.
I remember 3 L4 cache scenario
1. from IBM power-9 variant suggested in 2020-2021 in hot chips
2. from Intel
a. Haswell|Broadwell series with eDram as L4
b. future product (at least in desktop) with L4 cache.
Quoted 3 lines
Adding it now would prevent API breakage whenever L4 cache actually becomes relevant. Otherwise please don't support for it - considering it would be dead and untested code.
I can add the same to the DPDK topology probe in v4, on AMD EPYC v-cache is treated as extended L3 and not L4. Hence will not be able to test on AMD EPYC.
Quoted 16 lines
Quoted 7 lines
Quoted 5 lines
And - just a thought:
Since this library and the Cache Stashing (PCIe TLP) library aresomewhat related,
Quoted 1 line
would it be beneficial to combine them into one patch series,
Quoted 8 lines
primarily to make their
Quoted 1 line
APIs more uniform?
There was initial zoom invite for understanding and usage, we expected a follow up on the same to close the loop.
Based on my current understanding, the API to be used as hints to PMD should be passinglcore idonly.
Hence these can be independent.
Quoted 4 lines
The Cache Stashing hints API uses a more specific destination than just "lcore id". The implementations of this Topology library and the Cache Stashing library may be completely independent, but the structure describing a location in the topology could be common.
Thank you, now I understand,
Quoted 5 lines
Maybe I should say this differently:
Wathsala and other folks working on the Cache Stashing API, you need to keep a close eye on this Topology patch series!
We might expect the Cache Stashing API to reuse relevant structures from it.
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Quoted 27 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Does the API need to be prepared for L4 cache?
https://www.anandtech.com/show/16924/did-ibm-just-preview-the-future
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
-
of-caches
Thank you for the pointer, yes initial patch was considering L4cache
Quoted 1 line
Quoted 1 line
too. But I was not able to get hold of system or get someone to
test
Quoted 4 lines
Quoted 4 lines
this with L4.
Hence removed the L4 instance fromdpdk_topologystructure.We can introduce into v4. Can we get someone from IBM to confirm
the
Quoted 3 lines
Quoted 1 line
same?
If any of the CPU folks think L4 cache might become relevant in the
foreseeable
Quoted 1 line
future, it should be added to the API without testing at this time.
I remember 3 L4 cache scenario
1. from IBM power-9 variant suggested in 2020-2021 in hot chips
2. from Intel
a. Haswell|Broadwell series with eDram as L4
b. future product (at least in desktop) with L4 cache.Quoted 1 line
Adding it now would prevent API breakage whenever L4 cache actually
Quoted 8 lines
becomes relevant.
Quoted 1 line
Otherwise please don't support for it - considering it would be dead
and untested
Quoted 1 line
code.
I can add the same to the DPDK topology probe in v4, on AMD EPYC v- cache is treated as extended L3 and not L4. Hence will not be able to test on AMD EPYC.
I recall from the Cache Stashing community call... There is some ACPI function to get the (opaque) "location IDs" of various parts in the system, to be used for setting the Cache Stashing hints. Is there only one "ACPI location ID" (I don't know the correct name) shared by the L3 cache and the v-cache in AMD EPYC, or do they have each their own?
If they are not exposed as one ID, but two separate IDs, the Topology API might need to reflect this, so it can be used in the Cache Stashing API.
Quoted 35 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
And - just a thought:
Since this library and the Cache Stashing (PCIe TLP) library aresomewhat related,
Quoted 1 line
would it be beneficial to combine them into one patch series,
primarily to make their
Quoted 1 line
APIs more uniform?
There was initial zoom invite for understanding and usage, we
expected
Quoted 2 lines
Quoted 2 lines
a follow up on the same to close the loop.
Based on my current understanding, the API to be used as hints toPMD
Quoted 4 lines
Quoted 2 lines
should be passing
lcore idonly.
Hence these can be independent.The Cache Stashing hints API uses a more specific destination than
just "lcore id".
Quoted 1 line
The implementations of this Topology library and the Cache Stashing
library may be
Quoted 1 line
completely independent, but the structure describing a location in
the topology could
Quoted 1 line
be common.
Thank you, now I understand,
Quoted 3 lines
Maybe I should say this differently:
Wathsala and other folks working on the Cache Stashing API, you needto keep a
Quoted 2 lines
close eye on this Topology patch series!
We might expect the Cache Stashing API to reuse relevant structuresfrom it.
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Snipped
Quoted 38 lines
Quoted 29 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Does the API need to be prepared for L4 cache?
https://www.anandtech.com/show/16924/did-ibm-just-preview-the-future
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
-
of-caches
Thank you for the pointer, yes initial patch was considering L4cache
Quoted 1 line
Quoted 1 line
too. But I was not able to get hold of system or get someone to
test
Quoted 4 lines
Quoted 4 lines
this with L4.
Hence removed the L4 instance fromdpdk_topologystructure.We can introduce into v4. Can we get someone from IBM to confirm
the
Quoted 3 lines
Quoted 1 line
same?
If any of the CPU folks think L4 cache might become relevant in the
foreseeable
Quoted 1 line
future, it should be added to the API without testing at this time.
I remember 3 L4 cache scenario
1. from IBM power-9 variant suggested in 2020-2021 in hot chips 2.
from Intel
a. Haswell|Broadwell series with eDram as L4
b. future product (at least in desktop) with L4 cache.Quoted 1 line
Adding it now would prevent API breakage whenever L4 cache actually
Quoted 8 lines
becomes relevant.
Quoted 1 line
Otherwise please don't support for it - considering it would be dead
and untested
Quoted 1 line
code.
I can add the same to the DPDK topology probe in v4, on AMD EPYC v- cache is treated as extended L3 and not L4. Hence will not be able to test on AMD EPYC.
Quoted 5 lines
I recall from the Cache Stashing community call... There is some ACPI function to get the (opaque) "location IDs" of various parts in the system, to be used for setting the Cache Stashing hints.
Is there only one "ACPI location ID" (I don't know the correct name) shared by the L3 cache and the v-cache in AMD EPYC, or do they have each their own?
At least on AMD EPYC, the stashing ID updated to either MSI-X table or Device Specific Mode is core-id.
Quoted 2 lines
If they are not exposed as one ID, but two separate IDs, the Topology API might need to reflect this, so it can be used in the Cache Stashing API.
I have different view on the same and had shared this with Ajit (Broadcom) and others. To my understanding, use of rte_ethdev API used
for caching hints should be inline to rte_lcore. Depending upon the platform (ARM's specific implementation, the lcore gets translated to L2 or L3 cache ID within the PMD.
Note: the current patch introduces of Topology aware grouping, which helps to run application better or tiles or chiplets sharing same L2|L3 or IO domain.
Snipped
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Quoted 47 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Does the API need to be prepared for L4 cache?
https://www.anandtech.com/show/16924/did-ibm-just-preview-the-
Quoted 11 lines
Quoted 11 lines
future
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
-
of-caches
Thank you for the pointer, yes initial patch was considering L4cache
Quoted 1 line
Quoted 1 line
too. But I was not able to get hold of system or get someone to
test
Quoted 4 lines
Quoted 4 lines
this with L4.
Hence removed the L4 instance fromdpdk_topologystructure.We can introduce into v4. Can we get someone from IBM to
confirm
Quoted 4 lines
Quoted 4 lines
the
Quoted 3 lines
Quoted 1 line
same?
If any of the CPU folks think L4 cache might become relevant in
the
Quoted 2 lines
Quoted 2 lines
foreseeable
Quoted 1 line
future, it should be added to the API without testing at this
time.
Quoted 3 lines
Quoted 3 lines
I remember 3 L4 cache scenario
1. from IBM power-9 variant suggested in 2020-2021 in hot chips2.
Quoted 5 lines
Quoted 5 lines
from Intel
a. Haswell|Broadwell series with eDram as L4 b. future product (at least in desktop) with L4 cache.Quoted 1 line
Adding it now would prevent API breakage whenever L4 cache
actually
Quoted 2 lines
Quoted 2 lines
becomes relevant.
Quoted 1 line
Otherwise please don't support for it - considering it would be
dead
Quoted 5 lines
Quoted 5 lines
and untested
Quoted 1 line
code.
I can add the same to the DPDK topology probe in v4, on AMD EPYC v- cache is treated as extended L3 and not L4. Hence will not be able
to
Quoted 3 lines
Quoted 1 line
test on AMD EPYC.
I recall from the Cache Stashing community call... There is some ACPI
function to
Quoted 1 line
get the (opaque) "location IDs" of various parts in the system, to be
Quoted 8 lines
used for setting
Quoted 2 lines
the Cache Stashing hints.
Is there only one "ACPI location ID" (I don't know the correct name)shared by the
Quoted 1 line
L3 cache and the v-cache in AMD EPYC, or do they have each their own?
At least on AMD EPYC, the stashing ID updated to either MSI-X table or Device Specific Mode is core-id.
Are you saying that on AMD EPYC only L2 caches have a Stashing ID, so no other CPU caches can be stashed into? If yes, then it's a non-issue for Cache Stashing, since it doesn't need to care about L3 cache or v-cache.
Quoted 11 lines
Quoted 3 lines
If they are not exposed as one ID, but two separate IDs, the Topology
API might
Quoted 1 line
need to reflect this, so it can be used in the Cache Stashing API.
I have different view on the same and had shared this with Ajit (Broadcom) and others. To my understanding, use of
rte_ethdevAPI used for caching hints should be inline torte_lcore. Depending upon the platform (ARM's specific implementation, the lcore gets translated to L2 or L3 cache ID within the PMD.
The rte_ethdev API for cache stashing provides a higher level of abstraction, yes.
But the layer below it - the Stashing API used by the PMDs to obtain Stashing ID from "location ID" - could use the "location ID" structure type defined by the Topology library's lower layer.
Quoted 4 lines
Note: the current patch introduces of Topology aware grouping, which helps to run application better or tiles or chiplets sharing same L2|L3 or IO domain.
Both libraries (Topology and Cache Stashing) need to have detailed information about the hardware, although they use the information for two different purposes.
Maybe they could share a common lower layer for the system topology, perhaps just a few header files. Or maybe the Cache Stashing library should depend on the Topology library as its "lower layer" to provide the hardware information it needs.
I'm not saying that it must be so. I'm only saying that I suppose these two libraries have a lot in common, and they could try to take advantage of this, to provide a more uniform API at their lower layers.
RE: [RFC v3 1/3] eal/lcore: add topology based functions
Snipped
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
I recall from the Cache Stashing community call... There is some ACPI
function to
Quoted 2 lines
get the (opaque) "location IDs" of various parts in the system, to be
used for setting
Quoted 2 lines
the Cache Stashing hints.
Is there only one "ACPI location ID" (I don't know the correct name)
Quoted 8 lines
Quoted 5 lines
shared by the
Quoted 1 line
L3 cache and the v-cache in AMD EPYC, or do they have each their own?
At least on AMD EPYC, the stashing ID updated to either MSI-X table or Device Specific Mode is core-id.
Are you saying that on AMD EPYC only L2 caches have a Stashing ID, so no other CPU caches can be stashed into?
On AMD EPYC zen4 (limited Operating Part Number) & zen5, Cache Stashing is done on L2 cache level. This is done by passing core-id as the steering tag (opaque value)
Quoted 2 lines
If yes, then it's a non-issue for Cache Stashing, since it doesn't need to care about L3 cache or v-cache.
Yes, that is what I am trying to imply irrespective of the platform (Arm, powerpc, riscv, Intel or AMD) cache stashing based on PCIe SIG is based on each vendor implementation. On AMD EPYC currently this is on based on core-id (which is the hint to platform to put it into L2 cache).
Other platforms might support putting to L1, L2 or L3. And for these I agree that cache id might be used steering tag.
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
If they are not exposed as one ID, but two separate IDs, the Topology
Quoted 8 lines
API might
Quoted 1 line
need to reflect this, so it can be used in the Cache Stashing API.
I have different view on the same and had shared this with Ajit (Broadcom) and others. To my understanding, use of
rte_ethdevAPI used for caching hints should be inline torte_lcore. Depending upon the platform (ARM's specific implementation, the lcore gets translated to L2 or L3 cache ID within the PMD.
Quoted 5 lines
The
rte_ethdevAPI for cache stashing provides a higher level of abstraction, yes.But the layer below it - the Stashing API used by the PMDs to obtain Stashing ID from "location ID" - could use the "location ID" structure type defined by the Topology library's lower layer.
Yes, consume the lcore-id from the user via ethdev API, internally the PMD translates this.. Based on my current understanding this can be done in two ways
1. the translation is done using hwloc library API calls
2. using rte_topology structure during probing, also probe for cache id for L1, L2, L3 and L4.
To do achieve this, one has to add unsigned int cache_id to struct core_domain_mapping. This allows rte_eal_topology_init probe to store the cache_id.
Quoted 9 lines
Quoted 5 lines
Note: the current patch introduces of Topology aware grouping, which helps to run application better or tiles or chiplets sharing same L2|L3 or IO domain.
Both libraries (Topology and Cache Stashing) need to have detailed information about the hardware, although they use the information for two different purposes.
Quoted 7 lines
Maybe they could share a common lower layer for the system topology, perhaps just a few header files. Or maybe the Cache Stashing library should depend on the Topology library as its "lower layer" to provide the hardware information it needs.
I'm not saying that it must be so. I'm only saying that I suppose these two libraries have a lot in common, and they could try to take advantage of this, to provide a more uniform API at their lower layers.
Yes I agree, my only case here let us first get rte_topology into dpdk eco-system. Since the struct core_domain_mapping can be easily updated this can be done in next step.
Note: assuming we can merge this for release 25.03, and we all concur or cache stashing API we get it tested on AMD EPYC and other platforms alike.
I will share v4 by today.
RFC v3 2/3 test/lcore: enable tests for topology
In reply to Vipin Vargheseadd functional test cases to validate topology supported lcore API.
v3 changes:
- fix test test-report/2024-October/817748.html
--- app/test/test_lcores.c | 189 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+)
app/test/test_lcores.c +189 -0
@@ -389,6 +389,186 @@ test_ctrl_thread(void)return 0 ; } +static int +test_topology_macro (void ) +{ +unsigned int total_lcores =0 ; +unsigned int total_wrkr_lcores =0 ; + +unsigned int total_lcore_io =0 ; +unsigned int total_lcore_l3 =0 ; +unsigned int total_lcore_l2 =0 ; +unsigned int total_lcore_l1 =0 ; + +unsigned int total_wrkr_lcore_io =0 ; +unsigned int total_wrkr_lcore_l3 =0 ; +unsigned int total_wrkr_lcore_l2 =0 ; +unsigned int total_wrkr_lcore_l1 =0 ; + +unsigned int lcore; + +/* get topology core count */ + lcore =-1 ; +RTE_LCORE_FOREACH (lcore) + total_lcores += 1; + + lcore =-1 ; + RTE_LCORE_FOREACH_DOMAIN(lcore, RTE_LCORE_DOMAIN_IO) + total_lcore_io +=1 ; + + lcore =-1 ; + RTE_LCORE_FOREACH_DOMAIN(lcore, RTE_LCORE_DOMAIN_L3) + total_lcore_l3 +=1 ; + + lcore =-1 ; + RTE_LCORE_FOREACH_DOMAIN(lcore, RTE_LCORE_DOMAIN_L2) + total_lcore_l2 +=1 ; + + lcore =-1 ; + RTE_LCORE_FOREACH_DOMAIN(lcore, RTE_LCORE_DOMAIN_L1) + total_lcore_l1 +=1 ; + +printf ("INFO: lcore count topology: none (%u), io (%u), l3 (%u), l2 (%u), l1 (%u).\n" , + total_lcores, total_lcore_io, + total_lcore_l3, total_lcore_l2, + total_lcore_l1); + + lcore =-1 ; +RTE_LCORE_FOREACH_WORKER (lcore) + total_wrkr_lcores += 1; + + lcore =-1 ; + RTE_LCORE_FOREACH_WORKER_DOMAIN(lcore, RTE_LCORE_DOMAIN_IO) + total_wrkr_lcore_io +=1 ; + + lcore =-1 ; + RTE_LCORE_FOREACH_WORKER_DOMAIN(lcore, RTE_LCORE_DOMAIN_L3) + total_wrkr_lcore_l3 +=1 ; + + lcore =-1 ; + RTE_LCORE_FOREACH_WORKER_DOMAIN(lcore, RTE_LCORE_DOMAIN_L2) + total_wrkr_lcore_l2 +=1 ; + + lcore =-1 ; + RTE_LCORE_FOREACH_WORKER_DOMAIN(lcore, RTE_LCORE_DOMAIN_L1) + total_wrkr_lcore_l1 +=1 ; + +printf ("INFO: worker lcore count topology: none (%u), io (%u), l3 (%u), l2 (%u), l1 (%u).\n" , + total_wrkr_lcores, total_wrkr_lcore_io, + total_wrkr_lcore_l3, total_wrkr_lcore_l2, + total_wrkr_lcore_l1); + +if ((total_wrkr_lcores +1 ) != total_lcores) { +printf ("ERR: failed in MACRO for RTE_LCORE_FOREACH\n" ); +return -2 ; + } + +if ((total_wrkr_lcore_io) > total_lcore_io) { +printf ("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for IO\n" ); +return -2 ; + } + +if ((total_wrkr_lcore_l3) > total_lcore_l3) { +printf ("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for L3\n" ); +return -2 ; + } + +if ((total_wrkr_lcore_l2) > total_lcore_l2) { +printf ("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for L2\n" ); +return -2 ; + } + +if ((total_wrkr_lcore_l1) > total_lcore_l1) { +printf ("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for L1\n" ); +return -2 ; + } + +printf ("INFO: lcore DOMAIN macro: success!\n" ); + +return 0 ; +} + +static int +test_lcore_count_from_domain (void ) +{ +unsigned int total_lcores =0 ; +unsigned int total_lcore_io =0 ; +unsigned int total_lcore_l3 =0 ; +unsigned int total_lcore_l2 =0 ; +unsigned int total_lcore_l1 =0 ; + +unsigned int domain_count; +unsigned int i; + +/* get topology core count */ + total_lcores =rte_lcore_count (); + + domain_count =rte_get_domain_count (RTE_LCORE_DOMAIN_IO ); +for (i =0 ; i < domain_count; i++) + total_lcore_io +=rte_lcore_count_from_domain (RTE_LCORE_DOMAIN_IO , i); + + domain_count =rte_get_domain_count (RTE_LCORE_DOMAIN_L3 ); +for (i =0 ; i < domain_count; i++) + total_lcore_l3 +=rte_lcore_count_from_domain (RTE_LCORE_DOMAIN_L3 , i); + + domain_count =rte_get_domain_count (RTE_LCORE_DOMAIN_L2 ); +for (i =0 ; i < domain_count; i++) + total_lcore_l2 +=rte_lcore_count_from_domain (RTE_LCORE_DOMAIN_L2 , i); + + domain_count =rte_get_domain_count (RTE_LCORE_DOMAIN_L1 ); +for (i =0 ; i < domain_count; i++) + total_lcore_l1 +=rte_lcore_count_from_domain (RTE_LCORE_DOMAIN_L1 , i); + +printf ("INFO: lcore count: none (%u), io (%u), l3 (%u), l2 (%u), l1 (%u).\n" , + total_lcores, total_lcore_io, total_lcore_l3, total_lcore_l2, total_lcore_l1); + +if ((total_lcores != total_lcore_l1) || + (total_lcores != total_lcore_l2) || + (total_lcores != total_lcore_l3) || + (total_lcores != total_lcore_io)) { +printf ("ERR: failed in domain API\n" ); +return -2 ; + } + +printf ("INFO: lcore count domain API: success\n" ); + +return 0 ; +} + +static int +test_lcore_from_domain_negative (void ) +{ +unsigned int domain_count; + + domain_count =rte_get_domain_count (RTE_LCORE_DOMAIN_IO ); +if (rte_lcore_count_from_domain (RTE_LCORE_DOMAIN_IO , domain_count)) { +printf ("ERR: domain API inconsistent for IO\n" ); +return -1 ; + } + + domain_count =rte_get_domain_count (RTE_LCORE_DOMAIN_L3 ); +if (rte_lcore_count_from_domain (RTE_LCORE_DOMAIN_L3 , domain_count)) { +printf ("ERR: domain API inconsistent for L3\n" ); +return -1 ; + } + + domain_count =rte_get_domain_count (RTE_LCORE_DOMAIN_L2 ); +if (rte_lcore_count_from_domain (RTE_LCORE_DOMAIN_L2 , domain_count)) { +printf ("ERR: domain API inconsistent for L2\n" ); +return -1 ; + } + + domain_count =rte_get_domain_count (RTE_LCORE_DOMAIN_L1 ); +if (rte_lcore_count_from_domain (RTE_LCORE_DOMAIN_L1 , domain_count)) { +printf ("ERR: domain API inconsistent for L1\n" ); +return -1 ; + } + +printf ("INFO: lcore domain API: success!\n" ); + +return 0 ; +} +static int test_lcores (void ) {
@@ -419,6 +599,15 @@ test_lcores(void)if (test_ctrl_thread () <0 )return TEST_FAILED ; +if (test_topology_macro () <0 ) +return TEST_FAILED ; + +if (test_lcore_count_from_domain () <0 ) +return TEST_FAILED ; + +if (test_lcore_from_domain_negative () <0 ) +return TEST_FAILED ; +return TEST_SUCCESS ; }
Signature · 1 line
2.34.1
RE: [EXTERNAL] [RFC v3 2/3] test/lcore: enable tests for topology
Quoted 8 lines
add functional test cases to validate topology supported lcore API.
v3 changes:
- fix test test-report/2024-October/817748.htmlSigned-off-by Vipin Varghese <[email protected]>---
Test fails on ARM platform:
lcore 19, socket 0, role RTE, cpuset 19
Control thread running successfully
INFO: lcore count topology: none (12), io (1), l3 (1), l2 (1), l1 (1).
INFO: worker lcore count topology: none (11), io (1), l3 (1), l2 (1), l1 (1).
INFO: lcore DOMAIN macro: success!
INFO: lcore count: none (12), io (0), l3 (0), l2 (0), l1 (0).
ERR: failed in domain API
Test Failed
RE: [EXTERNAL] [RFC v3 2/3] test/lcore: enable tests for topology
Snipped
Quoted 6 lines
Quoted 1 line
---
Test fails on ARM platform:
Quoted 9 lines
lcore 19, socket 0, role RTE, cpuset 19
Control thread running successfully
INFO: lcore count topology: none (12), io (1), l3 (1), l2 (1), l1 (1).
INFO: worker lcore count topology: none (11), io (1), l3 (1), l2 (1), l1 (1).
INFO: lcore DOMAIN macro: success!
INFO: lcore count: none (12), io (0), l3 (0), l2 (0), l1 (0).
ERR: failed in domain API
Test Failed
Thank you Pavan, for helping me on this. Sharing the fix in v4
RFC v3 3/3 examples: add lcore topology API calls
In reply to Vipin VargheseEnhance example code to allow topology based lcores API, while retaining default behaviour.
- helloworld: allow lcoes to send hello to lcores in selected topology.
- l2fwd: allow use of IO lcores topology.
- skeleton: choose the lcore from IO topology which has more ports.
v3 changes:
- fix typo from SE_NO_TOPOLOGY to USE_NO_TOPOLOGY
--- examples/helloworld/main.c | 142 ++++++++++++++++++++++++++++++++++- examples/l2fwd/main.c | 56 ++++++++++++-- examples/skeleton/basicfwd.c | 22 ++++++ 3 files changed, 210 insertions(+), 10 deletions(-)
examples/helloworld/main.c +140 -2
@@ -7,6 +7,7 @@#include <stdint.h> #include <errno.h> #include <sys/queue.h> +#include <getopt.h> #include <rte_memory.h> #include <rte_launch.h>
@@ -14,6 +15,14 @@#include <rte_per_lcore.h> #include <rte_lcore.h> #include <rte_debug.h> +#include <rte_log.h> + +#define RTE_LOGTYPE_HELLOWORLD RTE_LOGTYPE_USER1 +#define USE_NO_TOPOLOGY 0xffff + +static uint16_t topo_sel =USE_NO_TOPOLOGY ; +/* lcore selector based on Topology */ +static const char short_options[] ="T:" ;/* Launch a function on lcore. 8< */ static int
@@ -21,11 +30,109 @@ lcore_hello(__rte_unused void *arg) {unsigned lcore_id; lcore_id =rte_lcore_id (); +printf ("hello from core %u\n" , lcore_id);return 0 ; } + +static int +send_lcore_hello(__rte_unused void *arg) +{ +unsigned int lcore_id; +uint16_t send_lcore_id; +uint16_t send_count =0 ; + + lcore_id =rte_lcore_id (); + + send_lcore_id =rte_get_next_lcore_from_domain (lcore_id, false, true, topo_sel); + +while ((send_lcore_id !=RTE_MAX_LCORE ) && (lcore_id != send_lcore_id)) { +printf ("hello from core %u to core %u\n" , lcore_id, send_lcore_id); + send_lcore_id =rte_get_next_lcore_from_domain (send_lcore_id, + false, true, topo_sel); + send_count +=1 ; + } + +if (send_count ==0 ) +RTE_LOG (INFO ,HELLOWORLD ,"for lcoe %u; no lcores in same domain!!!\n" , lcore_id); + +return 0 ; +}/* >8 End of launching function on lcore. */ +/* display usage. 8< */ +static void +helloworld_usage (const char *prgname) +{ +printf ("%s [EAL options] -- [-T TOPO]\n" +" -T TOPO: choose topology to send hello to\n" +" - 0: send cores sharing L1 (SMT)\n" +" - 1: send cores sharing L2\n" +" - 2: send cores sharing L3\n" +" - 3: send cores sharing IO\n\n" , + prgname); +} + +static unsigned int +parse_topology (const char *q_arg) +{ +char *end =NULL ; +unsigned long n; + +/* parse the topology option */ + n =strtoul (q_arg, &end,10 ); + +if ((q_arg[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) +return 0 ; + +if (n >3 ) +return USE_NO_TOPOLOGY ; + + n = (n ==0 ) ?RTE_LCORE_DOMAIN_L1 : + (n ==1 ) ?RTE_LCORE_DOMAIN_L2 : + (n ==2 ) ?RTE_LCORE_DOMAIN_L3 : +RTE_LCORE_DOMAIN_IO ; + +return n; +} + +/* Parse the argument given in the command line of the application */ +static int +helloworld_parse_args (int argc,char **argv) +{ +int opt, ret; +char **argvopt = argv; +int option_index; +char *prgname = argv[0 ]; +while ((opt =getopt_long (argc, argvopt, short_options, +NULL , &option_index)) !=EOF ) { +switch (opt) { +/* Topology selection */ +case 'T' : + topo_sel =parse_topology (optarg); +if (topo_sel ==USE_NO_TOPOLOGY ) { +helloworld_usage (prgname); +rte_exit (EXIT_FAILURE ,"Invalid Topology selection\n" ); + } + +RTE_LOG (DEBUG ,HELLOWORLD ,"USR selects (%s) domain cores!\n" , + (topo_sel ==RTE_LCORE_DOMAIN_L1 ) ?"L1" : + (topo_sel ==RTE_LCORE_DOMAIN_L2 ) ?"L2" : + (topo_sel ==RTE_LCORE_DOMAIN_L3 ) ?"L3" :"IO" ); + ret =0 ; +break ; +default : +helloworld_usage (prgname); +return -1 ; + } + } +if (optind >=0 ) + argv[optind-1 ] = prgname; + ret = optind-1 ; + optind =1 ;/* reset getopt lib */ +return ret; +} +/* Initialization of Environment Abstraction Layer (EAL). 8< */ int main (int argc,char **argv)
@@ -38,15 +145,46 @@ main(int argc, char **argv)rte_panic ("Cannot init EAL\n" );/* >8 End of initialization of Environment Abstraction Layer */ + argc -= ret; + argv += ret; + + ret =helloworld_parse_args (argc, argv); +if (ret <0 ) +rte_exit (EXIT_FAILURE ,"Invalid arguments\n" ); + +if (topo_sel !=USE_NO_TOPOLOGY ) { +uint16_t domain_count =rte_get_domain_count (topo_sel); +RTE_LOG (DEBUG ,HELLOWORLD ,"selected Domain (%s)\n" , + (topo_sel ==RTE_LCORE_DOMAIN_L1 ) ?"L1" : + (topo_sel ==RTE_LCORE_DOMAIN_L2 ) ?"L2" : + (topo_sel ==RTE_LCORE_DOMAIN_L3 ) ?"L3" :"IO" ); + +for (int i =0 ; i < domain_count; i++) { +uint16_t domain_lcore_count =rte_lcore_count_from_domain (topo_sel, i); +uint16_t domain_lcore =rte_get_lcore_in_domain (topo_sel, i,0 ); + +if (domain_lcore_count) +RTE_LOG (DEBUG ,HELLOWORLD ,"at index (%u), %u cores, lcore (%u) at index 0\n" , + i, + domain_lcore_count, + domain_lcore); + } + } +/* Launches the function on each lcore. 8< */ RTE_LCORE_FOREACH_WORKER (lcore_id) {/* Simpler equivalent. 8< */ -rte_eal_remote_launch (lcore_hello,NULL , lcore_id); +rte_eal_remote_launch ((topo_sel ==USE_NO_TOPOLOGY ) ? + lcore_hello : send_lcore_hello,NULL , lcore_id);/* >8 End of simpler equivalent. */ }/* call it on main lcore too */ -lcore_hello (NULL ); +if (topo_sel ==USE_NO_TOPOLOGY ) +lcore_hello (NULL ); +else +send_lcore_hello (NULL ); +/* >8 End of launching the function on each lcore. */ rte_eal_mp_wait_lcore ();
examples/l2fwd/main.c +48 -8
97 lines not on this page · raw message
examples/skeleton/basicfwd.c +22 -0
@@ -176,6 +176,11 @@ main(int argc, char *argv[])unsigned nb_ports;uint16_t portid; +uint16_t ports_socket_domain[RTE_MAX_ETHPORTS ] = {0 }; +uint16_t sel_io_socket =0 ; +uint16_t sel_io_indx =0 ; +uint16_t core_count_from_io =0 ; +/* Initializion the Environment Abstraction Layer (EAL). 8< */ int ret =rte_eal_init (argc, argv);if (ret <0 )
@@ -190,6 +195,20 @@ main(int argc, char *argv[])if (nb_ports <2 || (nb_ports &1 ))rte_exit (EXIT_FAILURE ,"Error: number of ports must be even\n" ); +/* get the socekt of each port */ +RTE_ETH_FOREACH_DEV (portid) { + ports_socket_domain[rte_eth_dev_socket_id (portid)] +=1 ; + +if (ports_socket_domain[rte_eth_dev_socket_id (portid)] > sel_io_socket) { + sel_io_socket = ports_socket_domain[rte_eth_dev_socket_id (portid)]; + sel_io_indx =rte_eth_dev_socket_id (portid); + } + } + + core_count_from_io =rte_lcore_count_from_domain (RTE_LCORE_DOMAIN_IO , sel_io_indx); +if (core_count_from_io ==0 ) +printf ("\nWARNING: select main_lcore from IO domain (%u)\n" , sel_io_indx); +/* Creates a new mempool in memory to hold the mbufs. */ /* Allocates mempool to hold the mbufs. 8< */
@@ -210,6 +229,9 @@ main(int argc, char *argv[])if (rte_lcore_count () >1 )printf ("\nWARNING: Too many lcores enabled. Only 1 used.\n" ); +if (rte_lcore_to_socket_id (rte_lcore_id ()) != sel_io_indx) +printf ("\nWARNING: please use lcore from IO domain %u.\n" , sel_io_indx); +/* Call lcore_main on the main core only. Called on single lcore. 8< */ lcore_main ();/* >8 End of called on single lcore. */
Signature · 1 line
2.34.1
RE: [EXTERNAL] [RFC v3 3/3] examples: add lcore topology API calls
Quoted 7 lines
Enhance example code to allow topology based lcores API, while retaining default behaviour.
- helloworld: allow lcoes to send hello to lcores in selected topology.
- l2fwd: allow use of IO lcores topology.
- skeleton: choose the lcore from IO topology which has more ports.
Quoted 5 lines
v3 changes:
- fix typo fromSE_NO_TOPOLOGYtoUSE_NO_TOPOLOGYSigned-off-by Vipin Varghese <[email protected]>---
I see compilation failure on ARM platforms due to missing header include.
../examples/helloworld/main.c: In function 'parse_topology':../examples/helloworld/main.c:83:13: error: implicit declaration of function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]
83 | n = strtoul(q_arg, &end, 10);
| ^~~~~~~
| strtok../examples/helloworld/main.c:83:13: warning: nested extern declaration of 'strtoul' [-Wnested-externs] ../examples/helloworld/main.c: In function 'helloworld_parse_args':../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared (first use in this function)
115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; this is probably fixable by adding '#include <stdlib.h>'
12 | #include <rte_memory.h> +++ |+#include <stdlib.h> 13 | #include <rte_launch.h>
../examples/helloworld/main.c:115:42: note: each undeclared identifier is reported only once for each function it appears in
115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~../examples/helloworld/main.c: In function 'main':../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared (first use in this function)
153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n");
| ^~~~~~~~~~~~../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; thi
Below header include should fix it.
examples/helloworld/main.c +1 -0
@@ -3,6 +3,7 @@*/ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <stdint.h> #include <errno.h>
RE: [EXTERNAL] [RFC v3 3/3] examples: add lcore topology API calls
Hi Pavan,
Snipped
Quoted 40 lines
I see compilation failure on ARM platforms due to missing header include.
../examples/helloworld/main.c: In function 'parse_topology':../examples/helloworld/main.c:83:13: error: implicit declaration of function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]83 | n = strtoul(q_arg, &end, 10); | ^~~~~~~ | strtok
../examples/helloworld/main.c:83:13: warning: nested extern declaration of 'strtoul' [- Wnested-externs]../examples/helloworld/main.c: In function 'helloworld_parse_args':../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared (first use in this function)
115 |rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; this is probably fixable by adding '#include <stdlib.h>'12 | #include <rte_memory.h> +++ |+#include <stdlib.h> 13 | #include <rte_launch.h>
../examples/helloworld/main.c:115:42: note: each undeclared identifier is reported only once for each function it appears in
115 |rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~../examples/helloworld/main.c: In function 'main':../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared (first use in this function)153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n"); | ^~~~~~~~~~~~
../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; thiBelow header include should fix it.
examples/helloworld/main.c index renamed from examples/helloworld/main.c +0
-0
9845c3775c3a..f49bd0108f74100644
examples/helloworld/main.c line 9
Quoted 7 lines
examples/helloworld/main.c +1
-0@@ -3,6 +3,7 @@*/ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <stdint.h> #include <errno.h>
Thank you for helping me here, I did run with check_includes & developer_mode, it did not throw this error.
Before patch submission I tried devtools/test-meson-builds.sh too. I think internally this is not using check_includes & developer_mode . Let me recheck and fix this in version 4.
RE: [EXTERNAL] [RFC v3 3/3] examples: add lcore topology API calls
Quoted 50 lines
Hi Pavan,
Snipped
Quoted 9 lines
I see compilation failure on ARM platforms due to missing header include.
../examples/helloworld/main.c: In function 'parse_topology':../examples/helloworld/main.c:83:13: error: implicit declaration of function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]83 | n = strtoul(q_arg, &end, 10); | ^~~~~~~ | strtokQuoted 6 lines
../examples/helloworld/main.c:83:13: warning: nested extern declaration of 'strtoul' [- Wnested-externs]../examples/helloworld/main.c: In function 'helloworld_parse_args':../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared (first use in this function)
115 | rte_exit(EXIT_FAILURE, "Invalid Topologyselection\n");
Quoted 9 lines
| ^~~~~~~~~~~~
../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; this is probably fixable by adding '#include <stdlib.h>'12 | #include <rte_memory.h> +++ |+#include <stdlib.h> 13 | #include <rte_launch.h>
../examples/helloworld/main.c:115:42: note: each undeclared identifier is reported only once for each function it appears in
115 | rte_exit(EXIT_FAILURE, "Invalid Topologyselection\n");
Quoted 19 lines
| ^~~~~~~~~~~~
../examples/helloworld/main.c: In function 'main':../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared (first use in this function)153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n"); | ^~~~~~~~~~~~
../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; thiBelow header include should fix it.
examples/helloworld/main.c +0
-0index
9845c3775c3a..f49bd0108f74100644examples/helloworld/main.c +0
-0@@ -3,6 +3,7 @@*/
Quoted 11 lines
examples/helloworld/main.c line 9
Quoted 5 lines
examples/helloworld/main.c +1
-0#include <stdio.h> +#include <stdlib.h> #include <string.h> #include <stdint.h> #include <errno.h> Thank you for helping me here, I did run with
check_includes & developer_mode, it did not throw this error.
Before patch submission I trieddevtools/test-meson-builds.shtoo. I think internally this is not usingcheck_includes & developer_mode.
Let me recheck and fix this in version 4.
Thank you, I found the reason for my miss on this.
When build using cross compiler manually, no issues with the steps
``` meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc ninja -C arm64-build cd example/helloworld make ```
But building using cross compiler with examples manually, no issues with the steps
``` meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc -Dexamples=helloworld ninja -C arm64-build ```
We get the logs as
```
../examples/helloworld/main.c: In function 'parse_topology':
../examples/helloworld/main.c:83:13: warning: implicit declaration of function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]
83 | n = strtoul(q_arg, &end, 10);
| ^~~~~~~
| strtok
../examples/helloworld/main.c:83:13: warning: nested extern declaration of 'strtoul' [-Wnested-externs]
../examples/helloworld/main.c: In function 'helloworld_parse_args':
../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared (first use in this function)
115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~
../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; did you forget to '#include <stdlib.h>'?
12 | #include <rte_memory.h>
+++ |+#include <stdlib.h>
13 | #include <rte_launch.h>
../examples/helloworld/main.c:115:42: note: each undeclared identifier is reported only once for each function it appears in
115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~
../examples/helloworld/main.c: In function 'main':
../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared (first use in this function)
153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n");
| ^~~~~~~~~~~~
../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; did you forget to '#include <stdlib.h>'?
[2963/4590] Compiling C object drivers/libtmp_rte_event_cnxk.a.p/event_cnxk_tx_cn10k_tx_112_127_seg.c.o
ninja: build stopped: subcommand failed.
```RE: [EXTERNAL] [RFC v3 3/3] examples: add lcore topology API calls
Quoted 73 lines
Quoted 49 lines
Hi Pavan,
Snipped
Quoted 9 lines
I see compilation failure on ARM platforms due to missing header include.
../examples/helloworld/main.c: In function 'parse_topology':../examples/helloworld/main.c:83:13: error: implicit declaration of function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]83 | n = strtoul(q_arg, &end, 10); | ^~~~~~~ | strtokQuoted 6 lines
../examples/helloworld/main.c:83:13: warning: nested extern declaration of 'strtoul' [- Wnested-externs]../examples/helloworld/main.c: In function 'helloworld_parse_args':../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared (first use in this function)
115 | rte_exit(EXIT_FAILURE, "Invalid Topologyselection\n");
Quoted 9 lines
| ^~~~~~~~~~~~
../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; this is probably fixable by adding '#include <stdlib.h>'12 | #include <rte_memory.h> +++ |+#include <stdlib.h> 13 | #include <rte_launch.h>
../examples/helloworld/main.c:115:42: note: each undeclared identifier is reported only once for each function it appears in
115 | rte_exit(EXIT_FAILURE, "Invalid Topologyselection\n");
Quoted 19 lines
| ^~~~~~~~~~~~
../examples/helloworld/main.c: In function 'main':../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared (first use in this function)153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n"); | ^~~~~~~~~~~~
../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; thiBelow header include should fix it.
examples/helloworld/main.c +0
-0index
9845c3775c3a..f49bd0108f74100644examples/helloworld/main.c +0
-0@@ -3,6 +3,7 @@*/ Quoted 7 lines
examples/helloworld/main.c line 9
Quoted 5 lines
examples/helloworld/main.c +1
-0#include <stdio.h> +#include <stdlib.h> #include <string.h> #include <stdint.h> #include <errno.h> Thank you for helping me here, I did run with `check_includes &
developer_mode`,
Quoted 2 lines
it did not throw this error.
Before patch submission I trieddevtools/test-meson-builds.shtoo. I thinkinternally
Quoted 2 lines
this is not using
check_includes & developer_mode. Let me recheck and fix this in version 4.Thank you, I found the reason for my miss on this.
When build using cross compiler manually, no issues with the steps
``` meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc ninja -C arm64-build cd example/helloworld make ```
Quoted 8 lines
But building using cross compiler with examples manually, no issues with the steps
``` meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc - Dexamples=helloworld ninja -C arm64-build ```
I generally run ./devtools/test-meson-builds.sh as a catch all 😊
RE: [EXTERNAL] [RFC v3 3/3] examples: add lcore topology API calls
Snipped
Quoted 67 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
I see compilation failure on ARM platforms due to missing header include.
../examples/helloworld/main.c: In function 'parse_topology':../examples/helloworld/main.c:83:13: error: implicit declaration of function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]83 | n = strtoul(q_arg, &end, 10); | ^~~~~~~ | strtok
../examples/helloworld/main.c:83:13: warning: nested extern declaration of 'strtoul' [- Wnested-externs]../examples/helloworld/main.c: In function 'helloworld_parse_args':../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared (first use in this function)
115 | rte_exit(EXIT_FAILURE, "Invalid TopologyQuoted 4 lines
Quoted 4 lines
selection\n");
Quoted 3 lines
| ^~~~~~~~~~~~
../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; this is probably fixable by adding '#include<
stdlib.h>'Quoted 47 lines
Quoted 26 lines
Quoted 6 lines
12 | #include <rte_memory.h> +++ |+#include <stdlib.h> 13 | #include <rte_launch.h>
../examples/helloworld/main.c:115:42: note: each undeclared identifier is reported only once for each function it appears in
115 | rte_exit(EXIT_FAILURE, "Invalid Topologyselection\n");
Quoted 19 lines
| ^~~~~~~~~~~~
../examples/helloworld/main.c: In function 'main':../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared (first use in this function)153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n"); | ^~~~~~~~~~~~
../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; thiBelow header include should fix it.
(quoted diff) +0
-0
b/examples/helloworld/main.cindex9845c3775c3a..f49bd0108f74100644examples/helloworld/main.c +0
-0@@ -3,6 +3,7 @@*/ Quoted 7 lines
examples/helloworld/main.c line 9
Quoted 5 lines
examples/helloworld/main.c +1
-0#include <stdio.h> +#include <stdlib.h> #include <string.h> #include <stdint.h> #include <errno.h> Thank you for helping me here, I did run with `check_includes &
developer_mode`,
Quoted 3 lines
it did not throw this error.
Before patch submission I trieddevtools/test-meson-builds.shtoo. I thinkinternally
Quoted 2 lines
this is not using
check_includes & developer_mode. Let me recheck and fix this in version 4.Thank you, I found the reason for my miss on this.
When build using cross compiler manually, no issues with the steps ``` meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc ninja -C arm64-build cd example/helloworld make ```
Quoted 7 lines
Quoted 5 lines
But building using cross compiler with examples manually, no issues with the steps ``` meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc - Dexamples=helloworld ninja -C arm64-build ```
I generally run
./devtools/test-meson-builds.shas a catch all 😊
Thank you sharing v4 with fix