eal: fix recording of detected/enabled logical cores
PATCH 1/1 eal: fix recording of detected/enabled logical cores
From: Ivan Boule <[email protected]>
1) In the EAL initialization phase, invoke the function rte_eal_cpu_init to detect the set of running cores (and enable them by default) before processing the [enabled] core mask option that is performed during the parsing of EAL arguments.
2) In the function rte_eal_cpu_init():
- to parse the set of all running logical cores on the machine, do not use the RTE_LCORE_FOREACH macro that considers the set of already detected cores...
Instead, use a standard loop based on the RTE_MAX_LCORE constant.
- explicitely set to ROLE_RTE the role of each detected logical core that is recorded in the EAL configuration, as all running cores are enabled by default.
3) In the function eal_parse_coremask(), update the "lcore_count" field of the EAL configuration with the effective number of logical cores that are set in the mask of enabled logical cores.
--- lib/librte_eal/linuxapp/eal/eal.c | 8 +++++--- lib/librte_eal/linuxapp/eal/eal_lcore.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +5 -3
@@ -389,6 +389,8 @@ eal_parse_coremask(const char *coremask) cfg->lcore_role[i] =ROLE_OFF ; } } +/* Update the count of enabled logical cores of the EAL configuration */ + cfg->lcore_count = count;return 0 ; }
@@ -817,6 +819,9 @@ rte_eal_init(int argc, char **argv)if (rte_eal_log_early_init () <0 )rte_panic ("Cannot init early logs\n" ); +if (rte_eal_cpu_init () <0 ) +rte_panic ("Cannot detect lcores\n" ); + fctret =eal_parse_args (argc, argv);if (fctret <0 )exit (1 );
@@ -849,9 +854,6 @@ rte_eal_init(int argc, char **argv)rte_config_init (); -if (rte_eal_cpu_init () <0 ) -rte_panic ("Cannot detect lcores\n" ); -if (rte_eal_memory_init () <0 )rte_panic ("Cannot init memory\n" );
lib/librte_eal/linuxapp/eal/eal_lcore.c +8 -4
@@ -152,15 +152,19 @@ rte_eal_cpu_init(void)unsigned lcore_id;unsigned count =0 ; -/* disable lcores that were not detected */ -RTE_LCORE_FOREACH (lcore_id) { - +/* +* Parse the maximum set of logical cores, detect the subset of running +* ones and enable them by default. +*/ +for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { lcore_config[lcore_id].detected =cpu_detected (lcore_id);if (lcore_config[lcore_id].detected ==0 ) {RTE_LOG (DEBUG ,EAL ,"Skip lcore %u (not detected)\n" , lcore_id); config->lcore_role[lcore_id] =ROLE_OFF ;continue ; } +/* By default, each detected core is enabled */ + config->lcore_role[lcore_id] =ROLE_RTE ; lcore_config[lcore_id].core_id =cpu_core_id (lcore_id); lcore_config[lcore_id].socket_id =cpu_socket_id (lcore_id);if (lcore_config[lcore_id].socket_id >=RTE_MAX_NUMA_NODES )
@@ -177,7 +181,7 @@ rte_eal_cpu_init(void) lcore_config[lcore_id].socket_id); count ++; } - +/* Set the count of enabled logical cores of the EAL configuration */ config->lcore_count = count;return 0 ;
Signature · 1 line
1.7.10.4
Adrien Mazarguil
Acked-byQuoted 20 lines · Thomas Monjalon
From: Ivan Boule <[email protected]>
1) In the EAL initialization phase, invoke the function
rte_eal_cpu_initto detect the set of running cores (and enable them by default) before processing the [enabled] core mask option that is performed during the parsing of EAL arguments.2) In the function
rte_eal_cpu_init():
- to parse the set of all running logical cores on the machine, do not use theRTE_LCORE_FOREACHmacro that considers the set of already detected cores...
Instead, use a standard loop based on theRTE_MAX_LCOREconstant.
- explicitely set toROLE_RTEthe role of each detected logical core that is recorded in the EAL configuration, as all running cores are enabled by default.3) In the function
eal_parse_coremask(), update the "lcore_count" field of the EAL configuration with the effective number of logical cores that are set in the mask of enabled logical cores.
Quoted 5 lines
Signed-off-by Ivan Boule <[email protected]>--- lib/librte_eal/linuxapp/eal/eal.c | 8 +++++--- lib/librte_eal/linuxapp/eal/eal_lcore.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-)
Signature · 2 lines
Adrien Mazarguil 6WIND
26/07/2013 13:55, Thomas Monjalon :
Quoted 16 lines
From: Ivan Boule <[email protected]>
1) In the EAL initialization phase, invoke the function
rte_eal_cpu_initto detect the set of running cores (and enable them by default) before processing the [enabled] core mask option that is performed during the parsing of EAL arguments.2) In the function
rte_eal_cpu_init():
- to parse the set of all running logical cores on the machine, do not use theRTE_LCORE_FOREACHmacro that considers the set of already detected cores...
Instead, use a standard loop based on theRTE_MAX_LCOREconstant.
- explicitely set toROLE_RTEthe role of each detected logical core that is recorded in the EAL configuration, as all running cores are enabled by default.
Quoted 5 lines
3) In the function
eal_parse_coremask(), update the "lcore_count" field of the EAL configuration with the effective number of logical cores that are set in the mask of enabled logical cores.Signed-off-by Ivan Boule <[email protected]>
acked and pushed
Signature · 1 line
Thomas