The eal_parse_args function was performing several updates to the runtime state that do not logically belong in a parse_args function. Move these to the "eal_adjust_config()" function, which is now renamed to the more accurate "eal_apply_runtime_state()". Ensure too, that all queries for the multi process mode use the runtime state rather than the original user provided value, which needs resolution if it's AUTO.
Signed-off-by: Bruce Richardson <[email protected]> --- lib/eal/common/eal_common_options.c | 68 +++++++++++++---------------- lib/eal/common/eal_options.h | 2 +- lib/eal/freebsd/eal.c | 7 +-- lib/eal/linux/eal.c | 7 +-- 4 files changed, 36 insertions(+), 48 deletions(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index b2aba99f12..ea49a44218 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -2078,7 +2078,6 @@ int eal_parse_args(void) { struct eal_user_cfg *user_cfg = eal_get_user_configuration(); - struct eal_runtime_state *runtime_state = eal_get_runtime_state(); bool remap_lcores = (args.remap_lcore_ids != NULL); struct arg_list_elem *arg; uint16_t lcore_id_base = 0; @@ -2206,17 +2205,6 @@ eal_parse_args(void) if (args.main_lcore != NULL && eal_parse_main_lcore(args.main_lcore) < 0) return -1; - if (user_cfg->main_lcore != -1) { - runtime_state->main_lcore = user_cfg->main_lcore; - } else { - /* default main lcore is the first one */ - runtime_state->main_lcore = rte_get_next_lcore(-1, 0, 0); - if (runtime_state->main_lcore >= RTE_MAX_LCORE) { - EAL_LOG(ERR, "Main lcore is not enabled for DPDK"); - return -1; - } - } - /* memory options */ if (args.memory_size != NULL) { char *end = NULL; @@ -2441,23 +2429,11 @@ eal_parse_args(void) } } -#ifndef RTE_EXEC_ENV_WINDOWS - /* create runtime data directory. In no_shconf mode, skip any errors */ - if (eal_create_runtime_dir() < 0) { - if (!user_cfg->no_shconf) { - EAL_LOG(ERR, "Cannot create runtime directory"); - return -1; - } - EAL_LOG(WARNING, "No DPDK runtime directory created"); - } -#endif - - if (eal_adjust_config() != 0) { - EAL_LOG(ERR, "Invalid configuration"); - return -1; - } + /* sum per-NUMA memory requests into user_cfg->memory */ + for (int i = 0; i < RTE_MAX_NUMA_NODES; i++) + user_cfg->memory += user_cfg->numa_mem[i]; - return 0; + return eal_apply_runtime_state(); } static void @@ -2505,20 +2481,38 @@ eal_cleanup_config(const struct eal_user_cfg *user_cfg) } int -eal_adjust_config(void) +eal_apply_runtime_state(void) { struct eal_user_cfg *user_cfg = eal_get_user_configuration(); - int i; + struct eal_runtime_state *runtime_state = eal_get_runtime_state(); - if (user_cfg->process_type == RTE_PROC_AUTO) - user_cfg->process_type = eal_proc_type_detect(); + /* set the main lcore */ + if (user_cfg->main_lcore != -1) { + runtime_state->main_lcore = user_cfg->main_lcore; + } else { + /* default main lcore is the first one */ + runtime_state->main_lcore = rte_get_next_lcore(-1, 0, 0); + if (runtime_state->main_lcore >= RTE_MAX_LCORE) { + EAL_LOG(ERR, "Main lcore is not enabled for DPDK"); + return -1; + } + } - compute_ctrl_threads_cpuset(); +#ifndef RTE_EXEC_ENV_WINDOWS + /* create runtime data directory. In no_shconf mode, skip any errors */ + if (eal_create_runtime_dir() < 0) { + if (!user_cfg->no_shconf) { + EAL_LOG(ERR, "Cannot create runtime directory"); + return -1; + } + EAL_LOG(WARNING, "No DPDK runtime directory created"); + } +#endif - /* if no memory amounts were requested, this will result in 0 and - * will be overridden later, right after eal_hugepage_info_init() */ - for (i = 0; i < RTE_MAX_NUMA_NODES; i++) - user_cfg->memory += user_cfg->numa_mem[i]; + runtime_state->process_type = (user_cfg->process_type == RTE_PROC_AUTO) ? + eal_proc_type_detect() : user_cfg->process_type; + + compute_ctrl_threads_cpuset(); return 0; } diff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h index 58fb3085e5..eee7339e90 100644 --- a/lib/eal/common/eal_options.h +++ b/lib/eal/common/eal_options.h @@ -14,7 +14,7 @@ int eal_parse_log_options(void); int eal_parse_args(void); int eal_option_device_parse(void); int eal_apply_hugepage_mem_sz_limits(void); -int eal_adjust_config(void); +int eal_apply_runtime_state(void); int eal_cleanup_config(const struct eal_user_cfg *user_cfg); enum rte_proc_type_t eal_proc_type_detect(void); int eal_plugins_init(void); diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 18333071de..acb650031b 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -284,9 +284,6 @@ static int eal_mem_config_init(void) { struct eal_runtime_state *runtime_state = eal_get_runtime_state(); - const struct eal_user_cfg *user_cfg = eal_get_user_configuration(); - - runtime_state->process_type = user_cfg->process_type; switch (runtime_state->process_type) { case RTE_PROC_PRIMARY: @@ -564,7 +561,7 @@ rte_eal_init(int argc, char **argv) if (!user_cfg->no_hugetlbfs) { /* shared mem config not yet attached */ - ret = user_cfg->process_type == RTE_PROC_PRIMARY ? + ret = rte_eal_process_type() == RTE_PROC_PRIMARY ? eal_hugepage_info_init() : eal_hugepage_info_read(); if (ret < 0) { @@ -572,7 +569,7 @@ rte_eal_init(int argc, char **argv) rte_errno = EACCES; goto err_out; } - if (user_cfg->process_type == RTE_PROC_PRIMARY && + if (rte_eal_process_type() == RTE_PROC_PRIMARY && eal_apply_hugepage_mem_sz_limits() < 0) { rte_eal_init_alert("Cannot apply hugepage memory limits."); rte_errno = EINVAL; diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 7f8010b61d..32b7206f63 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -366,9 +366,6 @@ static int eal_mem_config_init(void) { struct eal_runtime_state *runtime_state = eal_get_runtime_state(); - const struct eal_user_cfg *user_cfg = eal_get_user_configuration(); - - runtime_state->process_type = user_cfg->process_type; switch (runtime_state->process_type) { case RTE_PROC_PRIMARY: @@ -736,7 +733,7 @@ rte_eal_init(int argc, char **argv) if (!user_cfg->no_hugetlbfs) { /* shared mem config not yet attached */ - ret = user_cfg->process_type == RTE_PROC_PRIMARY ? + ret = rte_eal_process_type() == RTE_PROC_PRIMARY ? eal_hugepage_info_init() : eal_hugepage_info_read(); if (ret < 0) { @@ -744,7 +741,7 @@ rte_eal_init(int argc, char **argv) rte_errno = EACCES; goto err_out; } - if (user_cfg->process_type == RTE_PROC_PRIMARY && + if (rte_eal_process_type() == RTE_PROC_PRIMARY && eal_apply_hugepage_mem_sz_limits() < 0) { rte_eal_init_alert("Cannot apply hugepage memory limits."); rte_errno = EINVAL; -- 2.55.0

