Allow intitializing EAL without argc/argv
Subsystems (2)
PATCH 39/39 eal: provide hooks for init with externally supplied config
In reply to Bruce RichardsonNow that we have a split EAL init, where most work is done on a configured eal_user_cfg structure, add in hooks to allow other libraries to init EAL by passing in that structure pre-configured.
We export an internal function that wraps the second stage init, while taking care of the run_once flag, before calling the main initialization function with a prepopulated config.
Also, export internally the platform info function so that any callers of this new function can do any necessary validation of parameters as part of their setup.
--- lib/eal/common/eal_common_config.c | 5 +-- lib/eal/common/eal_common_lcore.c | 6 ++-- lib/eal/common/eal_common_thread.c | 2 +- lib/eal/common/eal_internal_cfg.h | 8 ++++- lib/eal/freebsd/eal.c | 53 ++++++++++++++++++++++++--- lib/eal/freebsd/eal_hugepage_info.c | 2 +- lib/eal/freebsd/eal_memory.c | 6 ++-- lib/eal/linux/eal.c | 51 +++++++++++++++++++++++--- lib/eal/linux/eal_hugepage_info.c | 2 +- lib/eal/windows/eal.c | 56 ++++++++++++++++++++++++++++- lib/eal/windows/eal_hugepages.c | 2 +- lib/eal/windows/eal_memalloc.c | 2 +- 12 files changed, 171 insertions(+), 24 deletions(-)
lib/eal/common/eal_common_config.c +3 -2
@@ -68,8 +68,9 @@ eal_get_user_configuration(void) }/* Return a pointer to the platform state structure */ +RTE_EXPORT_INTERNAL_SYMBOL (rte_eal_get_platform_info) const struct eal_platform_info * -eal_get_platform_info (void ) +rte_eal_get_platform_info (void ) {/* platform-discovered and runtime EAL state */ static struct eal_platform_info eal_platform_info;
@@ -302,7 +303,7 @@ inteal_apply_hugepage_mem_sz_limits (void) {const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();unsigned int i;
lib/eal/common/eal_common_lcore.c +3 -3
@@ -54,7 +54,7 @@ RTE_EXPORT_SYMBOL(rte_lcore_to_cpu_id)int rte_lcore_to_cpu_id (int lcore_id) {const struct eal_runtime_state *runtime_state =eal_get_runtime_state (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();unsigned int cpu;if (unlikely (lcore_id >=RTE_MAX_LCORE ))
@@ -267,7 +267,7 @@ RTE_EXPORT_SYMBOL(rte_socket_count)unsigned int rte_socket_count (void ) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();return platform_info->numa_node_count; }
@@ -275,7 +275,7 @@ RTE_EXPORT_SYMBOL(rte_socket_id_by_idx)int rte_socket_id_by_idx (unsigned int idx) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();if (idx >= platform_info->numa_node_count) { rte_errno =EINVAL ;return -1 ;
lib/eal/common/eal_common_thread.c +1 -1
@@ -40,7 +40,7 @@ unsigned rte_socket_id(void)int eal_cpuset_socket_id (const rte_cpuset_t *cpusetp) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();int socket_id =SOCKET_ID_ANY ;if (cpusetp ==NULL )
lib/eal/common/eal_internal_cfg.h +7 -1
@@ -25,6 +25,7 @@#include <rte_bitset.h> #include <rte_stdatomic.h> #include "eal_thread.h" +#include "rte_compat.h" /* Forward declaration — full definition is in eal_memcfg.h */ struct rte_mem_config ;
@@ -385,8 +386,13 @@ struct eal_runtime_state {struct eal_solib_list loaded_plugins;/**< all plugins loaded by eal_plugins_init() */ }; -const struct eal_platform_info *eal_get_platform_info (void ); +__rte_internal +const struct eal_platform_info *rte_eal_get_platform_info(void);struct eal_user_cfg *eal_get_user_configuration (void );struct eal_runtime_state *eal_get_runtime_state (void ); +__rte_internal +int +rte_eal_runtime_init (const char *progname,const struct eal_user_cfg *user_provided_cfg); +#endif /* EAL_INTERNAL_CFG_H */
lib/eal/freebsd/eal.c +48 -5
95 lines not on this page · raw message
lib/eal/freebsd/eal_hugepage_info.c +1 -1
@@ -87,7 +87,7 @@ eal_get_platform_hp_info(struct eal_platform_info *platform_info)int eal_hugepage_info_init (void ) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();int num_buffers, fd;int64_t buffer_size;struct eal_runtime_state *runtime_state =eal_get_runtime_state ();
lib/eal/freebsd/eal_memory.c +3 -3
@@ -72,7 +72,7 @@ rte_eal_hugepage_init(void)void *addr;unsigned int i, j, seg_idx =0 ;const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* get pointer to global configuration */
@@ -285,7 +285,7 @@ attach_segment(const struct rte_memseg_list *msl, const struct rte_memseg *ms,int rte_eal_hugepage_attach (void ) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct hugepage_info *hpi;int fd_hugepage =-1 ;
@@ -354,7 +354,7 @@ memseg_primary_init(void)int hpi_idx, msl_idx =0 ;struct rte_memseg_list *msl;const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* no-huge does not need this at all */
lib/eal/linux/eal.c +47 -4
87 lines not on this page · raw message
lib/eal/linux/eal_hugepage_info.c +1 -1
@@ -518,7 +518,7 @@ hugepage_info_init(void)unsigned int reusable_pages;struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();int failed =0 ;/* platform_info->hugepage_sizes[] is already sorted largest to smallest */
lib/eal/windows/eal.c +55 -1
91 lines not on this page · raw message
lib/eal/windows/eal_hugepages.c +1 -1
@@ -59,7 +59,7 @@ hugepage_claim_privilege(void)static int hugepage_info_init (void ) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct hugepage_info *hpi;unsigned int socket_id;int ret =0 ;
lib/eal/windows/eal_memalloc.c +1 -1
@@ -314,7 +314,7 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs,int ret =-1 ;struct alloc_walk_param wa;const struct hugepage_info *hi =NULL ; -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();
Signature · 1 line
2.53.0
Re: [PATCH 00/39] Rework EAL configuration
In reply to Bruce RichardsonQuoted 139 lines · On Tue, 21 Jul 2026 10:45:08 +0100 Bruce Richardson…
This patchset reworks how configuration is stored and managed in EAL. The existing "
internal_config", "rte_config", "lcore_config" structures, which sometimes have arbitrary separation between them (especially the first two) are replaced by three new structures with clearly defined roles:-
eal_platform_info- contains the raw HW info for the system, details of CPUs and hugepage mounts. This is initialized on first use - even before EAL init is called - and is then immutable, since our HW should not change much underneath us. Its early availability means that it can be used to sanity check the contents of the other structs as they are being built up.-
eal_user_cfg- contains the config settings passed in by the user. For existingrte_eal_init, this is built up in the arg parse stage, and it's contents verified against the platform info, e.g. to check core masks are valid etc. Once argument parsing is completed, is also immutable.-
runtime_cfg- basically all the runtime settings that need to be there for DPDK to run, or which change over time. Largely combined content of the oldrte_config,internal_configandlcore_configstructs. This is initialized from the other two structs by eal initialization and can be modified by EAL at any time.Once that is done, we have a clean separation between user provided configuration and the rest of EAL, we can split EAL init into two parts, the first of which parses cmdline arguments and then calls the second which takes the
eal_user_cfgstruct result of that parse and does the actual initialization. The longer-term objective is to have other first-stage functions that prepare theuser_cfgstruct for initialization, so that we can move away from argc/argv as the only method of configuring DPDK initialization.Bruce Richardson (39):
telemetry: make cpuset init parameter const
argparse: check for range overflow in CPU lists
eal: define new functionally distinct config structs
eal: move memory request fields to user config
eal: move NUMA request fields to user config
eal: move hugepage policy fields to user config
eal: move process policy fields to user config
eal: move hugepage limit fields to new config structs
eal: move advanced user config options to user cfg struct
eal: move hugepage size info to platform info struct
eal: move runtime state to appropriate structure
eal: record details of all cpus in platform info
eal: use platform info for lcore lookups
eal: add macro for lowest set CPU bit in a set
eal: store lcore configuration in runtime data
eal: move core indices bitset to runtime state
eal: cleanup CPU init function
eal: move NUMA node information to platform info struct
eal: move lcore role and count to runtime state
eal: make lcore role a field in lcore config struct
eal: move main lcore setting to runtime config struct
eal: move IOVA mode and process type to runtime cfg
eal: move memory config pointer to runtime state struct
eal: removerte_configstructure
eal: separate runtime state update from arg parsing
eal: move device options staging list into user cfg
eal: separate plugin paths from loaded plugin objects
eal: simplify internal driver path iteration APIs
eal: move trace config into user config struct
eal: record service cores in user config struct
eal: store user-provided lcore info in user config struct
eal: clarify docs on params taking lcore IDs
eal: remove internal config reset function
eal: move functions setting runtime state
eal: initialize platform info on first use
eal: remove duplicated scan of sysfs for hugepage details
eal: add utilities for working with user config struct
eal: split EAL init into two stages
eal: provide hooks for init with externally supplied configapp/test/process.h | 4 +- app/test/test_argparse.c | 10 + doc/guides/linux_gsg/eal_args.include.rst | 38 +- lib/argparse/rte_argparse.c | 5 + lib/eal/common/eal_common_bus.c | 4 +- lib/eal/common/eal_common_config.c | 264 ++++++- lib/eal/common/eal_common_dev.c | 10 +- lib/eal/common/eal_common_dynmem.c | 70 +- lib/eal/common/eal_common_fbarray.c | 10 +- lib/eal/common/eal_common_launch.c | 25 +- lib/eal/common/eal_common_lcore.c | 267 ++++--- lib/eal/common/eal_common_mcfg.c | 44 +- lib/eal/common/eal_common_memalloc.c | 5 +- lib/eal/common/eal_common_memory.c | 104 ++- lib/eal/common/eal_common_memzone.c | 24 +- lib/eal/common/eal_common_options.c | 899 ++++++++-------------- lib/eal/common/eal_common_proc.c | 43 +- lib/eal/common/eal_common_tailqs.c | 6 +- lib/eal/common/eal_common_thread.c | 67 +- lib/eal/common/eal_common_timer.c | 2 +- lib/eal/common/eal_common_trace.c | 30 +- lib/eal/common/eal_common_trace_utils.c | 104 --- lib/eal/common/eal_hugepages.h | 8 + lib/eal/common/eal_internal_cfg.h | 386 ++++++++-- lib/eal/common/eal_memcfg.h | 3 + lib/eal/common/eal_option_list.h | 6 +- lib/eal/common/eal_options.h | 8 +- lib/eal/common/eal_private.h | 121 ++- lib/eal/common/eal_trace.h | 11 - lib/eal/common/malloc_elem.c | 15 +- lib/eal/common/malloc_heap.c | 41 +- lib/eal/common/malloc_mp.c | 2 +- lib/eal/common/rte_malloc.c | 14 +- lib/eal/common/rte_service.c | 17 +- lib/eal/freebsd/eal.c | 287 ++++--- lib/eal/freebsd/eal_hugepage_info.c | 78 +- lib/eal/freebsd/eal_lcore.c | 16 +- lib/eal/freebsd/eal_memory.c | 46 +- lib/eal/freebsd/include/rte_os.h | 2 + lib/eal/include/rte_eal.h | 35 +- lib/eal/include/rte_memzone.h | 10 +- lib/eal/include/rte_tailq.h | 2 +- lib/eal/linux/eal.c | 296 ++++--- lib/eal/linux/eal_hugepage_info.c | 231 +++--- lib/eal/linux/eal_lcore.c | 43 ++ lib/eal/linux/eal_memalloc.c | 168 ++-- lib/eal/linux/eal_memory.c | 168 ++-- lib/eal/linux/eal_timer_hpet.c | 21 +- lib/eal/linux/eal_vfio.c | 11 +- lib/eal/linux/include/rte_os.h | 10 + lib/eal/unix/eal_unix_thread.c | 11 +- lib/eal/windows/eal.c | 193 +++-- lib/eal/windows/eal_hugepages.c | 60 +- lib/eal/windows/eal_lcore.c | 6 + lib/eal/windows/eal_memalloc.c | 37 +- lib/eal/windows/eal_memory.c | 14 +- lib/eal/windows/eal_thread.c | 11 +- lib/eal/windows/eal_windows.h | 8 - lib/eal/windows/include/rte_os.h | 1 + lib/eal/windows/include/sched.h | 10 + lib/telemetry/telemetry.c | 4 +- lib/telemetry/telemetry_internal.h | 2 +- 62 files changed, 2499 insertions(+), 1949 deletions(-)
Quoted 3 lines
--
2.53.0
Ran deeper AI review on this and it found a couple small things:
Review of "eal: rework EAL initialization" (39 patches)
Series applies cleanly to main (9231dc7). All 39 commits build individually with -Dwerror=true, so bisect is safe. Findings verified against the merged tree rather than the diffs alone.
Patch 02/39 - argparse: check for range overflow in CPU lists
Warning: missing Fixes: and Cc: stable.
This is an out-of-bounds write, not a cleanup - CPU_SET(min, cpuset) with min >= CPU_SETSIZE writes past the end of rte_cpuset_t. The introducing commit is in v25.11, so it needs backporting:
The fix itself is correct and complete: all three branches assign max before the new check, min >= 0 is guaranteed by the isdigit() gate, and min <= max holds in every branch, so the CPU_SET loop is fully bounded.
Patch 33/39 - eal: remove internal config reset function
Error: removing eal_reset_internal_config() drops the lock_descriptor = -1 preset, which can lead to close(0) on stdin. Linux only.
The deleted function did:
for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) {
memset(&internal_cfg->hugepage_info[i], 0, ...);
internal_cfg->hugepage_info[i].lock_descriptor = -1;
}That -1 was the invariant eal_hugedirs_unlock() relied on. hugepage_info[] now lives in eal_runtime_state, which is a static initialised only with .mem_config, so every lock_descriptor starts at 0 - a valid fd.
This patch compensates by widening the guard:
if (hugepage_info[i].hugepage_sz == 0 ||
hugepage_info[i].lock_descriptor < 0)
continue;but hugepage_sz == 0 is not a sufficient proxy. In hugepage_info_init() (lib/eal/linux/eal_hugepage_info.c) hpi->hugepage_sz is assigned *before* the mountpoint check, and the no-mountpoint path continues without ever assigning lock_descriptor:
hpi = &rs->hugepage_info[num_sizes];
hpi->hugepage_sz = hps->size; /* set first */
if (get_hugepage_dir(...) < 0) {
if (user_cfg->in_memory) {
calc_num_pages(hpi, hps, 0);
num_sizes++; /* entry accepted */
}
continue; /* lock_descriptor never set */
}
hpi->lock_descriptor = open(hpi->hugedir, O_RDONLY);Two reachable cases:
(a) --in-memory with a reserved-but-unmounted size (e.g. 1G reserved,
only 2M mounted). The entry is accepted with hugepage_sz != 0 and
lock_descriptor == 0. (b) Default mode where the *last* size has no mountpoint. num_sizes is not incremented, so slot [num_sizes] keeps a nonzero hugepage_sz with lock_descriptor == 0. eal_hugedirs_unlock() iterates to MAX_HUGEPAGE_SIZES, not num_hugepage_sizes, so it still visits it.
In both, the guard passes and the code runs flock(0, LOCK_UN) followed by close(0) on the normal init path (lib/eal/linux/eal.c:831, unconditional after rte_eal_memory_init()). Confirmed with a standalone harness reproducing the two functions' control flow.
FreeBSD is unaffected (single entry, fd assigned unconditionally, no unlock loop); Windows sets -1 explicitly in eal_hugepages.c.
Simplest fix is to restore the invariant rather than widen the guard - set lock_descriptor = -1 for all MAX_HUGEPAGE_SIZES entries when runtime state is set up, or initialise the entry immediately after hugepage_sz is assigned in hugepage_info_init(). Bounding the unlock loop by num_hugepage_sizes would fix (b) but not (a).
The other non-zero defaults from the deleted function are all preserved
correctly: hugepage_file.unlink_existing, no_hpet, and max_simd_bitwidth.bitwidth are in EAL_USER_CFG_INITIALIZER, and RTE_IOVA_DC / RTE_INTR_MODE_NONE / RTE_PROC_PRIMARY are all genuinely 0. lock_descriptor is the only one lost.
Patch 29/39 - eal: move trace config into user config struct
Warning: --trace-dir accumulate semantics changed, plus a leak on repeat.
The old path went through trace_dir_update(), which concatenated onto any existing value:
asprintf(&dir, "%s%s", trace->dir != NULL ? trace->dir : "", str);
The new code does a plain asprintf into user_cfg->trace_dir. Passing --trace-dir more than once now replaces rather than appends, and the earlier allocation leaks since trace_dir is overwritten without a free. If the replace behaviour is intended, worth saying so in the commit message; otherwise free the previous value first.
Patch 39/39 - eal: provide hooks for init with externally supplied config
Error: rte_eal_runtime_init() returns -1 without setting rte_errno on the platform-info path. Identical in all three platform copies:
if (rte_eal_get_platform_info() == NULL) {
rte_eal_init_alert("Platform information is not available.");
return -1; /* rte_errno not set */
}The other two error paths in the same function set EINVAL and EALREADY, and the equivalent path in rte_eal_init() sets ENOTSUP. A caller checking rte_errno gets a stale value. Suggest rte_errno = ENOTSUP to match.
Warning: the stated purpose is not reachable as posted.
The commit message says the hooks let "other libraries init EAL by passing in that structure pre-configured", but struct eal_user_cfg and both new prototypes live in lib/eal/common/eal_internal_cfg.h. lib/meson.build:143 only adds eal/common to the include path when RTE_LIB_EAL is not yet set, i.e. for EAL's own sub-build; afterwards dependent libraries get deps += ['eal'], which exposes only EAL's public include dirs. No in-tree library can declare the type or call the function without the explicit include_directories() hack used by drivers/common/mlx5/linux/meson.build. Either make the header reachable or note that a follow-up is required.
Warning: both new __rte_internal symbols have no in-tree consumer and no test, so the deep-copy path in eal_user_cfg_copy() is never exercised by anything. A test driving rte_eal_runtime_init() with a hand-populated config would be worth adding alongside.
Info: eal_internal_cfg.h uses #include "rte_compat.h" while every other public RTE header in the same file uses angle brackets.
Checked and found correct
Recording these so they are not re-reviewed:
- eal_user_cfg_copy() deep copy is sound. device_option uses a flexible char arg[], so calloc(1, sizeof(*copy) + arglen) is right; eal_plugin_path uses a fixed char name[PATH_MAX], so malloc(sizeof(*p)) plus memcpy(..., sizeof(name)) is right. Both lists, trace patterns, all four heap strings and the per-lcore cpusets are deep-copied, so cleaning up both user_cfg_from_args and the global config is not a double free. The error path calls eal_user_cfg_cleanup(dst), which is idempotent, so the later eal_cleanup_config() in eal_runtime_init()'s err_out is safe.
- EAL_USER_CFG_INITIALIZER(self): the self-referencing TAILQ_HEAD_INITIALIZER((self).devopt_list) is legal - the object's scope begins after its declarator, and tqh_last correctly points at the final object rather than the compound-literal temporary.
- rte_eal_get_platform_info() double-checked locking has correct acquire/release pairing under a spinlock.
- rte_eal_cpu_init() error paths all free and NULL both cpu_info and numa_nodes, so the caller's fail label cannot double-free. No leak on the numa_node_count > RTE_MAX_NUMA_NODES path.
- eal_expand_cpuset_to_map() and the --lcores parser both NULL entries as they free, so the later eal_user_cfg_cleanup() is safe.
- Every added malloc/calloc/strdup/asprintf checks its return. sprintf(pattern, "%s*", ...) into calloc(1, len + 2) is exactly sized.
- No public ABI change; the only new exports are two RTE_EXPORT_INTERNAL_SYMBOLs and no version.map is hand-edited.
Re: [PATCH 00/39] Rework EAL configuration
Quoted 36 lines · Stephen Hemminger
Quoted 33 lines · On Tue, 21 Jul 2026 10:45:08 +0100 Bruce Richardson…
This patchset reworks how configuration is stored and managed in EAL. The existing "
internal_config", "rte_config", "lcore_config" structures, which sometimes have arbitrary separation between them (especially the first two) are replaced by three new structures with clearly defined roles:-
eal_platform_info- contains the raw HW info for the system, details of CPUs and hugepage mounts. This is initialized on first use - even before EAL init is called - and is then immutable, since our HW should not change much underneath us. Its early availability means that it can be used to sanity check the contents of the other structs as they are being built up.-
eal_user_cfg- contains the config settings passed in by the user. For existingrte_eal_init, this is built up in the arg parse stage, and it's contents verified against the platform info, e.g. to check core masks are valid etc. Once argument parsing is completed, is also immutable.-
runtime_cfg- basically all the runtime settings that need to be there for DPDK to run, or which change over time. Largely combined content of the oldrte_config,internal_configandlcore_configstructs. This is initialized from the other two structs by eal initialization and can be modified by EAL at any time.Once that is done, we have a clean separation between user provided configuration and the rest of EAL, we can split EAL init into two parts, the first of which parses cmdline arguments and then calls the second which takes the
eal_user_cfgstruct result of that parse and does the actual initialization. The longer-term objective is to have other first-stage functions that prepare theuser_cfgstruct for initialization, so that we can move away from argc/argv as the only method of configuring DPDK initialization.
<snip>
Quoted 21 lines
Quoted 3 lines
--
2.53.0Ran deeper AI review on this and it found a couple small things:
Review of "eal: rework EAL initialization" (39 patches)
Series applies cleanly to main (9231dc7). All 39 commits build individually with -Dwerror=true, so bisect is safe. Findings verified against the merged tree rather than the diffs alone.
Patch 02/39 - argparse: check for range overflow in CPU lists
Warning: missing Fixes: and Cc: stable.
This is an out-of-bounds write, not a cleanup -
CPU_SET(min, cpuset)with min >=CPU_SETSIZEwrites past the end ofrte_cpuset_t. The introducing commit is in v25.11, so it needs backporting:
Quoted 7 lines
Fixes d78103fb9488 ("argparse: support core lists")The fix itself is correct and complete: all three branches assign max before the new check, min >= 0 is guaranteed by the
isdigit()gate, and min <= max holds in every branch, so theCPU_SETloop is fully bounded.
Added in v2
Quoted 66 lines
Patch 33/39 - eal: remove internal config reset function
Error: removing
eal_reset_internal_config()drops thelock_descriptor= -1 preset, which can lead to close(0) on stdin. Linux only.The deleted function did:
for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) { memset(&internal_cfg->hugepage_info[i], 0, ...); internal_cfg->hugepage_info[i].lock_descriptor = -1; }That -1 was the invariant
eal_hugedirs_unlock()relied on. hugepage_info[] now lives ineal_runtime_state, which is a static initialised only with .mem_config, so everylock_descriptorstarts at 0 - a valid fd.This patch compensates by widening the guard:
if (hugepage_info[i].hugepage_sz == 0 || hugepage_info[i].lock_descriptor < 0) continue;but
hugepage_sz== 0 is not a sufficient proxy. Inhugepage_info_init()(lib/eal/linux/eal_hugepage_info.c)hpi->hugepage_szis assigned *before* the mountpoint check, and the no-mountpoint path continues without ever assigninglock_descriptor:hpi = &rs->hugepage_info[num_sizes]; hpi->hugepage_sz = hps->size; /* set first */ if (get_hugepage_dir(...) < 0) { if (user_cfg->in_memory) { calc_num_pages(hpi, hps, 0); num_sizes++; /* entry accepted */ } continue; /* lock_descriptor never set */ } hpi->lock_descriptor = open(hpi->hugedir, O_RDONLY);Two reachable cases:
(a) --in-memory with a reserved-but-unmounted size (e.g. 1G reserved,
only 2M mounted). The entry is accepted with hugepage_sz != 0 and lock_descriptor == 0.(b) Default mode where the *last* size has no mountpoint.
num_sizesis not incremented, so slot [num_sizes] keeps a nonzerohugepage_szwithlock_descriptor== 0.eal_hugedirs_unlock()iterates toMAX_HUGEPAGE_SIZES, notnum_hugepage_sizes, so it still visits it.In both, the guard passes and the code runs
flock(0, LOCK_UN)followed by close(0) on the normal init path (lib/eal/linux/eal.c:831, unconditional afterrte_eal_memory_init()). Confirmed with a standalone harness reproducing the two functions' control flow.FreeBSD is unaffected (single entry, fd assigned unconditionally, no unlock loop); Windows sets -1 explicitly in
eal_hugepages.c.Simplest fix is to restore the invariant rather than widen the guard - set
lock_descriptor= -1 for allMAX_HUGEPAGE_SIZESentries when runtime state is set up, or initialise the entry immediately afterhugepage_szis assigned inhugepage_info_init(). Bounding the unlock loop bynum_hugepage_sizeswould fix (b) but not (a).
Quoted 6 lines
The other non-zero defaults from the deleted function are all preserved
correctly: hugepage_file.unlink_existing,no_hpet, and max_simd_bitwidth.bitwidth are inEAL_USER_CFG_INITIALIZER, andRTE_IOVA_DC/RTE_INTR_MODE_NONE/RTE_PROC_PRIMARYare all genuinely 0.lock_descriptoris the only one lost.
Yes, this is a valid issue. Reworked a couple of patches to fix it for v2.
Quoted 8 lines
Patch 29/39 - eal: move trace config into user config struct
Warning: --trace-dir accumulate semantics changed, plus a leak on repeat.
The old path went through
trace_dir_update(), which concatenated onto any existing value:
Quoted 8 lines
asprintf(&dir, "%s%s", trace->dir != NULL ? trace->dir : "", str);The new code does a plain asprintf into
user_cfg->trace_dir. Passing --trace-dir more than once now replaces rather than appends, and the earlier allocation leaks sincetrace_diris overwritten without a free. If the replace behaviour is intended, worth saying so in the commit message; otherwise free the previous value first.
This I believe to be a false positive. The trace-dir EAL flag can only be specified once on the command line, enforced by the argparse library, so the fact that the later functions don't handle multiple values is not a problem. The concatenation here is actually for appending a filename to an existing trace dir.
Quoted 6 lines
Patch 39/39 - eal: provide hooks for init with externally supplied config
Error:
rte_eal_runtime_init()returns -1 without settingrte_errnoon the platform-info path. Identical in all three platform copies:
Quoted 9 lines
if (rte_eal_get_platform_info() == NULL) { rte_eal_init_alert("Platform information is not available."); return -1; /* rte_errno not set */ }The other two error paths in the same function set EINVAL and EALREADY, and the equivalent path in
rte_eal_init()sets ENOTSUP. A caller checkingrte_errnogets a stale value. Suggestrte_errno= ENOTSUP to match.
Fixed in v2. Explicitly set rte_errno = 0 at the start of function and set it explicitly only when it's not already set by a subfunction of get_platform_info.
Quoted 12 lines
Warning: the stated purpose is not reachable as posted.
The commit message says the hooks let "other libraries init EAL by passing in that structure pre-configured", but struct
eal_user_cfgand both new prototypes live inlib/eal/common/eal_internal_cfg.h.lib/meson.build:143only adds eal/common to the include path whenRTE_LIB_EALis not yet set, i.e. for EAL's own sub-build; afterwards dependent libraries get deps += ['eal'], which exposes only EAL's public include dirs. No in-tree library can declare the type or call the function without the explicitinclude_directories()hack used bydrivers/common/mlx5/linux/meson.build. Either make the header reachable or note that a follow-up is required.
Expected. In RFC I included an example of use, but dropped from this v1 series as it's already long enough.
Quoted 5 lines
Warning: both new
__rte_internalsymbols have no in-tree consumer and no test, so the deep-copy path ineal_user_cfg_copy()is never exercised by anything. A test drivingrte_eal_runtime_init()with a hand-populated config would be worth adding alongside.
As above, will hopefully be added later if this makes it in.
Quoted 6 lines
Info:
eal_internal_cfg.huses #include "rte_compat.h" while every other public RTE header in the same file uses angle brackets.Checked and found correct
<snip>
v2 cover Rework EAL configuration
In reply to Bruce RichardsonThis patchset reworks how configuration is stored and managed in EAL. The existing "internal_config", "rte_config", "lcore_config" structures, which sometimes have arbitrary separation between them (especially the first two) are replaced by three new structures with clearly defined roles:
- eal_platform_info - contains the raw HW info for the system, details of CPUs and hugepage mounts. This is initialized on first use - even before EAL init is called - and is then immutable, since our HW should not change much underneath us. Its early availability means that it can be used to sanity check the contents of the other structs as they are being built up.
- eal_user_cfg - contains the config settings passed in by the user. For existing rte_eal_init, this is built up in the arg parse stage, and it's contents verified against the platform info, e.g. to check core masks are valid etc. Once argument parsing is completed, is also immutable.
- runtime_cfg - basically all the runtime settings that need to be there for DPDK to run, or which change over time. Largely combined content of the old rte_config, internal_config and lcore_config structs. This is initialized from the other two structs by eal initialization and can be modified by EAL at any time.
Once that is done, we have a clean separation between user provided configuration and the rest of EAL, we can split EAL init into two parts, the first of which parses cmdline arguments and then calls the second which takes the eal_user_cfg struct result of that parse and does the actual initialization. The longer-term objective is to have other first-stage functions that prepare the user_cfg struct for initialization, so that we can move away from argc/argv as the only method of configuring DPDK initialization.
v2: minor rework following AI review.
Bruce Richardson (39):
telemetry: make cpuset init parameter const
argparse: check for range overflow in CPU lists
eal: define new functionally distinct config structs
eal: move memory request fields to user config
eal: move NUMA request fields to user config
eal: move hugepage policy fields to user config
eal: move process policy fields to user config
eal: move hugepage limit fields to new config structs
eal: move advanced user config options to user cfg struct
eal: move hugepage size info to platform info struct
eal: move runtime state to appropriate structure
eal: record details of all cpus in platform info
eal: use platform info for lcore lookups
eal: add macro for lowest set CPU bit in a set
eal: store lcore configuration in runtime data
eal: move core indices bitset to runtime state
eal: cleanup CPU init function
eal: move NUMA node information to platform info struct
eal: move lcore role and count to runtime state
eal: make lcore role a field in lcore config struct
eal: move main lcore setting to runtime config struct
eal: move IOVA mode and process type to runtime cfg
eal: move memory config pointer to runtime state struct
eal: remove rte_config structure
eal: separate runtime state update from arg parsing
eal: move device options staging list into user cfg
eal: separate plugin paths from loaded plugin objects
eal: simplify internal driver path iteration APIs
eal: move trace config into user config struct
eal: record service cores in user config struct
eal: store user-provided lcore info in user config struct
eal: clarify docs on params taking lcore IDs
eal: remove internal config reset function
eal: move functions setting runtime state
eal: initialize platform info on first use
eal: remove duplicated scan of sysfs for hugepage details
eal: add utilities for working with user config struct
eal: split EAL init into two stages
eal: provide hooks for init with externally supplied config
app/test/process.h | 4 +- app/test/test_argparse.c | 10 + doc/guides/linux_gsg/eal_args.include.rst | 38 +- lib/argparse/rte_argparse.c | 5 + lib/eal/common/eal_common_bus.c | 4 +- lib/eal/common/eal_common_config.c | 267 ++++++- lib/eal/common/eal_common_dev.c | 10 +- lib/eal/common/eal_common_dynmem.c | 70 +- lib/eal/common/eal_common_fbarray.c | 10 +- lib/eal/common/eal_common_launch.c | 25 +- lib/eal/common/eal_common_lcore.c | 267 ++++--- lib/eal/common/eal_common_mcfg.c | 44 +- lib/eal/common/eal_common_memalloc.c | 5 +- lib/eal/common/eal_common_memory.c | 104 ++- lib/eal/common/eal_common_memzone.c | 24 +- lib/eal/common/eal_common_options.c | 899 ++++++++-------------- lib/eal/common/eal_common_proc.c | 43 +- lib/eal/common/eal_common_tailqs.c | 6 +- lib/eal/common/eal_common_thread.c | 67 +- lib/eal/common/eal_common_timer.c | 2 +- lib/eal/common/eal_common_trace.c | 30 +- lib/eal/common/eal_common_trace_utils.c | 104 --- lib/eal/common/eal_hugepages.h | 8 + lib/eal/common/eal_internal_cfg.h | 385 +++++++-- lib/eal/common/eal_memcfg.h | 3 + lib/eal/common/eal_option_list.h | 6 +- lib/eal/common/eal_options.h | 8 +- lib/eal/common/eal_private.h | 121 ++- lib/eal/common/eal_trace.h | 11 - lib/eal/common/malloc_elem.c | 15 +- lib/eal/common/malloc_heap.c | 41 +- lib/eal/common/malloc_mp.c | 2 +- lib/eal/common/rte_malloc.c | 14 +- lib/eal/common/rte_service.c | 17 +- lib/eal/freebsd/eal.c | 291 ++++--- lib/eal/freebsd/eal_hugepage_info.c | 78 +- lib/eal/freebsd/eal_lcore.c | 16 +- lib/eal/freebsd/eal_memory.c | 46 +- lib/eal/freebsd/include/rte_os.h | 2 + lib/eal/include/rte_eal.h | 35 +- lib/eal/include/rte_memzone.h | 10 +- lib/eal/include/rte_tailq.h | 2 +- lib/eal/linux/eal.c | 297 ++++--- lib/eal/linux/eal_hugepage_info.c | 231 +++--- lib/eal/linux/eal_lcore.c | 43 ++ lib/eal/linux/eal_memalloc.c | 168 ++-- lib/eal/linux/eal_memory.c | 168 ++-- lib/eal/linux/eal_timer_hpet.c | 21 +- lib/eal/linux/eal_vfio.c | 11 +- lib/eal/linux/include/rte_os.h | 10 + lib/eal/unix/eal_unix_thread.c | 11 +- lib/eal/windows/eal.c | 197 +++-- lib/eal/windows/eal_hugepages.c | 60 +- lib/eal/windows/eal_lcore.c | 6 + lib/eal/windows/eal_memalloc.c | 37 +- lib/eal/windows/eal_memory.c | 14 +- lib/eal/windows/eal_thread.c | 11 +- lib/eal/windows/eal_windows.h | 8 - lib/eal/windows/include/rte_os.h | 1 + lib/eal/windows/include/sched.h | 10 + lib/telemetry/telemetry.c | 4 +- lib/telemetry/telemetry_internal.h | 2 +- 62 files changed, 2511 insertions(+), 1948 deletions(-)
--
2.53.0
PATCH v2 1/39 telemetry: make cpuset init parameter const
The cpuset parameter to telemetry_init is not modified so can be marked as const. This can allow callers to pass the parameter from a const structure rather than a modifiable one.
--- lib/telemetry/telemetry.c | 4 ++-- lib/telemetry/telemetry_internal.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/telemetry/telemetry.c +2 -2
@@ -56,7 +56,7 @@ static struct socket v1_socket; /* socket for v1 telemetry */static const char *telemetry_version;/* save rte_version */ static const char *socket_dir;/* runtime directory */ -static rte_cpuset_t *thread_cpuset; +static const rte_cpuset_t *thread_cpuset;RTE_LOG_REGISTER_DEFAULT (logtype,WARNING );#define RTE_LOGTYPE_TELEMETRY logtype
@@ -658,7 +658,7 @@ telemetry_v2_init(void)RTE_EXPORT_INTERNAL_SYMBOL (rte_telemetry_init) int32_t -rte_telemetry_init (const char *runtime_dir,const char *rte_version,rte_cpuset_t *cpuset) +rte_telemetry_init (const char *runtime_dir,const char *rte_version,const rte_cpuset_t *cpuset) { telemetry_version = rte_version; socket_dir = runtime_dir;
lib/telemetry/telemetry_internal.h +1 -1
@@ -119,6 +119,6 @@ typedef int (*rte_log_fn)(uint32_t level, uint32_t logtype, const char *format,*/ __rte_internal int -rte_telemetry_init (const char *runtime_dir,const char *rte_version,rte_cpuset_t *cpuset); +rte_telemetry_init (const char *runtime_dir,const char *rte_version,const rte_cpuset_t *cpuset);#endif
Signature · 1 line
2.53.0
PATCH v2 2/39 argparse: check for range overflow in CPU lists
In reply to Bruce RichardsonThe rte_cpuset_t type cannot handle core ids greater than CPU_SETSIZE Add an explicit check for out of range values when processes a corelist.
--- app/test/test_argparse.c | 10 ++++++++++ lib/argparse/rte_argparse.c | 5 +++++ 2 files changed, 15 insertions(+)
app/test/test_argparse.c +10 -0
@@ -834,9 +834,13 @@ test_argparse_parse_type_corelist(void)char *corelist_invalid_special_chars =test_strdup ("1,2@3" );char *corelist_invalid_comma_only =test_strdup ("," );char *corelist_invalid_out_of_range =test_strdup ("70000" ); +char corelist_invalid_cpu_set[32 ];rte_cpuset_t val_cpuset;int ret; +snprintf (corelist_invalid_cpu_set,sizeof (corelist_invalid_cpu_set), +"0-%d" ,CPU_SETSIZE ); +/* test valid single core */ CPU_ZERO (&val_cpuset); ret = rte_argparse_parse_type(corelist_valid_single,
@@ -966,6 +970,12 @@ test_argparse_parse_type_corelist(void) RTE_ARGPARSE_VALUE_TYPE_CORELIST, &val_cpuset);TEST_ASSERT (ret !=0 ,"Argparse parse type for corelist (out of range) should have failed!" ); +/* test invalid corelist that exceeds the destination CPU set */ +CPU_ZERO (&val_cpuset); + ret =rte_argparse_parse_type (corelist_invalid_cpu_set, +RTE_ARGPARSE_VALUE_TYPE_CORELIST , &val_cpuset); +TEST_ASSERT (ret !=0 ,"Argparse parse type for corelist outside CPU set should have failed!" ); +return 0 ; }
lib/argparse/rte_argparse.c +5 -0
@@ -623,6 +623,11 @@ parse_arg_corelist(const struct rte_argparse_arg *arg, const char *value)/* range from low to high */ max = idx; } +if (max >=CPU_SETSIZE ) { +ARGPARSE_LOG (ERR ,"argument %s contains a core outside the CPU set range!" , + arg->name_long); +return -EINVAL ; + }for (; min <= max; min++)CPU_SET (min, cpuset);
Signature · 1 line
2.53.0
PATCH v2 3/39 eal: define new functionally distinct config structs
In reply to Bruce RichardsonRather than having a generic internal_config structure which mixes system configuration, memory configuration, and user options in one struct, create separate structures for the platform info, system runtime state and the user provided config. Later patches will complete these with data moved from the current location.
--- lib/eal/common/eal_common_config.c | 31 ++++++++++++++++++++++++++++++ lib/eal/common/eal_internal_cfg.h | 28 +++++++++++++++++++++++++++ 2 files changed, 59 insertions(+)
lib/eal/common/eal_common_config.c +31 -0
@@ -5,6 +5,7 @@#include <rte_string_fns.h> #include <eal_export.h> +#include "eal_internal_cfg.h" #include "eal_private.h" #include "eal_filesystem.h" #include "eal_memcfg.h"
@@ -27,6 +28,15 @@ static struct rte_config rte_config = {/* platform-specific runtime dir */ static char runtime_dir[UNIX_PATH_MAX ]; +/* user-provided EAL configuration */ +static struct eal_user_cfg eal_user_cfg; + +/* platform-discovered and runtime EAL state */ +static struct eal_platform_info eal_platform_info; + +/* internal runtime configuration */ +static struct eal_runtime_state eal_runtime_state; +/* internal configuration */ static struct internal_config internal_config;
@@ -63,6 +73,27 @@ eal_get_internal_configuration(void)return &internal_config; } +/* Return a pointer to the user configuration structure */ +struct eal_user_cfg * +eal_get_user_configuration (void ) +{ +return &eal_user_cfg; +} + +/* Return a pointer to the platform state structure */ +struct eal_platform_info * +eal_get_platform_info (void ) +{ +return &eal_platform_info; +} + +/* Return a pointer to the runtime state structure */ +struct eal_runtime_state * +eal_get_runtime_state (void ) +{ +return &eal_runtime_state; +} +RTE_EXPORT_SYMBOL (rte_eal_iova_mode) enum rte_iova_moderte_eal_iova_mode (void )
lib/eal/common/eal_internal_cfg.h +28 -0
@@ -48,6 +48,31 @@ struct hugepage_file_discipline {bool unlink_existing; }; +/** +* User-provided EAL initialization configuration. +* Immutable after initialization, so no need for atomic types or locks. +*/ +struct eal_user_cfg { +uint8_t reserved; +}; + +/** +* Discovered information about cores, memory, etc. on the system. +* Immutable after initialization, so no need for atomic types or locks. +*/ +struct eal_platform_info { +uint8_t reserved; +}; + +/** +* Internal EAL runtime state +* May be modified at runtime, so access must be protected by locks or atomic types +* as appropriate. +*/ +struct eal_runtime_state { +uint8_t reserved; +}; +/** * internal configuration */
@@ -115,6 +140,9 @@ struct internal_config { unsigned int no_auto_probing; /**< true to switch from block-listing to allow-listing */ }; +struct eal_user_cfg *eal_get_user_configuration (void ); +struct eal_platform_info *eal_get_platform_info (void ); +struct eal_runtime_state *eal_get_runtime_state (void );void eal_reset_internal_config (struct internal_config *internal_cfg);#endif /* EAL_INTERNAL_CFG_H */
Signature · 1 line
2.53.0
PATCH v2 4/39 eal: move memory request fields to user config
In reply to Bruce RichardsonMove the basic memory request information supplied by the user from the internal-config to the user config structure in EAL. For the number of channels or ranks of memory, limit the data size to uint8_t rather than having a full 32-bit value per entry.
--- lib/eal/common/eal_common_dynmem.c | 11 ++++--- lib/eal/common/eal_common_memory.c | 8 ++--- lib/eal/common/eal_common_options.c | 47 ++++++++++++++++++++++------- lib/eal/common/eal_internal_cfg.h | 8 ++--- lib/eal/freebsd/eal.c | 7 +++-- lib/eal/freebsd/eal_memory.c | 11 ++++--- lib/eal/linux/eal.c | 5 +-- lib/eal/linux/eal_memory.c | 12 ++++---- lib/eal/windows/eal.c | 5 +-- lib/eal/windows/eal_memory.c | 3 +- 10 files changed, 74 insertions(+), 43 deletions(-)
lib/eal/common/eal_common_dynmem.c +6 -5
@@ -358,7 +358,8 @@ eal_dynmem_calc_num_pages_per_socket(uint64_t remaining_mem, cur_mem;const struct internal_config *internal_conf =eal_get_internal_configuration (); -uint64_t total_mem = internal_conf->memory; +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +uint64_t total_mem = user_cfg->memory;if (num_hp_info ==0 )return -1 ;
@@ -382,12 +383,12 @@ eal_dynmem_calc_num_pages_per_socket(* sockets according to number of cores from CPU mask present * on each socket. */ - total_size = internal_conf->memory; + total_size = user_cfg->memory;for (socket =0 ; socket <RTE_MAX_NUMA_NODES && total_size !=0 ; socket++) {/* Set memory amount per socket */ - default_size = internal_conf->memory * + default_size = user_cfg->memory * cpu_per_socket[socket] /rte_lcore_count ();/* Limit to maximum available memory on socket */
@@ -418,7 +419,7 @@ eal_dynmem_calc_num_pages_per_socket(/* in 32-bit mode, allocate all of the memory only on main * lcore socket */ - total_size = internal_conf->memory; + total_size = user_cfg->memory;for (socket =0 ; socket <RTE_MAX_NUMA_NODES && total_size !=0 ; socket++) {struct rte_config *cfg =rte_eal_get_configuration ();
@@ -502,7 +503,7 @@ eal_dynmem_calc_num_pages_per_socket(/* if we didn't satisfy total memory requirements */ if (total_mem >0 ) { - requested = internal_conf->memory /0x100000 ; + requested = user_cfg->memory /0x100000 ; available = requested - (total_mem /0x100000 );EAL_LOG (ERR ,"Not enough memory available! Requested: %uMB, available: %uMB" , requested, available);
lib/eal/common/eal_common_memory.c +4 -4
@@ -681,15 +681,15 @@ static intrte_eal_memdevice_init (void) {struct rte_config *config; -const struct internal_config *internal_conf; +const struct eal_user_cfg *user_cfg;if (rte_eal_process_type () ==RTE_PROC_SECONDARY )return 0 ; - internal_conf =eal_get_internal_configuration (); + user_cfg =eal_get_user_configuration (); config =rte_eal_get_configuration (); - config->mem_config->nchannel = internal_conf->force_nchannel; - config->mem_config->nrank = internal_conf->force_nrank; + config->mem_config->nchannel = user_cfg->force_nchannel; + config->mem_config->nrank = user_cfg->force_nrank;return 0 ; }
lib/eal/common/eal_common_options.c +36 -11
89 lines not on this page · raw message
lib/eal/common/eal_internal_cfg.h +4 -4
@@ -13,6 +13,7 @@#include <rte_eal.h> #include <rte_os_shim.h> #include <rte_pci_dev_feature_defs.h> +#include <stdint.h> #include "eal_thread.h"
@@ -53,7 +54,9 @@ struct hugepage_file_discipline {* Immutable after initialization, so no need for atomic types or locks. */ struct eal_user_cfg { -uint8_t reserved; +size_t memory;/**< amount of asked memory */ +uint8_t force_nchannel;/**< force number of channels */ +uint8_t force_nrank;/**< force number of ranks */ };/**
@@ -77,9 +80,6 @@ struct eal_runtime_state {* internal configuration */ struct internal_config { -volatile size_t memory;/**< amount of asked memory */ -volatile unsigned force_nchannel;/**< force number of channels */ -volatile unsigned force_nrank;/**< force number of ranks */ volatile unsigned no_hugetlbfs;/**< true to disable hugetlbfs */ struct hugepage_file_discipline hugepage_file;volatile unsigned no_pci;/**< true to disable PCI */
lib/eal/freebsd/eal.c +4 -3
@@ -415,6 +415,7 @@ rte_eal_init(int argc, char **argv)const struct rte_config *config =rte_eal_get_configuration ();struct internal_config *internal_conf =eal_get_internal_configuration (); +struct eal_user_cfg *user_cfg =eal_get_user_configuration ();bool has_phys_addr;enum rte_iova_mode iova_mode;
@@ -593,11 +594,11 @@ rte_eal_init(int argc, char **argv) } } -if (internal_conf->memory ==0 && internal_conf->force_numa ==0 ) { +if (user_cfg->memory ==0 && internal_conf->force_numa ==0 ) {if (internal_conf->no_hugetlbfs) - internal_conf->memory =MEMSIZE_IF_NO_HUGE_PAGE ; + user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ;else - internal_conf->memory =eal_get_hugepage_mem_size (); + user_cfg->memory =eal_get_hugepage_mem_size (); }if (internal_conf->vmware_tsc_map ==1 ) {
lib/eal/freebsd/eal_memory.c +6 -5
@@ -82,11 +82,12 @@ rte_eal_hugepage_init(void)struct rte_memseg_list *msl;uint64_t mem_sz, page_sz;int n_segs; +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* create a memseg list */ msl = &mcfg->memsegs[0 ]; - mem_sz = internal_conf->memory; + mem_sz = user_cfg->memory; page_sz =RTE_PGSIZE_4K ; n_segs = mem_sz / page_sz;
@@ -121,7 +122,7 @@ rte_eal_hugepage_init(void) hpi = &internal_conf->hugepage_info[i]; page_sz = hpi->hugepage_sz; max_pages = hpi->num_pages[0 ]; - mem_needed =RTE_ALIGN_CEIL (internal_conf->memory - total_mem, + mem_needed =RTE_ALIGN_CEIL (eal_get_user_configuration ()->memory - total_mem, page_sz); n_pages =RTE_MIN (mem_needed / page_sz, max_pages);
@@ -244,14 +245,14 @@ rte_eal_hugepage_init(void) total_mem += seg->len; } -if (total_mem >= internal_conf->memory) +if (total_mem >=eal_get_user_configuration ()->memory)break ; } -if (total_mem < internal_conf->memory) { +if (total_mem <eal_get_user_configuration ()->memory) {EAL_LOG (ERR ,"Couldn't reserve requested memory, " "requested: %" PRIu64"M " "available: %" PRIu64"M" , - internal_conf->memory >>20 , total_mem >>20 ); +eal_get_user_configuration ()->memory >>20 , total_mem >>20 );return -1 ; }return 0 ;
lib/eal/linux/eal.c +3 -2
@@ -577,6 +577,7 @@ rte_eal_init(int argc, char **argv)const struct rte_config *config =rte_eal_get_configuration ();struct internal_config *internal_conf =eal_get_internal_configuration (); +struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* first check if we have been run before */ if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
@@ -756,9 +757,9 @@ rte_eal_init(int argc, char **argv) } } -if (internal_conf->memory ==0 && internal_conf->force_numa ==0 ) { +if (user_cfg->memory ==0 && internal_conf->force_numa ==0 ) {if (internal_conf->no_hugetlbfs) - internal_conf->memory =MEMSIZE_IF_NO_HUGE_PAGE ; + user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ; }if (internal_conf->vmware_tsc_map ==1 ) {
lib/eal/linux/eal_memory.c +6 -6
@@ -1165,7 +1165,7 @@ eal_legacy_hugepage_init(void)/* create a memseg list */ msl = &mcfg->memsegs[0 ]; - mem_sz = internal_conf->memory; + mem_sz =eal_get_user_configuration ()->memory; page_sz =RTE_PGSIZE_4K ; n_segs = mem_sz / page_sz;
@@ -1186,7 +1186,7 @@ eal_legacy_hugepage_init(void)EAL_LOG (DEBUG ,"Falling back to anonymous map" ); }else {/* we got an fd - now resize it */ -if (ftruncate (memfd, internal_conf->memory) <0 ) { +if (ftruncate (memfd,eal_get_user_configuration ()->memory) <0 ) {EAL_LOG (ERR ,"Cannot resize memfd: %s" ,strerror (errno));EAL_LOG (ERR ,"Falling back to anonymous map" );
@@ -1342,8 +1342,8 @@ eal_legacy_hugepage_init(void)huge_recover_sigbus (); -if (internal_conf->memory ==0 && internal_conf->force_numa ==0 ) - internal_conf->memory =eal_get_hugepage_mem_size (); +if (eal_get_user_configuration ()->memory ==0 && internal_conf->force_numa ==0 ) +eal_get_user_configuration ()->memory =eal_get_hugepage_mem_size (); nr_hugefiles = nr_hugepages;
@@ -1742,7 +1742,7 @@ memseg_primary_init_32(void) total_requested_mem += mem; }else - total_requested_mem = internal_conf->memory; + total_requested_mem =eal_get_user_configuration ()->memory;if (total_requested_mem > mem32_max_mem) { EAL_LOG(ERR, "Invalid parameters: 32-bit process can at most use %uM of memory",
@@ -1806,7 +1806,7 @@ memseg_primary_init_32(void)/* max amount of memory on this socket */ max_socket_mem = (active_sockets !=0 ? internal_conf->numa_mem[socket_id] : - internal_conf->memory) + +eal_get_user_configuration ()->memory) + extra_mem_per_socket; cur_socket_mem =0 ;
lib/eal/windows/eal.c +3 -2
@@ -161,6 +161,7 @@ rte_eal_init(int argc, char **argv)const struct rte_config *config =rte_eal_get_configuration ();struct internal_config *internal_conf =eal_get_internal_configuration (); +struct eal_user_cfg *user_cfg =eal_get_user_configuration ();bool has_phys_addr;enum rte_iova_mode iova_mode;int ret;
@@ -236,9 +237,9 @@ rte_eal_init(int argc, char **argv) goto err_out; } -if (internal_conf->memory ==0 && !internal_conf->force_numa) { +if (user_cfg->memory ==0 && !internal_conf->force_numa) {if (internal_conf->no_hugetlbfs) - internal_conf->memory =MEMSIZE_IF_NO_HUGE_PAGE ; + user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ; }if (rte_eal_intr_init () <0 ) {
lib/eal/windows/eal_memory.c +2 -1
@@ -680,13 +680,14 @@ eal_nohuge_init(void) mcfg =rte_eal_get_configuration ()->mem_config;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* nohuge mode is legacy mode */ internal_conf->legacy_mem =1 ; msl = &mcfg->memsegs[0 ]; - mem_sz = internal_conf->memory; + mem_sz = user_cfg->memory; page_sz =RTE_PGSIZE_4K ; n_segs = mem_sz / page_sz;
Signature · 1 line
2.53.0
PATCH v2 5/39 eal: move NUMA request fields to user config
In reply to Bruce RichardsonAs with basic memory user parameters, move the NUMA-specific parameters to the user config struct. Update flag types to bool in the process.
--- lib/eal/common/eal_common_dynmem.c | 15 +++++++-------- lib/eal/common/eal_common_options.c | 24 +++++++++++------------- lib/eal/common/eal_internal_cfg.h | 11 ++++------- lib/eal/common/malloc_heap.c | 2 +- lib/eal/freebsd/eal.c | 2 +- lib/eal/linux/eal.c | 2 +- lib/eal/linux/eal_memory.c | 23 ++++++++++++----------- lib/eal/windows/eal.c | 2 +- 8 files changed, 38 insertions(+), 43 deletions(-)
lib/eal/common/eal_common_dynmem.c +7 -8
@@ -212,6 +212,7 @@ eal_dynmem_hugepage_init(void)int hp_sz_idx, socket_id;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();memset (used_hp,0 ,sizeof (used_hp));
@@ -248,7 +249,7 @@ eal_dynmem_hugepage_init(void)/* make a copy of numa_mem, needed for balanced allocation. */ for (hp_sz_idx =0 ; hp_sz_idx <RTE_MAX_NUMA_NODES ; hp_sz_idx++) - memory[hp_sz_idx] = internal_conf->numa_mem[hp_sz_idx]; + memory[hp_sz_idx] = user_cfg->numa_mem[hp_sz_idx];/* calculate final number of pages */ if (eal_dynmem_calc_num_pages_per_socket(memory,
@@ -316,10 +317,10 @@ eal_dynmem_hugepage_init(void) }/* if socket limits were specified, set them */ -if (internal_conf->force_numa_limits) { +if (user_cfg->force_numa_limits) {unsigned int i;for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) { -uint64_t limit = internal_conf->numa_limit[i]; +uint64_t limit = user_cfg->numa_limit[i];if (limit ==0 )continue ; if (rte_mem_alloc_validator_register("socket-limit",
@@ -356,8 +357,6 @@ eal_dynmem_calc_num_pages_per_socket(unsigned int requested, available;int total_num_pages =0 ;uint64_t remaining_mem, cur_mem; -const struct internal_config *internal_conf = -eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();uint64_t total_mem = user_cfg->memory;
@@ -365,7 +364,7 @@ eal_dynmem_calc_num_pages_per_socket(return -1 ;/* if specific memory amounts per socket weren't requested */ -if (internal_conf->force_numa ==0 ) { +if (!user_cfg->force_numa) {size_t total_size;#ifdef RTE_ARCH_64 int cpu_per_socket[RTE_MAX_NUMA_NODES ];
@@ -492,8 +491,8 @@ eal_dynmem_calc_num_pages_per_socket(/* if we didn't satisfy all memory requirements per socket */ if (memory[socket] >0 && - internal_conf->numa_mem[socket] !=0 ) { - requested = internal_conf->numa_mem[socket] /0x100000 ; + user_cfg->numa_mem[socket] !=0 ) { + requested = user_cfg->numa_mem[socket] /0x100000 ; available = requested - (memory[socket] /0x100000 );EAL_LOG (ERR ,"Not enough memory available on socket %u! Requested: %uMB, available: %uMB" , socket, requested, available);
lib/eal/common/eal_common_options.c +11 -13
@@ -515,18 +515,16 @@ eal_reset_internal_config(struct internal_config *internal_cfg) user_cfg->memory =0 ; user_cfg->force_nrank =0 ; user_cfg->force_nchannel =0 ; + user_cfg->force_numa = false; +for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) + user_cfg->numa_mem[i] =0 ; + user_cfg->force_numa_limits = false; +for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) + user_cfg->numa_limit[i] =0 ; internal_cfg->hugefile_prefix =NULL ; internal_cfg->hugepage_dir =NULL ; internal_cfg->hugepage_file.unlink_before_mapping = false; internal_cfg->hugepage_file.unlink_existing = true; - internal_cfg->force_numa =0 ; -/* zero out the NUMA config */ -for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) - internal_cfg->numa_mem[i] =0 ; - internal_cfg->force_numa_limits =0 ; -/* zero out the NUMA limits config */ -for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) - internal_cfg->numa_limit[i] =0 ;/* zero out hugedir descriptors */ for (i =0 ; i <MAX_HUGEPAGE_SIZES ; i++) { memset(&internal_cfg->hugepage_info[i], 0,
@@ -2307,18 +2305,18 @@ eal_parse_args(void) } }if (args.numa_mem !=NULL ) { -if (eal_parse_socket_arg (args.numa_mem, int_cfg->numa_mem) <0 ) { +if (eal_parse_socket_arg (args.numa_mem, user_cfg->numa_mem) <0 ) {EAL_LOG (ERR ,"invalid numa-mem parameter: '%s'" , args.numa_mem);return -1 ; } - int_cfg->force_numa =1 ; + user_cfg->force_numa = true; }if (args.numa_limit !=NULL ) { -if (eal_parse_socket_arg (args.numa_limit, int_cfg->numa_limit) <0 ) { +if (eal_parse_socket_arg (args.numa_limit, user_cfg->numa_limit) <0 ) {EAL_LOG (ERR ,"invalid numa-limit parameter: '%s'" , args.numa_limit);return -1 ; } - int_cfg->force_numa_limits =1 ; + user_cfg->force_numa_limits = true; } TAILQ_FOREACH(arg, &args.pagesz_mem, next) {if (eal_parse_pagesz_mem (arg->arg, int_cfg) <0 ) {
@@ -2510,7 +2508,7 @@ eal_adjust_config(struct internal_config *internal_cfg)/* 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 += internal_cfg->numa_mem[i]; + user_cfg->memory += user_cfg->numa_mem[i];return 0 ; }
lib/eal/common/eal_internal_cfg.h +4 -7
@@ -57,6 +57,10 @@ struct eal_user_cfg {size_t memory;/**< amount of asked memory */ uint8_t force_nchannel;/**< force number of channels */ uint8_t force_nrank;/**< force number of ranks */ +bool force_numa;/**< true to request memory on specific NUMA nodes */ +bool force_numa_limits;/**< true to apply per-NUMA memory limits */ +uint64_t numa_mem[RTE_MAX_NUMA_NODES ];/**< amount of memory per NUMA node */ +uint64_t numa_limit[RTE_MAX_NUMA_NODES ];/**< limit amount of memory per NUMA node */ };/**
@@ -93,13 +97,6 @@ struct internal_config {*/ volatile unsigned create_uio_dev;/**< true to create /dev/uioX devices */ volatile enum rte_proc_type_t process_type;/**< multi-process proc type */ -/** true to try allocating memory on specific NUMA nodes */ -volatile unsigned force_numa; -/** amount of memory per NUMA node */ -volatile uint64_t numa_mem[RTE_MAX_NUMA_NODES ]; -volatile unsigned force_numa_limits; -/** limit amount of memory per NUMA node */ -volatile uint64_t numa_limit[RTE_MAX_NUMA_NODES ];uintptr_t base_virtaddr;/**< base address to try and reserve memory from */ volatile unsigned legacy_mem;/**< true to enable legacy memory behavior (no dynamic allocation,
lib/eal/common/malloc_heap.c +1 -1
@@ -701,7 +701,7 @@ malloc_heap_alloc_on_heap_id(size_t size, unsigned int heap_id, unsigned int flastatic unsigned int malloc_get_numa_socket (void ) { -const struct internal_config *conf =eal_get_internal_configuration (); +const struct eal_user_cfg *conf =eal_get_user_configuration ();unsigned int socket_id =rte_socket_id ();unsigned int idx;
lib/eal/freebsd/eal.c +1 -1
@@ -594,7 +594,7 @@ rte_eal_init(int argc, char **argv) } } -if (user_cfg->memory ==0 && internal_conf->force_numa ==0 ) { +if (user_cfg->memory ==0 && !user_cfg->force_numa) {if (internal_conf->no_hugetlbfs) user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ;else
lib/eal/linux/eal.c +1 -1
@@ -757,7 +757,7 @@ rte_eal_init(int argc, char **argv) } } -if (user_cfg->memory ==0 && internal_conf->force_numa ==0 ) { +if (user_cfg->memory ==0 && !user_cfg->force_numa) {if (internal_conf->no_hugetlbfs) user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ; }
lib/eal/linux/eal_memory.c +12 -11
@@ -274,8 +274,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,struct bitmask *oldmask =NULL ;bool have_numa = true;unsigned long maxnode =0 ; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* Check if kernel supports NUMA. */ if (numa_available () !=0 ) {
@@ -294,7 +293,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi, oldpolicy = MPOL_DEFAULT; }for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) -if (internal_conf->numa_mem[i]) +if (user_cfg->numa_mem[i]) maxnode = i +1 ; }#endif
@@ -313,7 +312,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,if (j == maxnode) { node_id = (node_id +1 ) % maxnode; -while (!internal_conf->numa_mem[node_id]) { +while (!user_cfg->numa_mem[node_id]) { node_id++; node_id %= maxnode; }
@@ -1134,6 +1133,7 @@ eal_legacy_hugepage_init(void)struct hugepage_info used_hp[MAX_HUGEPAGE_SIZES ];struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();uint64_t memory[RTE_MAX_NUMA_NODES ];
@@ -1274,7 +1274,7 @@ eal_legacy_hugepage_init(void)/* make a copy of numa_mem, needed for balanced allocation. */ for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) - memory[i] = internal_conf->numa_mem[i]; + memory[i] = user_cfg->numa_mem[i];/* map all hugepages and sort them */ for (i =0 ; i < (int )internal_conf->num_hugepage_sizes; i++) {
@@ -1342,7 +1342,7 @@ eal_legacy_hugepage_init(void)huge_recover_sigbus (); -if (eal_get_user_configuration ()->memory ==0 && internal_conf->force_numa ==0 ) +if (eal_get_user_configuration ()->memory ==0 && !user_cfg->force_numa)eal_get_user_configuration ()->memory =eal_get_hugepage_mem_size (); nr_hugefiles = nr_hugepages;
@@ -1370,7 +1370,7 @@ eal_legacy_hugepage_init(void)/* make a copy of numa_mem, needed for number of pages calculation */ for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) - memory[i] = internal_conf->numa_mem[i]; + memory[i] = user_cfg->numa_mem[i];/* calculate final number of pages */ nr_hugepages = eal_dynmem_calc_num_pages_per_socket(memory,
@@ -1704,6 +1704,7 @@ memseg_primary_init_32(void)uint64_t extra_mem_per_socket, total_extra_mem, total_requested_mem;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* no-huge does not need this at all */ if (internal_conf->no_hugetlbfs)
@@ -1728,12 +1729,12 @@ memseg_primary_init_32(void)*/ active_sockets =0 ; total_requested_mem =0 ; -if (internal_conf->force_numa) +if (user_cfg->force_numa)for (i =0 ; i <rte_socket_count (); i++) {uint64_t mem; socket_id =rte_socket_id_by_idx (i); - mem = internal_conf->numa_mem[socket_id]; + mem = user_cfg->numa_mem[socket_id];if (mem ==0 )continue ;
@@ -1790,7 +1791,7 @@ memseg_primary_init_32(void)/* if we didn't specifically request memory on this socket */ skip = active_sockets !=0 && - internal_conf->numa_mem[socket_id] ==0 ; + user_cfg->numa_mem[socket_id] ==0 ;/* ...or if we didn't specifically request memory on *any* * socket, and this is not main lcore */
@@ -1805,7 +1806,7 @@ memseg_primary_init_32(void)/* max amount of memory on this socket */ max_socket_mem = (active_sockets !=0 ? - internal_conf->numa_mem[socket_id] : + user_cfg->numa_mem[socket_id] :eal_get_user_configuration ()->memory) + extra_mem_per_socket; cur_socket_mem =0 ;
lib/eal/windows/eal.c +1 -1
@@ -237,7 +237,7 @@ rte_eal_init(int argc, char **argv) goto err_out; } -if (user_cfg->memory ==0 && !internal_conf->force_numa) { +if (user_cfg->memory ==0 && !user_cfg->force_numa) {if (internal_conf->no_hugetlbfs) user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ; }
Signature · 1 line
2.53.0
PATCH v2 6/39 eal: move hugepage policy fields to user config
In reply to Bruce RichardsonContinue moving fields from the internal config to the user config, in this case the hugepage policy fields. As with previous fields, any flags are adjusted from unsigned to boolean.
--- lib/eal/common/eal_common_config.c | 2 +- lib/eal/common/eal_common_dynmem.c | 3 ++- lib/eal/common/eal_common_options.c | 39 +++++++++++++++-------------- lib/eal/common/eal_internal_cfg.h | 9 ++++--- lib/eal/freebsd/eal.c | 6 ++--- lib/eal/freebsd/eal_memory.c | 9 ++++--- lib/eal/linux/eal.c | 7 +++--- lib/eal/linux/eal_hugepage_info.c | 12 ++++----- lib/eal/linux/eal_memalloc.c | 25 ++++++++++-------- lib/eal/linux/eal_memory.c | 6 ++--- lib/eal/windows/eal.c | 6 ++--- lib/eal/windows/eal_memory.c | 5 ++-- 12 files changed, 68 insertions(+), 61 deletions(-)
lib/eal/common/eal_common_config.c +1 -1
@@ -131,7 +131,7 @@ RTE_EXPORT_SYMBOL(rte_eal_has_hugepages)int rte_eal_has_hugepages (void ) { -return !internal_config.no_hugetlbfs; +return !eal_user_cfg.no_hugetlbfs; }RTE_EXPORT_SYMBOL (rte_eal_has_pci)
lib/eal/common/eal_common_dynmem.c +2 -1
@@ -36,9 +36,10 @@ eal_dynmem_memseg_lists_init(void)void *mem_va_addr =NULL ;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* no-huge does not need this at all */ -if (internal_conf->no_hugetlbfs) +if (user_cfg->no_hugetlbfs)return 0 ;/*
lib/eal/common/eal_common_options.c +20 -19
@@ -3,6 +3,7 @@* Copyright(c) 2014 6WIND S.A. */ +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <pthread.h>
@@ -498,11 +499,10 @@ eal_option_device_parse(void)const char *eal_get_hugefile_prefix (void ) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -if (internal_conf->hugefile_prefix !=NULL ) -return internal_conf->hugefile_prefix; +if (user_cfg->hugefile_prefix !=NULL ) +return user_cfg->hugefile_prefix;return HUGEFILE_PREFIX_DEFAULT ; }
@@ -521,10 +521,11 @@ eal_reset_internal_config(struct internal_config *internal_cfg) user_cfg->force_numa_limits = false;for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) user_cfg->numa_limit[i] =0 ; - internal_cfg->hugefile_prefix =NULL ; - internal_cfg->hugepage_dir =NULL ; - internal_cfg->hugepage_file.unlink_before_mapping = false; - internal_cfg->hugepage_file.unlink_existing = true; + user_cfg->no_hugetlbfs = false; + user_cfg->hugefile_prefix =NULL ; + user_cfg->hugepage_dir =NULL ; + user_cfg->hugepage_file.unlink_before_mapping = false; + user_cfg->hugepage_file.unlink_existing = true;/* zero out hugedir descriptors */ for (i =0 ; i <MAX_HUGEPAGE_SIZES ; i++) { memset(&internal_cfg->hugepage_info[i], 0,
@@ -2251,7 +2252,7 @@ eal_parse_args(void) user_cfg->force_nrank = (uint8_t )nrank; }if (args.no_huge) { - int_cfg->no_hugetlbfs =1 ; + user_cfg->no_hugetlbfs = true;/* no-huge is legacy mem */ int_cfg->legacy_mem =1 ; }
@@ -2259,7 +2260,7 @@ eal_parse_args(void) int_cfg->in_memory =1 ;/* in-memory is a superset of noshconf and huge-unlink */ int_cfg->no_shconf =1 ; - int_cfg->hugepage_file.unlink_before_mapping = true; + user_cfg->hugepage_file.unlink_before_mapping = true; }if (args.legacy_mem) { int_cfg->legacy_mem =1 ;
@@ -2273,9 +2274,9 @@ eal_parse_args(void)EAL_LOG (ERR ,"Invalid hugepage dir parameter" );return -1 ; } -free (int_cfg->hugepage_dir);/* free old hugepage dir */ - int_cfg->hugepage_dir =strdup (args.huge_dir); -if (int_cfg->hugepage_dir ==NULL ) { +free (user_cfg->hugepage_dir);/* free old hugepage dir */ + user_cfg->hugepage_dir =strdup (args.huge_dir); +if (user_cfg->hugepage_dir ==NULL ) {EAL_LOG (ERR ,"failed to allocate memory for hugepage dir parameter" );return -1 ; }
@@ -2289,9 +2290,9 @@ eal_parse_args(void)EAL_LOG (ERR ,"Invalid char, '%%', in file_prefix parameter" );return -1 ; } -free (int_cfg->hugefile_prefix);/* free old file prefix */ - int_cfg->hugefile_prefix =strdup (args.file_prefix); -if (int_cfg->hugefile_prefix ==NULL ) { +free (user_cfg->hugefile_prefix);/* free old file prefix */ + user_cfg->hugefile_prefix =strdup (args.file_prefix); +if (user_cfg->hugefile_prefix ==NULL ) {EAL_LOG (ERR ,"failed to allocate memory for file prefix parameter" );return -1 ; }
@@ -2299,7 +2300,7 @@ eal_parse_args(void)if (args.huge_unlink !=NULL ) {if (args.huge_unlink == (void *)1 ) args.huge_unlink =NULL ; -if (eal_parse_huge_unlink (args.huge_unlink, &int_cfg->hugepage_file) <0 ) { +if (eal_parse_huge_unlink (args.huge_unlink, &user_cfg->hugepage_file) <0 ) {EAL_LOG (ERR ,"invalid huge-unlink parameter" );return -1 ; }
@@ -2487,8 +2488,8 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)int eal_cleanup_config (struct internal_config *internal_cfg) { -free (internal_cfg->hugefile_prefix); -free (internal_cfg->hugepage_dir); +free (eal_get_user_configuration ()->hugefile_prefix); +free (eal_get_user_configuration ()->hugepage_dir);free (internal_cfg->user_mbuf_pool_ops_name);return 0 ;
lib/eal/common/eal_internal_cfg.h +5 -4
@@ -14,6 +14,7 @@#include <rte_os_shim.h> #include <rte_pci_dev_feature_defs.h> #include <stdint.h> +#include <stdbool.h> #include "eal_thread.h"
@@ -59,6 +60,10 @@ struct eal_user_cfg {uint8_t force_nrank;/**< force number of ranks */ bool force_numa;/**< true to request memory on specific NUMA nodes */ bool force_numa_limits;/**< true to apply per-NUMA memory limits */ +bool no_hugetlbfs;/**< true to disable hugetlbfs */ +struct hugepage_file_discipline hugepage_file; +char *hugefile_prefix;/**< the base filename of hugetlbfs files */ +char *hugepage_dir;/**< specific hugetlbfs directory to use */ uint64_t numa_mem[RTE_MAX_NUMA_NODES ];/**< amount of memory per NUMA node */ uint64_t numa_limit[RTE_MAX_NUMA_NODES ];/**< limit amount of memory per NUMA node */ };
@@ -84,8 +89,6 @@ struct eal_runtime_state {* internal configuration */ struct internal_config { -volatile unsigned no_hugetlbfs;/**< true to disable hugetlbfs */ -struct hugepage_file_discipline hugepage_file;volatile unsigned no_pci;/**< true to disable PCI */ volatile unsigned no_hpet;/**< true to disable HPET */ volatile unsigned vmware_tsc_map;/**< true to use VMware TSC mapping
@@ -112,8 +115,6 @@ struct internal_config {volatile enum rte_intr_mode vfio_intr_mode;/** the shared VF token for VFIO-PCI bound PF and VFs devices */ rte_uuid_t vfio_vf_token; -char *hugefile_prefix;/**< the base filename of hugetlbfs files */ -char *hugepage_dir;/**< specific hugetlbfs directory to use */ char *user_mbuf_pool_ops_name;/**< user defined mbuf pool ops name */ unsigned num_hugepage_sizes;/**< how many sizes on this system */
lib/eal/freebsd/eal.c +3 -3
@@ -536,7 +536,7 @@ rte_eal_init(int argc, char **argv)* If contigmem is inaccessible, rte_eal_hugepage_init() will fail * with a message describing the cause. */ - has_phys_addr = internal_conf->no_hugetlbfs ==0 ; + has_phys_addr = !user_cfg->no_hugetlbfs;/* Always call rte_bus_get_iommu_class() to trigger DMA mask detection and validation */ enum rte_iova_mode bus_iova_mode =rte_bus_get_iommu_class ();
@@ -576,7 +576,7 @@ rte_eal_init(int argc, char **argv)EAL_LOG (INFO ,"Selected IOVA mode '%s'" ,rte_eal_iova_mode () ==RTE_IOVA_PA ?"PA" :"VA" ); -if (internal_conf->no_hugetlbfs ==0 ) { +if (!user_cfg->no_hugetlbfs) {/* rte_config isn't initialized yet */ ret = internal_conf->process_type ==RTE_PROC_PRIMARY ? eal_hugepage_info_init() :
@@ -595,7 +595,7 @@ rte_eal_init(int argc, char **argv) }if (user_cfg->memory ==0 && !user_cfg->force_numa) { -if (internal_conf->no_hugetlbfs) +if (user_cfg->no_hugetlbfs) user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ;else user_cfg->memory =eal_get_hugepage_mem_size ();
lib/eal/freebsd/eal_memory.c +5 -4
@@ -73,16 +73,16 @@ rte_eal_hugepage_init(void)unsigned int i, j, seg_idx =0 ;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* get pointer to global configuration */ mcfg =rte_eal_get_configuration ()->mem_config;/* for debug purposes, hugetlbfs can be disabled */ -if (internal_conf->no_hugetlbfs) { +if (user_cfg->no_hugetlbfs) {struct rte_memseg_list *msl;uint64_t mem_sz, page_sz;int n_segs; -const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* create a memseg list */ msl = &mcfg->memsegs[0 ];
@@ -122,7 +122,7 @@ rte_eal_hugepage_init(void) hpi = &internal_conf->hugepage_info[i]; page_sz = hpi->hugepage_sz; max_pages = hpi->num_pages[0 ]; - mem_needed =RTE_ALIGN_CEIL (eal_get_user_configuration ()->memory - total_mem, + mem_needed =RTE_ALIGN_CEIL (user_cfg->memory - total_mem, page_sz); n_pages =RTE_MIN (mem_needed / page_sz, max_pages);
@@ -355,9 +355,10 @@ memseg_primary_init(void)struct rte_memseg_list *msl;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* no-huge does not need this at all */ -if (internal_conf->no_hugetlbfs) +if (user_cfg->no_hugetlbfs)return 0 ;/* FreeBSD has an issue where core dump will dump the entire memory
lib/eal/linux/eal.c +4 -3
@@ -739,7 +739,7 @@ rte_eal_init(int argc, char **argv)EAL_LOG (INFO ,"Selected IOVA mode '%s'" ,rte_eal_iova_mode () ==RTE_IOVA_PA ?"PA" :"VA" ); -if (internal_conf->no_hugetlbfs ==0 ) { +if (!user_cfg->no_hugetlbfs) {/* rte_config isn't initialized yet */ ret = internal_conf->process_type ==RTE_PROC_PRIMARY ? eal_hugepage_info_init() :
@@ -758,7 +758,7 @@ rte_eal_init(int argc, char **argv) }if (user_cfg->memory ==0 && !user_cfg->force_numa) { -if (internal_conf->no_hugetlbfs) +if (user_cfg->no_hugetlbfs) user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ; }
@@ -980,9 +980,10 @@ rte_eal_cleanup(void)*/ struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (rte_eal_process_type () ==RTE_PROC_PRIMARY && - internal_conf->hugepage_file.unlink_existing) + user_cfg->hugepage_file.unlink_existing)rte_memseg_walk (mark_freeable,NULL );rte_service_finalize ();
lib/eal/linux/eal_hugepage_info.c +6 -6
@@ -215,22 +215,21 @@ get_hugepage_dir(uint64_t hugepage_sz, char *hugedir, int len)static uint64_t default_size =0 ;const char pagesize_opt[] ="pagesize=" ;const size_t pagesize_opt_len =sizeof (pagesize_opt) -1 ; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct mntent *mnt;FILE *fp;/* Fast path: hugepage_dir explicitly specified */ -if (internal_conf->hugepage_dir !=NULL ) { +if (user_cfg->hugepage_dir !=NULL ) {struct statfs sfs;/* Query info about mounted filesystem */ -if (statfs (internal_conf->hugepage_dir, &sfs) !=0 || +if (statfs (user_cfg->hugepage_dir, &sfs) !=0 || (uint32_t )sfs.f_type !=HUGETLBFS_MAGIC || (uint64_t )sfs.f_bsize != hugepage_sz)return -1 ; -strlcpy (hugedir, internal_conf->hugepage_dir, len); +strlcpy (hugedir, user_cfg->hugepage_dir, len);return 0 ; }
@@ -457,6 +456,7 @@ hugepage_info_init(void)struct dirent *dirent;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); dir =opendir (sys_dir_path);if (dir ==NULL ) {
@@ -527,7 +527,7 @@ hugepage_info_init(void)* or count how many of them can be reused. */ reusable_pages =0 ; -if (!internal_conf->hugepage_file.unlink_existing) { +if (!user_cfg->hugepage_file.unlink_existing) { reusable_bytes =0 ;if (inspect_hugedir (hpi->hugedir, &reusable_bytes) <0 )
lib/eal/linux/eal_memalloc.c +14 -11
@@ -268,6 +268,7 @@ get_seg_fd(char *path, int buflen, struct hugepage_info *hi,int ret;const struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (dirty !=NULL ) *dirty = false;
@@ -306,7 +307,7 @@ get_seg_fd(char *path, int buflen, struct hugepage_info *hi, __func__, path, strerror(errno));return -1 ; } -if (!internal_conf->hugepage_file.unlink_existing && ret ==0 && +if (!user_cfg->hugepage_file.unlink_existing && ret ==0 && dirty !=NULL ) *dirty = true;
@@ -323,7 +324,7 @@ get_seg_fd(char *path, int buflen, struct hugepage_info *hi,* whether they will be dirty depends on the part that is mapped. */ if (!internal_conf->single_file_segments && - internal_conf->hugepage_file.unlink_existing && + user_cfg->hugepage_file.unlink_existing &&rte_eal_process_type () ==RTE_PROC_PRIMARY && ret ==0 ) {/* coverity[toctou] */
@@ -376,8 +377,7 @@ static int resize_hugefile_in_filesystem(int fd, uint64_t fa_offset, uint64_t page_sz, bool grow, bool *dirty) { - const struct internal_config *internal_conf = -eal_get_internal_configuration (); + const struct eal_user_cfg *user_cfg = eal_get_user_configuration();bool again = false; do {
@@ -449,7 +449,7 @@ resize_hugefile_in_filesystem(int fd, uint64_t fa_offset, uint64_t page_sz,* dirty, unless the file is a fresh one. */ if (dirty !=NULL ) - *dirty &= !internal_conf->hugepage_file.unlink_existing; + *dirty &= !user_cfg->hugepage_file.unlink_existing; } } }while (again);
@@ -517,6 +517,7 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,void *new_addr;const struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); alloc_sz = hi->hugepage_sz;
@@ -549,7 +550,7 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,EAL_LOG (DEBUG ,"%s(): ftruncate() failed: %s" , __func__,strerror (errno)); goto resized; } -if (internal_conf->hugepage_file.unlink_before_mapping && +if (user_cfg->hugepage_file.unlink_before_mapping && !internal_conf->in_memory) {if (unlink (path)) { EAL_LOG(DEBUG, "%s(): unlink() failed: %s",
@@ -683,7 +684,7 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,close_hugefile (fd, path, list_idx); }else {/* only remove file if we can take out a write lock */ -if (!internal_conf->hugepage_file.unlink_before_mapping && +if (!user_cfg->hugepage_file.unlink_before_mapping && internal_conf->in_memory ==0 &&lock (fd,LOCK_EX ) ==1 )unlink (path);
@@ -702,6 +703,7 @@ free_seg(struct rte_memseg *ms, struct hugepage_info *hi,int fd, ret =0 ;const struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* erase page data */ memset (ms->addr,0 , ms->len);
@@ -737,8 +739,8 @@ free_seg(struct rte_memseg *ms, struct hugepage_info *hi,* holding onto this page. */ if (!internal_conf->in_memory && - internal_conf->hugepage_file.unlink_existing && - !internal_conf->hugepage_file.unlink_before_mapping) { + user_cfg->hugepage_file.unlink_existing && + !user_cfg->hugepage_file.unlink_before_mapping) { ret =lock (fd,LOCK_EX );if (ret >=0 ) {/* no one else is using this page */
@@ -1658,6 +1660,7 @@ eal_memalloc_init(void) {const struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (rte_eal_process_type () ==RTE_PROC_SECONDARY )/* memory_hotplug_lock is held during initialization, so it's
@@ -1674,8 +1677,8 @@ eal_memalloc_init(void)return -1 ; }/* safety net, should be impossible to configure */ -if (internal_conf->hugepage_file.unlink_before_mapping && - !internal_conf->hugepage_file.unlink_existing) { +if (user_cfg->hugepage_file.unlink_before_mapping && + !user_cfg->hugepage_file.unlink_existing) {EAL_LOG (ERR ,"Unlinking existing hugepage files is prohibited, cannot unlink them before mapping." );return -1 ; }
lib/eal/linux/eal_memory.c +3 -3
@@ -1148,7 +1148,7 @@ eal_legacy_hugepage_init(void) mcfg =rte_eal_get_configuration ()->mem_config;/* hugetlbfs can be disabled */ -if (internal_conf->no_hugetlbfs) { +if (user_cfg->no_hugetlbfs) {void *prealloc_addr;size_t mem_sz;struct rte_memseg_list *msl;
@@ -1445,7 +1445,7 @@ eal_legacy_hugepage_init(void) }/* free the hugepage backing files */ -if (internal_conf->hugepage_file.unlink_before_mapping && +if (user_cfg->hugepage_file.unlink_before_mapping &&unlink_hugepage_files (tmp_hp, internal_conf->num_hugepage_sizes) <0 ) {EAL_LOG (ERR ,"Unlinking hugepage files failed!" ); goto fail;
@@ -1707,7 +1707,7 @@ memseg_primary_init_32(void)const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* no-huge does not need this at all */ -if (internal_conf->no_hugetlbfs) +if (user_cfg->no_hugetlbfs)return 0 ;/* this is a giant hack, but desperate times call for desperate
lib/eal/windows/eal.c +3 -3
@@ -225,12 +225,12 @@ rte_eal_init(int argc, char **argv) internal_conf->no_shconf =1 ; } -if (!internal_conf->no_hugetlbfs && (eal_hugepage_info_init () <0 )) { +if (!user_cfg->no_hugetlbfs && (eal_hugepage_info_init () <0 )) {rte_eal_init_alert ("Cannot get hugepage information" ); rte_errno =EACCES ; goto err_out; } -if (!internal_conf->no_hugetlbfs && +if (!user_cfg->no_hugetlbfs &&eal_apply_hugepage_mem_sz_limits (internal_conf) <0 ) {rte_eal_init_alert ("Cannot apply hugepage memory limits" ); rte_errno =EINVAL ;
@@ -238,7 +238,7 @@ rte_eal_init(int argc, char **argv) }if (user_cfg->memory ==0 && !user_cfg->force_numa) { -if (internal_conf->no_hugetlbfs) +if (user_cfg->no_hugetlbfs) user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ; }
lib/eal/windows/eal_memory.c +2 -3
@@ -723,10 +723,9 @@ eal_nohuge_init(void)int rte_eal_hugepage_init (void ) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -return internal_conf->no_hugetlbfs ? +return user_cfg->no_hugetlbfs ?eal_nohuge_init () :eal_dynmem_hugepage_init (); }
Signature · 1 line
2.53.0
PATCH v2 7/39 eal: move process policy fields to user config
In reply to Bruce RichardsonMove process/runtime policy request fields from internal_config into eal_user_cfg, updating flag types to bool in the process.
--- lib/eal/common/eal_common_config.c | 2 +- lib/eal/common/eal_common_dev.c | 10 +++--- lib/eal/common/eal_common_fbarray.c | 10 +++--- lib/eal/common/eal_common_memory.c | 12 +++----- lib/eal/common/eal_common_options.c | 47 ++++++++++++++++------------- lib/eal/common/eal_common_proc.c | 35 +++++++++------------ lib/eal/common/eal_internal_cfg.h | 20 +++++------- lib/eal/freebsd/eal.c | 42 ++++++++++++-------------- lib/eal/freebsd/eal_hugepage_info.c | 3 +- lib/eal/linux/eal.c | 38 +++++++++++------------ lib/eal/linux/eal_hugepage_info.c | 5 +-- lib/eal/linux/eal_memalloc.c | 37 +++++++++-------------- lib/eal/linux/eal_memory.c | 5 ++- lib/eal/linux/eal_timer_hpet.c | 21 ++++++------- lib/eal/linux/eal_vfio.c | 14 ++++----- lib/eal/windows/eal.c | 6 ++-- 16 files changed, 138 insertions(+), 169 deletions(-)
lib/eal/common/eal_common_config.c +1 -1
@@ -138,5 +138,5 @@ RTE_EXPORT_SYMBOL(rte_eal_has_pci)int rte_eal_has_pci (void ) { -return !internal_config.no_pci; +return !eal_user_cfg.no_pci; }
lib/eal/common/eal_common_dev.c +4 -6
@@ -267,9 +267,8 @@ RTE_EXPORT_SYMBOL(rte_dev_probe)int rte_dev_probe (const char *devargs) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); -bool do_mp = internal_conf->no_shconf ==0 ; +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +bool do_mp = user_cfg->no_shconf ==0 ;struct eal_dev_mp_req req;struct rte_device *dev;int ret;
@@ -426,9 +425,8 @@ RTE_EXPORT_SYMBOL(rte_dev_remove)int rte_dev_remove (struct rte_device *dev) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); -bool do_mp = internal_conf->no_shconf ==0 ; +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +bool do_mp = user_cfg->no_shconf ==0 ;struct eal_dev_mp_req req;char *devargs;int ret;
lib/eal/common/eal_common_fbarray.c +4 -6
@@ -697,8 +697,7 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len,struct mem_area *ma =NULL ;void *data =NULL ;int fd =-1 ; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (arr ==NULL ) { rte_errno =EINVAL ;
@@ -734,7 +733,7 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len, fd =-1 ; -if (internal_conf->no_shconf) { +if (user_cfg->no_shconf) {/* remap virtual area as writable */ static const int flags =RTE_MAP_FORCE_ADDRESS |RTE_MAP_PRIVATE |RTE_MAP_ANONYMOUS ;
@@ -964,8 +963,7 @@ rte_fbarray_destroy(struct rte_fbarray *arr)size_t mmap_len;int fd, ret;char path[PATH_MAX ]; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (arr ==NULL ) { rte_errno =EINVAL ;
@@ -999,7 +997,7 @@ rte_fbarray_destroy(struct rte_fbarray *arr) goto out; }/* with no shconf, there were never any files to begin with */ -if (!internal_conf->no_shconf) { +if (!user_cfg->no_shconf) {/* * attempt to get an exclusive lock on the file, to ensure it * has been detached by all other processes
lib/eal/common/eal_common_memory.c +5 -7
@@ -1073,13 +1073,12 @@ rte_extmem_detach(void *va_addr, size_t len)int rte_eal_memory_detach (void ) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config;size_t page_sz =rte_mem_page_size ();unsigned int i; -if (internal_conf->in_memory ==1 ) +if (user_cfg->in_memory)return 0 ;rte_rwlock_write_lock (&mcfg->memory_hotplug_lock);
@@ -1122,7 +1121,7 @@ rte_eal_memory_detach(void)* config - we can't zero it out because it might still be referenced * by other processes. */ -if (internal_conf->no_shconf ==0 && mcfg->mem_cfg_addr !=0 ) { +if (!user_cfg->no_shconf && mcfg->mem_cfg_addr !=0 ) {if (rte_mem_unmap (mcfg,RTE_ALIGN (sizeof (*mcfg), page_sz)) !=0 )EAL_LOG (ERR ,"Could not unmap shared memory config: %s" ,rte_strerror (rte_errno));
@@ -1136,8 +1135,7 @@ rte_eal_memory_detach(void)int rte_eal_memory_init (void ) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();int retval;EAL_LOG (DEBUG ,"Setting up physically contiguous memory..." );
@@ -1154,7 +1152,7 @@ rte_eal_memory_init(void)if (retval <0 ) goto fail; -if (internal_conf->no_shconf ==0 &&rte_eal_memdevice_init () <0 ) +if (!user_cfg->no_shconf &&rte_eal_memdevice_init () <0 ) goto fail;return 0 ;
lib/eal/common/eal_common_options.c +26 -21
108 lines not on this page · raw message
lib/eal/common/eal_common_proc.c +14 -21
@@ -224,13 +224,12 @@ int rte_mp_action_register(const char *name, rte_mp_t action) {struct action_entry *entry; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (validate_action_name (name) !=0 )return -1 ; -if (internal_conf->no_shconf) { +if (user_cfg->no_shconf) {EAL_LOG (DEBUG ,"No shared files mode enabled, IPC is disabled" ); rte_errno =ENOTSUP ;return -1 ;
@@ -261,13 +260,12 @@ void rte_mp_action_unregister(const char *name) {struct action_entry *entry; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (validate_action_name (name) !=0 )return ; -if (internal_conf->no_shconf) { +if (user_cfg->no_shconf) {EAL_LOG (DEBUG ,"No shared files mode enabled, IPC is disabled" );return ; }
@@ -628,13 +626,12 @@ rte_mp_channel_init(void) {char path[UNIX_PATH_MAX ];int dir_fd; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* in no shared files mode, we do not have secondary processes support, * so no need to initialize IPC. */ -if (internal_conf->no_shconf) { +if (user_cfg->no_shconf) {EAL_LOG (DEBUG ,"No shared files mode enabled, IPC will be disabled" ); rte_errno =ENOTSUP ;return -1 ;
@@ -865,13 +862,12 @@ RTE_EXPORT_SYMBOL(rte_mp_sendmsg)int rte_mp_sendmsg (struct rte_mp_msg *msg) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (check_input (msg) !=0 )return -1 ; -if (internal_conf->no_shconf) { +if (user_cfg->no_shconf) {EAL_LOG (DEBUG ,"No shared files mode enabled, IPC is disabled" ); rte_errno =ENOTSUP ;return -1 ;
@@ -1026,8 +1022,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply,DIR *mp_dir;struct dirent *ent;struct timespec now, end; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();EAL_LOG (DEBUG ,"request: %s" , req->name);
@@ -1038,7 +1033,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply,if (check_input (req) !=0 ) goto end; -if (internal_conf->no_shconf) { +if (user_cfg->no_shconf) {EAL_LOG (DEBUG ,"No shared files mode enabled, IPC is disabled" ); rte_errno =ENOTSUP ;return -1 ;
@@ -1135,15 +1130,14 @@ rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts,struct timespec now;struct timespec *end;bool dummy_used = false; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();EAL_LOG (DEBUG ,"request: %s" , req->name);if (check_input (req) !=0 )return -1 ; -if (internal_conf->no_shconf) { +if (user_cfg->no_shconf) {EAL_LOG (DEBUG ,"No shared files mode enabled, IPC is disabled" ); rte_errno =ENOTSUP ;return -1 ;
@@ -1331,8 +1325,7 @@ int rte_mp_reply(struct rte_mp_msg *msg, const char *peer) { EAL_LOG(DEBUG, "reply: %s", msg->name); -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (check_input (msg) !=0 )return -1 ;
@@ -1343,7 +1336,7 @@ rte_mp_reply(struct rte_mp_msg *msg, const char *peer)return -1 ; } -if (internal_conf->no_shconf) { +if (user_cfg->no_shconf) {EAL_LOG (DEBUG ,"No shared files mode enabled, IPC is disabled" );return 0 ; }
lib/eal/common/eal_internal_cfg.h +8 -12
@@ -56,11 +56,19 @@ struct hugepage_file_discipline {*/ struct eal_user_cfg {size_t memory;/**< amount of asked memory */ +enum rte_proc_type_t process_type;/**< requested process type */ uint8_t force_nchannel;/**< force number of channels */ uint8_t force_nrank;/**< force number of ranks */ bool force_numa;/**< true to request memory on specific NUMA nodes */ bool force_numa_limits;/**< true to apply per-NUMA memory limits */ bool no_hugetlbfs;/**< true to disable hugetlbfs */ +bool no_pci;/**< true to disable PCI */ +bool no_hpet;/**< true to disable HPET */ +bool vmware_tsc_map;/**< true to use VMware TSC mapping */ +bool no_shconf;/**< true if there is no shared config */ +bool in_memory;/**< true to run with no shared runtime files */ +bool create_uio_dev;/**< true to create /dev/uioX devices */ +bool no_telemetry;/**< true to disable telemetry */ struct hugepage_file_discipline hugepage_file;char *hugefile_prefix;/**< the base filename of hugetlbfs files */ char *hugepage_dir;/**< specific hugetlbfs directory to use */
@@ -89,17 +97,6 @@ struct eal_runtime_state {* internal configuration */ struct internal_config { -volatile unsigned no_pci;/**< true to disable PCI */ -volatile unsigned no_hpet;/**< true to disable HPET */ -volatile unsigned vmware_tsc_map;/**< true to use VMware TSC mapping -* instead of native TSC */ -volatile unsigned no_shconf;/**< true if there is no shared config */ -volatile unsigned in_memory; -/**< true if DPDK should operate entirely in-memory and not create any -* shared files or runtime data. -*/ -volatile unsigned create_uio_dev;/**< true to create /dev/uioX devices */ -volatile enum rte_proc_type_t process_type;/**< multi-process proc type */ uintptr_t base_virtaddr;/**< base address to try and reserve memory from */ volatile unsigned legacy_mem;/**< true to enable legacy memory behavior (no dynamic allocation,
@@ -131,7 +128,6 @@ struct internal_config {rte_cpuset_t ctrl_cpuset;/**< cpuset for ctrl threads */ volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */ -unsigned int no_telemetry;/**< true to disable Telemetry */ struct simd_bitwidth max_simd_bitwidth;/**< max simd bitwidth path to use */ size_t huge_worker_stack_size;/**< worker thread stack size */
lib/eal/freebsd/eal.c +19 -23
124 lines not on this page · raw message
lib/eal/freebsd/eal_hugepage_info.c +2 -1
@@ -62,6 +62,7 @@ eal_hugepage_info_init(void)/* re-use the linux "internal config" structure for our memory data */ struct hugepage_info *hpi = &internal_conf->hugepage_info[0 ]; +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct hugepage_info *tmp_hpi;unsigned int i;
@@ -116,7 +117,7 @@ eal_hugepage_info_init(void) hpi->lock_descriptor = fd;/* for no shared files mode, do not create shared memory config */ -if (internal_conf->no_shconf) +if (user_cfg->no_shconf)return 0 ; tmp_hpi = create_shared_memory(eal_hugepage_info_path(),
lib/eal/linux/eal.c +17 -21
@@ -184,10 +184,11 @@ rte_eal_config_create(void)int retval;const struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();const char *pathname =eal_runtime_config_path (); -if (internal_conf->no_shconf) +if (user_cfg->no_shconf)return 0 ;/* map the config before hugepage address so that we don't waste a page */
@@ -265,12 +266,11 @@ rte_eal_config_attach(void) {struct rte_config *config =rte_eal_get_configuration ();struct rte_mem_config *mem_config; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();const char *pathname =eal_runtime_config_path (); -if (internal_conf->no_shconf) +if (user_cfg->no_shconf)return 0 ;if (mem_cfg_fd <0 ){
@@ -305,10 +305,9 @@ rte_eal_config_reattach(void)struct rte_config *config =rte_eal_get_configuration ();struct rte_mem_config *mem_config;void *rte_mem_cfg_addr; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -if (internal_conf->no_shconf) +if (user_cfg->no_shconf)return 0 ;/* save the address primary process has mapped shared config to */
@@ -350,11 +349,10 @@ eal_proc_type_detect(void) {enum rte_proc_type_t ptype =RTE_PROC_PRIMARY ;const char *pathname =eal_runtime_config_path (); -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* if there no shared config, there can be no secondary processes */ -if (!internal_conf->no_shconf) { +if (!user_cfg->no_shconf) {/* if we can open the file but not get a write-lock we are a * secondary process. NOTE: if we get a file handle back, we * keep that open and don't close it to prevent a race condition
@@ -376,10 +374,9 @@ static intrte_config_init (void) {struct rte_config *config =rte_eal_get_configuration (); -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); - config->process_type = internal_conf->process_type; + config->process_type = user_cfg->process_type;switch (config->process_type) {case RTE_PROC_PRIMARY :
@@ -741,7 +738,7 @@ rte_eal_init(int argc, char **argv)if (!user_cfg->no_hugetlbfs) {/* rte_config isn't initialized yet */ - ret = internal_conf->process_type ==RTE_PROC_PRIMARY ? + ret = user_cfg->process_type ==RTE_PROC_PRIMARY ?eal_hugepage_info_init () :eal_hugepage_info_read ();if (ret <0 ) {
@@ -749,7 +746,7 @@ rte_eal_init(int argc, char **argv) rte_errno =EACCES ; goto err_out; } -if (internal_conf->process_type ==RTE_PROC_PRIMARY && +if (user_cfg->process_type ==RTE_PROC_PRIMARY &&eal_apply_hugepage_mem_sz_limits (internal_conf) <0 ) {rte_eal_init_alert ("Cannot apply hugepage memory limits." ); rte_errno =EINVAL ;
@@ -762,7 +759,7 @@ rte_eal_init(int argc, char **argv) user_cfg->memory =MEMSIZE_IF_NO_HUGE_PAGE ; } -if (internal_conf->vmware_tsc_map ==1 ) { +if (user_cfg->vmware_tsc_map) {#ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT rte_cycles_vmware_tsc_map =1 ; EAL_LOG(DEBUG, "Using VMWARE TSC MAP, "
@@ -923,11 +920,11 @@ rte_eal_init(int argc, char **argv)* In no_shconf mode, no runtime directory is created in the first * place, so no cleanup needed. */ -if (!internal_conf->no_shconf &&eal_clean_runtime_dir () <0 ) { +if (!user_cfg->no_shconf &&eal_clean_runtime_dir () <0 ) {rte_eal_init_alert ("Cannot clear runtime directory" ); goto err_out; } -if (rte_eal_process_type () ==RTE_PROC_PRIMARY && !internal_conf->no_telemetry) { +if (rte_eal_process_type () ==RTE_PROC_PRIMARY && !user_cfg->no_telemetry) {if (rte_telemetry_init (rte_eal_get_runtime_dir (),rte_version (), &internal_conf->ctrl_cpuset) !=0 )
@@ -1006,10 +1003,9 @@ rte_eal_cleanup(void)RTE_EXPORT_SYMBOL (rte_eal_create_uio_dev) int rte_eal_create_uio_dev(void) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -return internal_conf->create_uio_dev; +return user_cfg->create_uio_dev; }RTE_EXPORT_SYMBOL (rte_eal_vfio_intr_mode)
lib/eal/linux/eal_hugepage_info.c +3 -2
@@ -500,7 +500,7 @@ hugepage_info_init(void)* init process. */ #ifdef MAP_HUGE_SHIFT -if (internal_conf->in_memory) { +if (user_cfg->in_memory) { EAL_LOG(DEBUG, "In-memory mode enabled, " "hugepages of size %" PRIu64 " bytes " "will be allocated anonymously",
@@ -581,12 +581,13 @@ eal_hugepage_info_init(void)unsigned int i;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (hugepage_info_init () <0 )return -1 ;/* for no shared files mode, we're done */ -if (internal_conf->no_shconf) +if (user_cfg->no_shconf)return 0 ; hpi = &internal_conf->hugepage_info[0 ];
lib/eal/linux/eal_memalloc.c +15 -22
@@ -276,7 +276,7 @@ get_seg_fd(char *path, int buflen, struct hugepage_info *hi,/* for in-memory mode, we only make it here when we're sure we support * memfd, and this is a special case. */ -if (internal_conf->in_memory) +if (user_cfg->in_memory)return get_seg_memfd (hi, list_idx, seg_idx);if (internal_conf->single_file_segments) {
@@ -460,13 +460,12 @@ resize_hugefile_in_filesystem(int fd, uint64_t fa_offset, uint64_t page_sz,static void close_hugefile (int fd,char *path,int list_idx) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* * primary process must unlink the file, but only when not in in-memory * mode (as in that case there is no file to unlink). */ -if (!internal_conf->in_memory && +if (!user_cfg->in_memory &&rte_eal_process_type () ==RTE_PROC_PRIMARY &&unlink (path)) EAL_LOG(ERR, "%s(): unlinking '%s' failed: %s",
@@ -483,10 +482,9 @@ resize_hugefile(int fd, uint64_t fa_offset, uint64_t page_sz, bool grow,/* in-memory mode is a special case, because we can be sure that * fallocate() is supported. */ -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -if (internal_conf->in_memory) { +if (user_cfg->in_memory) {if (dirty !=NULL ) *dirty = false; return resize_hugefile_in_memory(fd, fa_offset,
@@ -522,7 +520,7 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, alloc_sz = hi->hugepage_sz;/* these are checked at init, but code analyzers don't know that */ -if (internal_conf->in_memory && !anonymous_hugepages_supported) { +if (user_cfg->in_memory && !anonymous_hugepages_supported) {EAL_LOG (ERR ,"Anonymous hugepages not supported, in-memory mode cannot allocate memory" );return -1 ; }
@@ -551,7 +549,7 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, goto resized; }if (user_cfg->hugepage_file.unlink_before_mapping && - !internal_conf->in_memory) { + !user_cfg->in_memory) {if (unlink (path)) {EAL_LOG (DEBUG ,"%s(): unlink() failed: %s" , __func__,strerror (errno));
@@ -685,7 +683,7 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, }else {/* only remove file if we can take out a write lock */ if (!user_cfg->hugepage_file.unlink_before_mapping && - internal_conf->in_memory ==0 && + !user_cfg->in_memory &&lock (fd,LOCK_EX ) ==1 )unlink (path);close (fd);
@@ -738,7 +736,7 @@ free_seg(struct rte_memseg *ms, struct hugepage_info *hi,/* if we're able to take out a write lock, we're the last one * holding onto this page. */ -if (!internal_conf->in_memory && +if (!user_cfg->in_memory && user_cfg->hugepage_file.unlink_existing && !user_cfg->hugepage_file.unlink_before_mapping) { ret =lock (fd,LOCK_EX );
@@ -776,8 +774,7 @@ alloc_seg_walk(const struct rte_memseg_list *msl, void *arg)size_t page_sz;int cur_idx, start_idx, j, dir_fd =-1 ;unsigned int msl_idx, need, i; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (msl->page_sz != wa->page_sz)return 0 ;
@@ -827,7 +824,7 @@ alloc_seg_walk(const struct rte_memseg_list *msl, void *arg)* during init, we already hold a write lock, so don't try to take out * another one. */ -if (wa->hi->lock_descriptor ==-1 && !internal_conf->in_memory) { +if (wa->hi->lock_descriptor ==-1 && !user_cfg->in_memory) { dir_fd =open (wa->hi->hugedir,O_RDONLY );if (dir_fd <0 ) { EAL_LOG(ERR, "%s(): Cannot open '%s': %s",
@@ -910,8 +907,7 @@ free_seg_walk(const struct rte_memseg_list *msl, void *arg)struct free_walk_param *wa = arg;uintptr_t start_addr, end_addr;int msl_idx, seg_idx, ret, dir_fd =-1 ; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); start_addr = (uintptr_t ) msl->base_va; end_addr = start_addr + msl->len;
@@ -934,7 +930,7 @@ free_seg_walk(const struct rte_memseg_list *msl, void *arg)* during init, we already hold a write lock, so don't try to take out * another one. */ -if (wa->hi->lock_descriptor ==-1 && !internal_conf->in_memory) { +if (wa->hi->lock_descriptor ==-1 && !user_cfg->in_memory) { dir_fd =open (wa->hi->hugedir,O_RDONLY );if (dir_fd <0 ) { EAL_LOG(ERR, "%s(): Cannot open '%s': %s",
@@ -1099,8 +1095,7 @@ eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs)int eal_memalloc_free_seg (struct rte_memseg *ms) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct internal_config *internal_conf =eal_get_internal_configuration ();/* dynamic free not supported in legacy mode */ if (internal_conf->legacy_mem)
@@ -1658,8 +1653,6 @@ eal_memalloc_cleanup(void)int eal_memalloc_init (void ) { -const struct internal_config *internal_conf = -eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (rte_eal_process_type () ==RTE_PROC_SECONDARY )
@@ -1669,7 +1662,7 @@ eal_memalloc_init(void)if (rte_memseg_list_walk_thread_unsafe (secondary_msl_create_walk,NULL ) <0 )return -1 ;if (rte_eal_process_type () ==RTE_PROC_PRIMARY && - internal_conf->in_memory) { + user_cfg->in_memory) {EAL_LOG (DEBUG ,"Using memfd for anonymous memory" );/* this cannot ever happen but better safe than sorry */ if (!anonymous_hugepages_supported) {
lib/eal/linux/eal_memory.c +2 -3
@@ -545,11 +545,10 @@ create_shared_memory(const char *filename, const size_t mem_size) {void *retval;int fd; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* if no shared files mode is used, create anonymous memory instead */ -if (internal_conf->no_shconf) { +if (user_cfg->no_shconf) { retval =mmap (NULL , mem_size,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );if (retval ==MAP_FAILED )
lib/eal/linux/eal_timer_hpet.c +9 -12
@@ -88,10 +88,9 @@ RTE_EXPORT_SYMBOL(rte_get_hpet_hz)uint64_t rte_get_hpet_hz (void ) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -if (internal_conf->no_hpet) +if (user_cfg->no_hpet)rte_panic ("Error, HPET called, but no HPET present\n" );return eal_hpet_resolution_hz;
@@ -103,10 +102,9 @@ rte_get_hpet_cycles(void) {uint32_t t, msb;uint64_t ret; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -if (internal_conf->no_hpet) +if (user_cfg->no_hpet)rte_panic ("Error, HPET called, but no HPET present\n" ); t = eal_hpet->counter_l;
@@ -126,10 +124,9 @@ int rte_eal_hpet_init(int make_default) {int fd, ret; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -if (internal_conf->no_hpet) { +if (user_cfg->no_hpet) {EAL_LOG (NOTICE ,"HPET is disabled" );return -1 ; }
@@ -138,14 +135,14 @@ rte_eal_hpet_init(int make_default)if (fd <0 ) {EAL_LOG (ERR ,"ERROR: Cannot open " DEV_HPET ": %s!" ,strerror (errno)); - internal_conf->no_hpet =1 ; + user_cfg->no_hpet = true;return -1 ; } eal_hpet =mmap (NULL ,1024 ,PROT_READ ,MAP_SHARED , fd,0 );if (eal_hpet ==MAP_FAILED ) {EAL_LOG (ERR ,"ERROR: Cannot mmap " DEV_HPET "!" );close (fd); - internal_conf->no_hpet =1 ; + user_cfg->no_hpet = true;return -1 ; }close (fd);
@@ -169,7 +166,7 @@ rte_eal_hpet_init(int make_default) hpet_msb_inc, NULL);if (ret !=0 ) {EAL_LOG (ERR ,"ERROR: Cannot create HPET timer thread!" ); - internal_conf->no_hpet =1 ; + user_cfg->no_hpet = true;return -1 ; }
lib/eal/linux/eal_vfio.c +6 -8
@@ -482,8 +482,8 @@ vfio_get_group_fd(struct vfio_config *vfio_cfg,* knowledge of them. Requesting a group fd from the primary for a * container it doesn't know about would be incorrect. */ -const struct internal_config *internal_conf =eal_get_internal_configuration (); -bool mp_request = (internal_conf->process_type ==RTE_PROC_SECONDARY ) && +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +bool mp_request = (user_cfg->process_type ==RTE_PROC_SECONDARY ) && (vfio_cfg == default_vfio_cfg); vfio_group_fd =vfio_open_group_fd (iommu_group_num, mp_request);
@@ -770,8 +770,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,int iommu_group_num;rte_uuid_t vf_token;int i, ret; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* get group number */ ret =rte_vfio_get_group_num (sysfs_base, dev_addr, &iommu_group_num);
@@ -853,7 +852,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,* Note this can happen several times with the hotplug * functionality. */ -if (internal_conf->process_type ==RTE_PROC_PRIMARY && +if (user_cfg->process_type ==RTE_PROC_PRIMARY && vfio_cfg->vfio_active_groups ==1 &&vfio_group_device_count (vfio_group_fd) ==0 ) {const struct vfio_iommu_type *t;
@@ -1106,8 +1105,7 @@ rte_vfio_enable(const char *modname)unsigned int i, j;int vfio_available;DIR *dir; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();rte_spinlock_recursive_t lock =RTE_SPINLOCK_RECURSIVE_INITIALIZER ;
@@ -1151,7 +1149,7 @@ rte_vfio_enable(const char *modname) }closedir (dir); -if (internal_conf->process_type ==RTE_PROC_PRIMARY ) { +if (user_cfg->process_type ==RTE_PROC_PRIMARY ) {if (vfio_mp_sync_setup () ==-1 ) { default_vfio_cfg->vfio_container_fd =-1 ; }else {
lib/eal/windows/eal.c +3 -3
@@ -218,11 +218,11 @@ rte_eal_init(int argc, char **argv) }/* Prevent creation of shared memory files. */ -if (internal_conf->in_memory ==0 ) { +if (!user_cfg->in_memory) {EAL_LOG (WARNING ,"Multi-process support is requested, " "but not available." ); - internal_conf->in_memory =1 ; - internal_conf->no_shconf =1 ; + user_cfg->in_memory = true; + user_cfg->no_shconf = true; }if (!user_cfg->no_hugetlbfs && (eal_hugepage_info_init () <0 )) {
Signature · 1 line
2.53.0
PATCH v2 8/39 eal: move hugepage limit fields to new config structs
In reply to Bruce RichardsonMove the pagesz-mem fields to the user config structure as these are specified via commandline input. The derived memory limit for hugepages is moved to the runtime configuration, since it's not a direct user input parameter.
--- lib/eal/common/eal_common_dynmem.c | 3 ++- lib/eal/common/eal_common_options.c | 35 ++++++++++++++++------------- lib/eal/common/eal_internal_cfg.h | 17 +++++++------- lib/eal/linux/eal_memory.c | 3 ++- 4 files changed, 32 insertions(+), 26 deletions(-)
lib/eal/common/eal_common_dynmem.c +2 -1
@@ -37,6 +37,7 @@ eal_dynmem_memseg_lists_init(void)struct internal_config *internal_conf =eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* no-huge does not need this at all */ if (user_cfg->no_hugetlbfs)
@@ -109,7 +110,7 @@ eal_dynmem_memseg_lists_init(void) pagesz = type->page_sz; max_mem_per_type = - internal_conf->hugepage_mem_sz_limits[type->hpi_idx]; + runtime_state->hugepage_mem_sz_limits[type->hpi_idx];/* * we need to create a segment list for this type. we must take
lib/eal/common/eal_common_options.c +20 -15
@@ -510,6 +510,7 @@ void eal_reset_internal_config(struct internal_config *internal_cfg) {struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int i; user_cfg->memory =0 ;
@@ -521,6 +522,12 @@ eal_reset_internal_config(struct internal_config *internal_cfg) user_cfg->force_numa_limits = false;for (i =0 ; i <RTE_MAX_NUMA_NODES ; i++) user_cfg->numa_limit[i] =0 ; +for (i =0 ; i <MAX_HUGEPAGE_SIZES ; i++) { + runtime_state->hugepage_mem_sz_limits[i] =0 ; + user_cfg->pagesz_mem_overrides[i].pagesz =0 ; + user_cfg->pagesz_mem_overrides[i].limit =0 ; + } + user_cfg->num_pagesz_mem_overrides =0 ; user_cfg->process_type =RTE_PROC_PRIMARY ; user_cfg->no_hugetlbfs = false; user_cfg->no_pci = false;
@@ -533,11 +540,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg)memset (&internal_cfg->hugepage_info[i],0 ,sizeof (internal_cfg->hugepage_info[0 ])); internal_cfg->hugepage_info[i].lock_descriptor =-1 ; - internal_cfg->hugepage_mem_sz_limits[i] =0 ; - internal_cfg->pagesz_mem_overrides[i].pagesz =0 ; - internal_cfg->pagesz_mem_overrides[i].limit =0 ; } - internal_cfg->num_pagesz_mem_overrides =0 ; internal_cfg->base_virtaddr =0 ;/* if set to NONE, interrupt mode is determined automatically */
@@ -1904,7 +1907,7 @@ eal_parse_socket_arg(char *strval, volatile uint64_t *socket_arg) }static int -eal_parse_pagesz_mem (char *strval,struct internal_config *internal_cfg) +eal_parse_pagesz_mem (char *strval,struct eal_user_cfg *user_cfg) {char strval_cpy[1024 ];char *fields[3 ];
@@ -1965,8 +1968,8 @@ eal_parse_pagesz_mem(char *strval, struct internal_config *internal_cfg)return -1 ; } -for (i =0 ; i < internal_cfg->num_pagesz_mem_overrides; i++) { - pmo = &internal_cfg->pagesz_mem_overrides[i]; +for (i =0 ; i < user_cfg->num_pagesz_mem_overrides; i++) { + pmo = &user_cfg->pagesz_mem_overrides[i];if (pmo->pagesz != pagesz)continue ;
@@ -1978,17 +1981,17 @@ eal_parse_pagesz_mem(char *strval, struct internal_config *internal_cfg) }/* do we have space? */ -if (internal_cfg->num_pagesz_mem_overrides >=MAX_HUGEPAGE_SIZES ) { +if (user_cfg->num_pagesz_mem_overrides >=MAX_HUGEPAGE_SIZES ) {EAL_LOG (ERR ,"--pagesz-mem: too many page size entries (max %d)" ,MAX_HUGEPAGE_SIZES );return -1 ; } - pmo = &internal_cfg->pagesz_mem_overrides[internal_cfg->num_pagesz_mem_overrides]; + pmo = &user_cfg->pagesz_mem_overrides[user_cfg->num_pagesz_mem_overrides]; pmo->pagesz = pagesz; pmo->limit = mem_limit; - internal_cfg->num_pagesz_mem_overrides++; + user_cfg->num_pagesz_mem_overrides++;return 0 ; }
@@ -2325,7 +2328,7 @@ eal_parse_args(void) user_cfg->force_numa_limits = true; } TAILQ_FOREACH(arg, &args.pagesz_mem, next) { -if (eal_parse_pagesz_mem (arg->arg, int_cfg) <0 ) { +if (eal_parse_pagesz_mem (arg->arg, user_cfg) <0 ) {EAL_LOG (ERR ,"invalid pagesz-mem parameter: '%s'" , arg->arg);return -1 ; }
@@ -2522,6 +2525,8 @@ eal_adjust_config(struct internal_config *internal_cfg)int eal_apply_hugepage_mem_sz_limits (struct internal_config *internal_cfg) { +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();unsigned int i;for (i =0 ; i < internal_cfg->num_hugepage_sizes; i++) {
@@ -2534,12 +2539,12 @@ eal_apply_hugepage_mem_sz_limits(struct internal_config *internal_cfg) (uint64_t)RTE_MAX_MEMSEG_PER_TYPE * pagesz);/* override with user value for matching page size */ -for (j =0 ; j < (unsigned int )internal_cfg->num_pagesz_mem_overrides; j++) { -if (internal_cfg->pagesz_mem_overrides[j].pagesz == pagesz) - limit = internal_cfg->pagesz_mem_overrides[j].limit; +for (j =0 ; j < user_cfg->num_pagesz_mem_overrides; j++) { +if (user_cfg->pagesz_mem_overrides[j].pagesz == pagesz) + limit = user_cfg->pagesz_mem_overrides[j].limit; } - internal_cfg->hugepage_mem_sz_limits[i] = limit; + runtime_state->hugepage_mem_sz_limits[i] = limit; }return 0 ;
lib/eal/common/eal_internal_cfg.h +8 -9
@@ -74,6 +74,12 @@ struct eal_user_cfg {char *hugepage_dir;/**< specific hugetlbfs directory to use */ uint64_t numa_mem[RTE_MAX_NUMA_NODES ];/**< amount of memory per NUMA node */ uint64_t numa_limit[RTE_MAX_NUMA_NODES ];/**< limit amount of memory per NUMA node */ +/** storage for user-specified pagesz-mem overrides */ +struct pagesz_mem_override { +uint64_t pagesz;/**< page size in bytes */ +uint64_t limit;/**< memory limit in bytes */ + } pagesz_mem_overrides[MAX_HUGEPAGE_SIZES ]; +unsigned int num_pagesz_mem_overrides;/**< number of stored overrides */ };/**
@@ -90,7 +96,8 @@ struct eal_platform_info {* as appropriate. */ struct eal_runtime_state { -uint8_t reserved; +uint64_t hugepage_mem_sz_limits[MAX_HUGEPAGE_SIZES ]; +/**< default max memory per hugepage size */ };/**
@@ -116,14 +123,6 @@ struct internal_config {/**< user defined mbuf pool ops name */ unsigned num_hugepage_sizes;/**< how many sizes on this system */ struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES ]; -uint64_t hugepage_mem_sz_limits[MAX_HUGEPAGE_SIZES ]; -/**< default max memory per hugepage size */ -/** storage for user-specified pagesz-mem overrides */ -struct pagesz_mem_override { -uint64_t pagesz;/**< page size in bytes */ -uint64_t limit;/**< memory limit in bytes */ - } pagesz_mem_overrides[MAX_HUGEPAGE_SIZES ]; -unsigned int num_pagesz_mem_overrides;/**< number of stored overrides */ enum rte_iova_mode iova_mode ;/**< Set IOVA mode on this system */ rte_cpuset_t ctrl_cpuset;/**< cpuset for ctrl threads */ volatile unsigned int init_complete;
lib/eal/linux/eal_memory.c +2 -1
@@ -1704,6 +1704,7 @@ memseg_primary_init_32(void)struct internal_config *internal_conf =eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* no-huge does not need this at all */ if (user_cfg->no_hugetlbfs)
@@ -1824,7 +1825,7 @@ memseg_primary_init_32(void)continue ; max_pagesz_mem = max_socket_mem - cur_socket_mem; - pagesz_mem_limit = internal_conf->hugepage_mem_sz_limits[hpi_idx]; + pagesz_mem_limit = runtime_state->hugepage_mem_sz_limits[hpi_idx]; max_pagesz_mem =RTE_MIN (max_pagesz_mem, pagesz_mem_limit);/* make it multiple of page size */
Signature · 1 line
2.53.0
PATCH v2 9/39 eal: move advanced user config options to user cfg struct
In reply to Bruce RichardsonMove the more advanced configuration options, such as for virtual base addresses, vfio interrupt mode, etc., to the user configuration structure, so that all user-provided config options are in a single struct, which does not contain any other fields other than user config options.
--- lib/eal/common/eal_common_bus.c | 4 +- lib/eal/common/eal_common_config.c | 6 +- lib/eal/common/eal_common_dynmem.c | 2 +- lib/eal/common/eal_common_mcfg.c | 14 ++--- lib/eal/common/eal_common_memalloc.c | 5 +- lib/eal/common/eal_common_memory.c | 36 +++++------- lib/eal/common/eal_common_options.c | 88 +++++++++++++--------------- lib/eal/common/eal_internal_cfg.h | 33 ++++------- lib/eal/common/eal_options.h | 3 +- lib/eal/common/malloc_elem.c | 15 ++--- lib/eal/common/malloc_heap.c | 17 +++--- lib/eal/freebsd/eal.c | 15 ++--- lib/eal/linux/eal.c | 26 ++++---- lib/eal/linux/eal_hugepage_info.c | 5 +- lib/eal/linux/eal_memalloc.c | 63 ++++++++------------ lib/eal/linux/eal_memory.c | 41 ++++++------- lib/eal/windows/eal.c | 7 +-- lib/eal/windows/eal_memalloc.c | 6 +- lib/eal/windows/eal_memory.c | 6 +- 19 files changed, 168 insertions(+), 224 deletions(-)
lib/eal/common/eal_common_bus.c +2 -2
@@ -345,12 +345,12 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_bus_device_is_ignored)bool rte_bus_device_is_ignored (const struct rte_bus *bus,const char *dev_name) { -const struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct rte_devargs *devargs =rte_bus_find_devargs (bus, dev_name);enum rte_bus_scan_mode scan_mode = bus->conf.scan_mode;if (scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { -if (internal_conf->no_auto_probing !=0 ) +if (user_cfg->no_auto_probing) scan_mode =RTE_BUS_SCAN_ALLOWLIST ;else scan_mode =RTE_BUS_SCAN_BLOCKLIST ;
lib/eal/common/eal_common_config.c +3 -3
@@ -106,8 +106,8 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_eal_get_baseaddr)uint64_t rte_eal_get_baseaddr (void ) { -return (internal_config.base_virtaddr !=0 ) ? - (uint64_t ) internal_config.base_virtaddr : +return (eal_user_cfg.base_virtaddr !=0 ) ? + (uint64_t ) eal_user_cfg.base_virtaddr :eal_get_baseaddr (); }
@@ -123,7 +123,7 @@ RTE_EXPORT_SYMBOL(rte_eal_mbuf_user_pool_ops)const char *rte_eal_mbuf_user_pool_ops (void ) { -return internal_config.user_mbuf_pool_ops_name; +return eal_user_cfg.user_mbuf_pool_ops_name; }/* return non-zero if hugepages are enabled. */
lib/eal/common/eal_common_dynmem.c +1 -1
@@ -83,7 +83,7 @@ eal_dynmem_memseg_lists_init(void)#ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES /* we can still sort pages by socket in legacy mode */ -if (!internal_conf->legacy_mem && socket_id >0 ) +if (!user_cfg->legacy_mem && socket_id >0 )break ;#endif memtypes[cur_type].page_sz = hugepage_sz;
lib/eal/common/eal_common_mcfg.c +6 -8
@@ -50,22 +50,20 @@ voideal_mcfg_update_internal (void) {struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_user_cfg *user_cfg =eal_get_user_configuration (); - internal_conf->legacy_mem = mcfg->legacy_mem; - internal_conf->single_file_segments = mcfg->single_file_segments; + user_cfg->legacy_mem = mcfg->legacy_mem; + user_cfg->single_file_segments = mcfg->single_file_segments; }void eal_mcfg_update_from_internal (void ) {struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); - mcfg->legacy_mem = internal_conf->legacy_mem; - mcfg->single_file_segments = internal_conf->single_file_segments; + mcfg->legacy_mem = user_cfg->legacy_mem; + mcfg->single_file_segments = user_cfg->single_file_segments;/* record current DPDK version */ mcfg->version =RTE_VERSION ; }
lib/eal/common/eal_common_memalloc.c +2 -3
@@ -72,15 +72,14 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start,void *end, *aligned_start, *aligned_end;size_t pgsz = (size_t )msl->page_sz;const struct rte_memseg *ms; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* for IOVA_VA, it's always contiguous */ if (rte_eal_iova_mode () ==RTE_IOVA_VA && !msl->external)return true;/* for legacy memory, it's always contiguous */ -if (internal_conf->legacy_mem) +if (user_cfg->legacy_mem)return true; end =RTE_PTR_ADD (start, len);
lib/eal/common/eal_common_memory.c +15 -21
@@ -53,8 +53,7 @@ eal_get_virtual_area(void *requested_addr, size_t *size,uint64_t map_sz;void *mapped_addr, *aligned_addr;uint8_t try =0 ; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (system_page_sz ==0 ) system_page_sz =rte_mem_page_size ();
@@ -65,12 +64,12 @@ eal_get_virtual_area(void *requested_addr, size_t *size, allow_shrink = (flags &EAL_VIRTUAL_AREA_ALLOW_SHRINK ) >0 ; unmap = (flags &EAL_VIRTUAL_AREA_UNMAP ) >0 ; -if (next_baseaddr ==NULL && internal_conf->base_virtaddr !=0 && +if (next_baseaddr ==NULL && user_cfg->base_virtaddr !=0 &&rte_eal_process_type () ==RTE_PROC_PRIMARY ) - next_baseaddr = (void *) internal_conf->base_virtaddr; + next_baseaddr = (void *) user_cfg->base_virtaddr;#ifdef RTE_ARCH_64 -if (next_baseaddr ==NULL && internal_conf->base_virtaddr ==0 && +if (next_baseaddr ==NULL && user_cfg->base_virtaddr ==0 &&rte_eal_process_type () ==RTE_PROC_PRIMARY ) next_baseaddr = (void *)eal_get_baseaddr ();#endif
@@ -151,7 +150,7 @@ eal_get_virtual_area(void *requested_addr, size_t *size,* demote this warning to debug if we did not explicitly request * a base virtual address. */ -if (internal_conf->base_virtaddr !=0 ) { +if (user_cfg->base_virtaddr !=0 ) {EAL_LOG (WARNING ,"WARNING! Base virtual address hint (%p != %p) not respected!" , requested_addr, aligned_addr);EAL_LOG (WARNING ," This may cause issues with mapping memory into secondary processes" );
@@ -404,8 +403,7 @@ void * rte_mem_iova2virt(rte_iova_t iova) {struct virtiova vi; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();memset (&vi,0 ,sizeof (vi));
@@ -413,7 +411,7 @@ rte_mem_iova2virt(rte_iova_t iova)/* for legacy mem, we can get away with scanning VA-contiguous segments, * as we know they are PA-contiguous as well */ -if (internal_conf->legacy_mem) +if (user_cfg->legacy_mem)rte_memseg_contig_walk (find_virt_legacy, &vi);else rte_memseg_walk (find_virt, &vi);
@@ -497,11 +495,10 @@ int rte_mem_event_callback_register(const char *name, rte_mem_event_callback_t clb, void *arg) { - const struct internal_config *internal_conf = -eal_get_internal_configuration (); + const struct eal_user_cfg *user_cfg = eal_get_user_configuration();/* FreeBSD boots with legacy mem enabled by default */ -if (internal_conf->legacy_mem) { +if (user_cfg->legacy_mem) {EAL_LOG (DEBUG ,"Registering mem event callbacks not supported" ); rte_errno =ENOTSUP ;return -1 ;
@@ -513,11 +510,10 @@ RTE_EXPORT_SYMBOL(rte_mem_event_callback_unregister)int rte_mem_event_callback_unregister (const char *name,void *arg) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* FreeBSD boots with legacy mem enabled by default */ -if (internal_conf->legacy_mem) { +if (user_cfg->legacy_mem) {EAL_LOG (DEBUG ,"Registering mem event callbacks not supported" ); rte_errno =ENOTSUP ;return -1 ;
@@ -530,11 +526,10 @@ int rte_mem_alloc_validator_register(const char *name, rte_mem_alloc_validator_t clb, int socket_id, size_t limit) { - const struct internal_config *internal_conf = -eal_get_internal_configuration (); + const struct eal_user_cfg *user_cfg = eal_get_user_configuration();/* FreeBSD boots with legacy mem enabled by default */ -if (internal_conf->legacy_mem) { +if (user_cfg->legacy_mem) {EAL_LOG (DEBUG ,"Registering mem alloc validators not supported" ); rte_errno =ENOTSUP ;return -1 ;
@@ -547,11 +542,10 @@ RTE_EXPORT_SYMBOL(rte_mem_alloc_validator_unregister)int rte_mem_alloc_validator_unregister (const char *name,int socket_id) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* FreeBSD boots with legacy mem enabled by default */ -if (internal_conf->legacy_mem) { +if (user_cfg->legacy_mem) {EAL_LOG (DEBUG ,"Registering mem alloc validators not supported" ); rte_errno =ENOTSUP ;return -1 ;
lib/eal/common/eal_common_options.c +41 -47
244 lines not on this page · raw message
lib/eal/common/eal_internal_cfg.h +11 -22
@@ -56,7 +56,12 @@ struct hugepage_file_discipline {*/ struct eal_user_cfg {size_t memory;/**< amount of asked memory */ +size_t huge_worker_stack_size;/**< worker thread stack size */ enum rte_proc_type_t process_type;/**< requested process type */ +enum rte_intr_mode vfio_intr_mode;/**< default interrupt mode for VFIO */ +enum rte_iova_mode iova_mode;/**< requested IOVA mode */ +struct simd_bitwidth max_simd_bitwidth;/**< max simd bitwidth path to use */ +rte_uuid_t vfio_vf_token;/**< shared VF token for VFIO-PCI bound PF and VFs */ uint8_t force_nchannel;/**< force number of channels */ uint8_t force_nrank;/**< force number of ranks */ bool force_numa;/**< true to request memory on specific NUMA nodes */
@@ -69,9 +74,15 @@ struct eal_user_cfg {bool in_memory;/**< true to run with no shared runtime files */ bool create_uio_dev;/**< true to create /dev/uioX devices */ bool no_telemetry;/**< true to disable telemetry */ +bool legacy_mem;/**< true to enable legacy memory behavior */ +bool match_allocations;/**< true to free hugepages exactly as allocated */ +bool no_auto_probing;/**< true to switch from block-listing to allow-listing */ +bool single_file_segments;/**< true if storing all pages within single files */ struct hugepage_file_discipline hugepage_file;char *hugefile_prefix;/**< the base filename of hugetlbfs files */ char *hugepage_dir;/**< specific hugetlbfs directory to use */ +char *user_mbuf_pool_ops_name;/**< user defined mbuf pool ops name */ +uintptr_t base_virtaddr;/**< base address to try and reserve memory from */ uint64_t numa_mem[RTE_MAX_NUMA_NODES ];/**< amount of memory per NUMA node */ uint64_t numa_limit[RTE_MAX_NUMA_NODES ];/**< limit amount of memory per NUMA node */ /** storage for user-specified pagesz-mem overrides */
@@ -104,33 +115,11 @@ struct eal_runtime_state {* internal configuration */ struct internal_config { -uintptr_t base_virtaddr;/**< base address to try and reserve memory from */ -volatile unsigned legacy_mem; -/**< true to enable legacy memory behavior (no dynamic allocation, -* IOVA-contiguous segments). -*/ -volatile unsigned match_allocations; -/**< true to free hugepages exactly as allocated */ -volatile unsigned single_file_segments; -/**< true if storing all pages within single files (per-page-size, -* per-node) non-legacy mode only. -*/ -/** default interrupt mode for VFIO */ -volatile enum rte_intr_mode vfio_intr_mode; -/** the shared VF token for VFIO-PCI bound PF and VFs devices */ -rte_uuid_t vfio_vf_token; -char *user_mbuf_pool_ops_name; -/**< user defined mbuf pool ops name */ unsigned num_hugepage_sizes;/**< how many sizes on this system */ struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES ]; -enum rte_iova_mode iova_mode ;/**< Set IOVA mode on this system */ rte_cpuset_t ctrl_cpuset;/**< cpuset for ctrl threads */ volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */ -struct simd_bitwidth max_simd_bitwidth; -/**< max simd bitwidth path to use */ -size_t huge_worker_stack_size;/**< worker thread stack size */ -unsigned int no_auto_probing;/**< true to switch from block-listing to allow-listing */ };struct eal_user_cfg *eal_get_user_configuration (void );
lib/eal/common/eal_options.h +2 -1
@@ -8,13 +8,14 @@#include "getopt.h" struct rte_tel_data ; +struct eal_user_cfg ;int eal_parse_log_options (void );int eal_parse_args (void );int eal_option_device_parse (void );int eal_apply_hugepage_mem_sz_limits (struct internal_config *internal_cfg);int eal_adjust_config (struct internal_config *internal_cfg); -int eal_cleanup_config (struct internal_config *internal_cfg); +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 );int eal_save_args (int argc,char **argv);
lib/eal/common/malloc_elem.c +6 -9
@@ -37,8 +37,7 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align)rte_iova_t expected_iova;struct rte_memseg *ms;size_t page_sz, cur, max; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); page_sz = (size_t )elem->msl->page_sz; data_start =RTE_PTR_ADD (elem,MALLOC_ELEM_HEADER_LEN );
@@ -57,7 +56,7 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align)*/ if (!elem->msl->external && (rte_eal_iova_mode () ==RTE_IOVA_VA || - (internal_conf->legacy_mem && + (user_cfg->legacy_mem &&rte_eal_has_hugepages ())))return RTE_PTR_DIFF (data_end, contig_seg_start);
@@ -338,24 +337,22 @@ remove_elem(struct malloc_elem *elem)static int next_elem_is_adjacent (struct malloc_elem *elem) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();return elem->next ==RTE_PTR_ADD (elem, elem->size) && elem->next->msl == elem->msl && - (!internal_conf->match_allocations || + (!user_cfg->match_allocations || elem->orig_elem == elem->next->orig_elem); }static int prev_elem_is_adjacent (struct malloc_elem *elem) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();return elem ==RTE_PTR_ADD (elem->prev, elem->prev->size) && elem->prev->msl == elem->msl && - (!internal_conf->match_allocations || + (!user_cfg->match_allocations || elem->orig_elem == elem->prev->orig_elem); }
lib/eal/common/malloc_heap.c +7 -10
@@ -647,15 +647,14 @@ malloc_heap_alloc_on_heap_id(size_t size, unsigned int heap_id, unsigned int flaunsigned int size_flags = flags & ~RTE_MEMZONE_SIZE_HINT_ONLY ;int socket_id;void *ret; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();rte_spinlock_lock (&(heap->lock)); align = align ==0 ?1 : align;/* for legacy mode, try once and with all flags */ -if (internal_conf->legacy_mem) { +if (user_cfg->legacy_mem) { ret =heap_alloc (heap, size, flags, align, bound, contig); goto alloc_unlock; }
@@ -865,8 +864,7 @@ malloc_heap_free(struct malloc_elem *elem)unsigned int i, n_segs, before_space, after_space;int ret;bool unmapped = false; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (!malloc_elem_cookies_ok (elem) || elem->state !=ELEM_BUSY )return -1 ;
@@ -894,7 +892,7 @@ malloc_heap_free(struct malloc_elem *elem)/* ...of which we can't avail if we are in legacy mode, or if this is an * externally allocated segment. */ -if (internal_conf->legacy_mem || (msl->external >0 )) +if (user_cfg->legacy_mem || (msl->external >0 )) goto free_unlock;/* check if we can free any memory back to the system */
@@ -905,7 +903,7 @@ malloc_heap_free(struct malloc_elem *elem)* we will defer freeing these hugepages until the entire original allocation * can be freed */ -if (internal_conf->match_allocations && elem->size != elem->orig_size) +if (user_cfg->match_allocations && elem->size != elem->orig_size) goto free_unlock;/* probably, but let's make sure, as we may not be using up full page */
@@ -1401,10 +1399,9 @@ rte_eal_malloc_heap_init(void) {struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config;unsigned int i; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -if (internal_conf->match_allocations) +if (user_cfg->match_allocations)EAL_LOG (DEBUG ,"Hugepages will be freed exactly as allocated." );if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) {
lib/eal/freebsd/eal.c +6 -9
@@ -97,8 +97,6 @@ static intrte_eal_config_create (void) {struct rte_config *config =rte_eal_get_configuration (); -const struct internal_config *internal_conf = -eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();size_t page_sz =rte_mem_page_size ();size_t cfg_len =sizeof (struct rte_mem_config );
@@ -112,9 +110,9 @@ rte_eal_config_create(void)return 0 ;/* map the config before base address so that we don't waste a page */ -if (internal_conf->base_virtaddr !=0 ) +if (user_cfg->base_virtaddr !=0 ) rte_mem_cfg_addr = (void *) -RTE_ALIGN_FLOOR (internal_conf->base_virtaddr - +RTE_ALIGN_FLOOR (user_cfg->base_virtaddr -sizeof (struct rte_mem_config ), page_sz);else rte_mem_cfg_addr =NULL ;
@@ -472,7 +470,7 @@ rte_eal_init(int argc, char **argv) }/* FreeBSD always uses legacy memory model */ - internal_conf->legacy_mem = true; + user_cfg->legacy_mem = true;if (user_cfg->in_memory) {EAL_LOG (WARNING ,"Warning: ignoring unsupported flag, '--in-memory'" ); user_cfg->in_memory = false;
@@ -538,7 +536,7 @@ rte_eal_init(int argc, char **argv)/* Always call rte_bus_get_iommu_class() to trigger DMA mask detection and validation */ enum rte_iova_mode bus_iova_mode =rte_bus_get_iommu_class (); - iova_mode = internal_conf->iova_mode; + iova_mode = user_cfg->iova_mode;if (iova_mode ==RTE_IOVA_DC ) {EAL_LOG (DEBUG ,"Specific IOVA mode is not requested, autodetecting" );if (has_phys_addr) {
@@ -781,8 +779,7 @@ rte_eal_cleanup(void)return -1 ; } -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_user_cfg *user_cfg =eal_get_user_configuration ();rte_service_finalize ();eal_bus_cleanup ();rte_mp_channel_cleanup ();
@@ -791,7 +788,7 @@ rte_eal_cleanup(void)eal_trace_fini ();/* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach (); -eal_cleanup_config (internal_conf); +eal_cleanup_config (user_cfg);eal_lcore_var_cleanup ();return 0 ; }
lib/eal/linux/eal.c +11 -15
@@ -182,8 +182,6 @@ rte_eal_config_create(void)size_t cfg_len_aligned =RTE_ALIGN (cfg_len, page_sz);void *rte_mem_cfg_addr, *mapped_mem_cfg_addr;int retval; -const struct internal_config *internal_conf = -eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();const char *pathname =eal_runtime_config_path ();
@@ -192,9 +190,9 @@ rte_eal_config_create(void)return 0 ;/* map the config before hugepage address so that we don't waste a page */ -if (internal_conf->base_virtaddr !=0 ) +if (user_cfg->base_virtaddr !=0 ) rte_mem_cfg_addr = (void *) -RTE_ALIGN_FLOOR (internal_conf->base_virtaddr - +RTE_ALIGN_FLOOR (user_cfg->base_virtaddr -sizeof (struct rte_mem_config ), page_sz);else rte_mem_cfg_addr =NULL ;
@@ -522,8 +520,9 @@ eal_worker_thread_create(unsigned int lcore_id)pthread_attr_t attr;size_t stack_size;int ret =-1 ; +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); - stack_size =eal_get_internal_configuration ()->huge_worker_stack_size; + stack_size = user_cfg->huge_worker_stack_size;if (stack_size !=0 ) {/* Allocate NUMA aware stack memory and set pthread attributes */ stack_ptr = rte_zmalloc_socket("lcore_stack", stack_size,
@@ -687,7 +686,7 @@ rte_eal_init(int argc, char **argv)enum rte_iova_mode bus_iova_mode =rte_bus_get_iommu_class ();/* if no EAL option "--iova-mode=<pa|va>", use bus IOVA scheme */ -if (internal_conf->iova_mode ==RTE_IOVA_DC ) { +if (user_cfg->iova_mode ==RTE_IOVA_DC ) {/* autodetect the IOVA mapping mode */ enum rte_iova_mode iova_mode = bus_iova_mode;
@@ -718,7 +717,7 @@ rte_eal_init(int argc, char **argv)rte_eal_get_configuration ()->iova_mode = iova_mode; }else {rte_eal_get_configuration ()->iova_mode = - internal_conf->iova_mode; + user_cfg->iova_mode; }if (rte_eal_iova_mode () ==RTE_IOVA_PA && !phys_addrs) {
@@ -975,8 +974,6 @@ rte_eal_cleanup(void)/* if we're in a primary process, we need to mark hugepages as freeable * so that finalization can release them back to the system. */ -struct internal_config *internal_conf = -eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
@@ -994,7 +991,7 @@ rte_eal_cleanup(void)/* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach ();rte_eal_malloc_heap_cleanup (); -eal_cleanup_config (internal_conf); +eal_cleanup_config (user_cfg);eal_lcore_var_cleanup ();rte_eal_log_cleanup ();return 0 ;
@@ -1012,19 +1009,18 @@ RTE_EXPORT_SYMBOL(rte_eal_vfio_intr_mode)enum rte_intr_mode rte_eal_vfio_intr_mode (void ) { -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -return internal_conf->vfio_intr_mode; +return user_cfg->vfio_intr_mode; }RTE_EXPORT_SYMBOL (rte_eal_vfio_get_vf_token) voidrte_eal_vfio_get_vf_token (rte_uuid_t vf_token) { -struct internal_config *cfg =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -rte_uuid_copy (vf_token, cfg->vfio_vf_token); +rte_uuid_copy (vf_token, user_cfg->vfio_vf_token); }int
lib/eal/linux/eal_hugepage_info.c +2 -3
@@ -401,8 +401,7 @@ calc_num_pages(struct hugepage_info *hpi, struct dirent *dirent, {uint64_t total_pages =0 ;unsigned int i; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* * first, try to put all hugepages into relevant sockets, but
@@ -418,7 +417,7 @@ calc_num_pages(struct hugepage_info *hpi, struct dirent *dirent,* This could be determined by mapping, * but it is precisely what hugepage file reuse is trying to avoid. */ -if (!internal_conf->legacy_mem && reusable_pages ==0 ) +if (!user_cfg->legacy_mem && reusable_pages ==0 )for (i =0 ; i <rte_socket_count (); i++) {int socket =rte_socket_id_by_idx (i); unsigned int num_pages =
lib/eal/linux/eal_memalloc.c +26 -37
196 lines not on this page · raw message
lib/eal/linux/eal_memory.c +18 -23
119 lines not on this page · raw message
lib/eal/windows/eal.c +3 -4
@@ -139,15 +139,14 @@ RTE_EXPORT_SYMBOL(rte_eal_cleanup)int rte_eal_cleanup (void ) { -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_user_cfg *user_cfg =eal_get_user_configuration ();eal_intr_thread_cancel ();eal_mem_virt2iova_cleanup ();eal_bus_cleanup ();/* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach (); -eal_cleanup_config (internal_conf); +eal_cleanup_config (user_cfg);eal_lcore_var_cleanup ();return 0 ; }
@@ -277,7 +276,7 @@ rte_eal_init(int argc, char **argv)/* Always call rte_bus_get_iommu_class() to trigger DMA mask detection and validation */ enum rte_iova_mode bus_iova_mode =rte_bus_get_iommu_class (); - iova_mode = internal_conf->iova_mode; + iova_mode = user_cfg->iova_mode;if (iova_mode ==RTE_IOVA_DC ) {EAL_LOG (DEBUG ,"Specific IOVA mode is not requested, autodetecting" );if (has_phys_addr) {
lib/eal/windows/eal_memalloc.c +4 -2
@@ -316,8 +316,9 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs,struct hugepage_info *hi =NULL ;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -if (internal_conf->legacy_mem) { +if (user_cfg->legacy_mem) {EAL_LOG (ERR ,"dynamic allocation not supported in legacy mode" );return -ENOTSUP ; }
@@ -369,9 +370,10 @@ eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs)int seg, ret =0 ;struct internal_config *internal_conf =eal_get_internal_configuration (); +const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* dynamic free not supported in legacy mode */ -if (internal_conf->legacy_mem) +if (user_cfg->legacy_mem)return -1 ;for (seg =0 ; seg < n_segs; seg++) {
lib/eal/windows/eal_memory.c +2 -4
@@ -678,12 +678,10 @@ eal_nohuge_init(void)void *addr; mcfg =rte_eal_get_configuration ()->mem_config; -struct internal_config *internal_conf = -eal_get_internal_configuration (); -const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* nohuge mode is legacy mode */ - internal_conf->legacy_mem =1 ; + user_cfg->legacy_mem =1 ; msl = &mcfg->memsegs[0 ];
Signature · 1 line
2.53.0
PATCH v2 10/39 eal: move hugepage size info to platform info struct
In reply to Bruce RichardsonThe hugepage information should not change for the lifetime of the process, so store it in the platform_info structure in EAL, moving it out of the internal_config.
--- lib/eal/common/eal_common_dynmem.c | 29 ++++++------- lib/eal/common/eal_common_options.c | 14 ++++--- lib/eal/common/eal_internal_cfg.h | 5 +-- lib/eal/common/eal_options.h | 2 +- lib/eal/freebsd/eal.c | 9 ++-- lib/eal/freebsd/eal_hugepage_info.c | 28 ++++++------- lib/eal/freebsd/eal_memory.c | 21 ++++------ lib/eal/linux/eal.c | 14 +++---- lib/eal/linux/eal_hugepage_info.c | 37 ++++++++--------- lib/eal/linux/eal_memalloc.c | 27 ++++++------ lib/eal/linux/eal_memory.c | 64 +++++++++++++---------------- lib/eal/windows/eal.c | 4 +- lib/eal/windows/eal_hugepages.c | 7 ++-- lib/eal/windows/eal_memalloc.c | 26 ++++++------ 14 files changed, 130 insertions(+), 157 deletions(-)
lib/eal/common/eal_common_dynmem.c +13 -16
@@ -34,8 +34,7 @@ eal_dynmem_memseg_lists_init(void)size_t mem_va_len, mem_va_page_sz;unsigned int n_memtypes, cur_type;void *mem_va_addr =NULL ; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();
@@ -59,7 +58,7 @@ eal_dynmem_memseg_lists_init(void)*/ /* maximum number of memtypes we're ever going to get */ - n_memtypes = internal_conf->num_hugepage_sizes *rte_socket_count (); + n_memtypes = platform_info->num_hugepage_sizes *rte_socket_count ();/* can we fit all memtypes into the memseg lists? */ if (n_memtypes >RTE_MAX_MEMSEG_LISTS ) {
@@ -70,12 +69,12 @@ eal_dynmem_memseg_lists_init(void)/* populate mem types */ cur_type =0 ; -for (hpi_idx =0 ; hpi_idx < (int ) internal_conf->num_hugepage_sizes; +for (hpi_idx =0 ; hpi_idx < (int ) platform_info->num_hugepage_sizes; hpi_idx++) {struct hugepage_info *hpi;uint64_t hugepage_sz; - hpi = &internal_conf->hugepage_info[hpi_idx]; + hpi = &platform_info->hugepage_info[hpi_idx]; hugepage_sz = hpi->hugepage_sz;for (i =0 ; i < (int )rte_socket_count (); i++, cur_type++) {
@@ -212,14 +211,13 @@ eal_dynmem_hugepage_init(void)struct hugepage_info used_hp[MAX_HUGEPAGE_SIZES ];uint64_t memory[RTE_MAX_NUMA_NODES ];int hp_sz_idx, socket_id; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();memset (used_hp,0 ,sizeof (used_hp));for (hp_sz_idx =0 ; - hp_sz_idx < (int ) internal_conf->num_hugepage_sizes; + hp_sz_idx < (int ) platform_info->num_hugepage_sizes; hp_sz_idx++) {#ifndef RTE_ARCH_64 struct hugepage_info dummy;
@@ -227,7 +225,7 @@ eal_dynmem_hugepage_init(void)#endif /* also initialize used_hp hugepage sizes in used_hp */ struct hugepage_info *hpi; - hpi = &internal_conf->hugepage_info[hp_sz_idx]; + hpi = &platform_info->hugepage_info[hp_sz_idx]; used_hp[hp_sz_idx].hugepage_sz = hpi->hugepage_sz;#ifndef RTE_ARCH_64
@@ -255,12 +253,12 @@ eal_dynmem_hugepage_init(void)/* calculate final number of pages */ if (eal_dynmem_calc_num_pages_per_socket (memory, - internal_conf->hugepage_info, used_hp, - internal_conf->num_hugepage_sizes) <0 ) + platform_info->hugepage_info, used_hp, + platform_info->num_hugepage_sizes) <0 )return -1 ;for (hp_sz_idx =0 ; - hp_sz_idx < (int )internal_conf->num_hugepage_sizes; + hp_sz_idx < (int )platform_info->num_hugepage_sizes; hp_sz_idx++) {for (socket_id =0 ; socket_id <RTE_MAX_NUMA_NODES ; socket_id++) {
@@ -339,11 +337,10 @@ get_socket_mem_size(int socket) {uint64_t size =0 ;unsigned int i; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info (); -for (i =0 ; i < internal_conf->num_hugepage_sizes; i++) { -struct hugepage_info *hpi = &internal_conf->hugepage_info[i]; +for (i =0 ; i < platform_info->num_hugepage_sizes; i++) { +struct hugepage_info *hpi = &platform_info->hugepage_info[i]; size += hpi->hugepage_sz * hpi->num_pages[socket]; }
lib/eal/common/eal_common_options.c +8 -6
@@ -511,6 +511,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg) {struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +struct eal_platform_info *platform_info =eal_get_platform_info ();int i; user_cfg->memory =0 ;
@@ -537,9 +538,9 @@ eal_reset_internal_config(struct internal_config *internal_cfg) user_cfg->hugepage_file.unlink_existing = true;/* zero out hugedir descriptors */ for (i =0 ; i <MAX_HUGEPAGE_SIZES ; i++) { -memset (&internal_cfg->hugepage_info[i],0 , -sizeof (internal_cfg->hugepage_info[0 ])); - internal_cfg->hugepage_info[i].lock_descriptor =-1 ; +memset (&platform_info->hugepage_info[i],0 , +sizeof (platform_info->hugepage_info[0 ])); + platform_info->hugepage_info[i].lock_descriptor =-1 ; } user_cfg->base_virtaddr =0 ;
@@ -2519,15 +2520,16 @@ eal_adjust_config(struct internal_config *internal_cfg) }int -eal_apply_hugepage_mem_sz_limits (struct internal_config *internal_cfg) +eal_apply_hugepage_mem_sz_limits (void ) {const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +const struct eal_platform_info *platform_info =eal_get_platform_info ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();unsigned int i; -for (i =0 ; i < internal_cfg->num_hugepage_sizes; i++) { +for (i =0 ; i < platform_info->num_hugepage_sizes; i++) {unsigned int j; -const uint64_t pagesz = internal_cfg->hugepage_info[i].hugepage_sz; +const uint64_t pagesz = platform_info->hugepage_info[i].hugepage_sz;uint64_t limit;/* assign default limits */
lib/eal/common/eal_internal_cfg.h +2 -3
@@ -98,7 +98,8 @@ struct eal_user_cfg {* Immutable after initialization, so no need for atomic types or locks. */ struct eal_platform_info { -uint8_t reserved; +uint8_t num_hugepage_sizes;/**< how many sizes on this system */ +struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES ]; };/**
@@ -115,8 +116,6 @@ struct eal_runtime_state {* internal configuration */ struct internal_config { -unsigned num_hugepage_sizes;/**< how many sizes on this system */ -struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES ];rte_cpuset_t ctrl_cpuset;/**< cpuset for ctrl threads */ volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */
lib/eal/common/eal_options.h +1 -1
@@ -13,7 +13,7 @@ struct eal_user_cfg;int eal_parse_log_options (void );int eal_parse_args (void );int eal_option_device_parse (void ); -int eal_apply_hugepage_mem_sz_limits (struct internal_config *internal_cfg); +int eal_apply_hugepage_mem_sz_limits (void );int eal_adjust_config (struct internal_config *internal_cfg);int eal_cleanup_config (const struct eal_user_cfg *user_cfg);enum rte_proc_type_t eal_proc_type_detect (void );
lib/eal/freebsd/eal.c +4 -5
@@ -329,11 +329,10 @@ eal_get_hugepage_mem_size(void) {uint64_t size =0 ;unsigned i, j; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info (); -for (i =0 ; i < internal_conf->num_hugepage_sizes; i++) { -struct hugepage_info *hpi = &internal_conf->hugepage_info[i]; +for (i =0 ; i < platform_info->num_hugepage_sizes; i++) { +struct hugepage_info *hpi = &platform_info->hugepage_info[i];if (strnlen (hpi->hugedir,sizeof (hpi->hugedir)) !=0 ) {for (j =0 ; j <RTE_MAX_NUMA_NODES ; j++) { size += hpi->hugepage_sz * hpi->num_pages[j];
@@ -582,7 +581,7 @@ rte_eal_init(int argc, char **argv) goto err_out; }if (user_cfg->process_type ==RTE_PROC_PRIMARY && -eal_apply_hugepage_mem_sz_limits (internal_conf) <0 ) { +eal_apply_hugepage_mem_sz_limits () <0 ) {rte_eal_init_alert ("Cannot apply hugepage memory limits." ); rte_errno =EINVAL ; goto err_out;
lib/eal/freebsd/eal_hugepage_info.c +13 -15
@@ -57,16 +57,15 @@ eal_hugepage_info_init(void)size_t sysctl_size;int num_buffers, fd, error;int64_t buffer_size =0 ; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();/* re-use the linux "internal config" structure for our memory data */ -struct hugepage_info *hpi = &internal_conf->hugepage_info[0 ]; +struct hugepage_info *hpi = &platform_info->hugepage_info[0 ];const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct hugepage_info *tmp_hpi;unsigned int i; - internal_conf->num_hugepage_sizes =1 ; + platform_info->num_hugepage_sizes =1 ; sysctl_size =sizeof (num_buffers); error = sysctlbyname("hw.contigmem.num_buffers", &num_buffers,
@@ -121,23 +120,23 @@ eal_hugepage_info_init(void)return 0 ; tmp_hpi =create_shared_memory (eal_hugepage_info_path (), -sizeof (internal_conf->hugepage_info)); +sizeof (platform_info->hugepage_info));if (tmp_hpi ==NULL ) {EAL_LOG (ERR ,"Failed to create shared memory!" );return -1 ; } -memcpy (tmp_hpi, hpi,sizeof (internal_conf->hugepage_info)); +memcpy (tmp_hpi, hpi,sizeof (platform_info->hugepage_info));/* we've copied file descriptors along with everything else, but they * will be invalid in secondary process, so overwrite them */ -for (i =0 ; i <RTE_DIM (internal_conf->hugepage_info); i++) { +for (i =0 ; i <RTE_DIM (platform_info->hugepage_info); i++) {struct hugepage_info *tmp = &tmp_hpi[i]; tmp->lock_descriptor =-1 ; } -if (munmap (tmp_hpi,sizeof (internal_conf->hugepage_info)) <0 ) { +if (munmap (tmp_hpi,sizeof (platform_info->hugepage_info)) <0 ) {EAL_LOG (ERR ,"Failed to unmap shared memory!" );return -1 ; }
@@ -149,24 +148,23 @@ eal_hugepage_info_init(void)int eal_hugepage_info_read (void ) { -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info (); -struct hugepage_info *hpi = &internal_conf->hugepage_info[0 ]; +struct hugepage_info *hpi = &platform_info->hugepage_info[0 ];struct hugepage_info *tmp_hpi; - internal_conf->num_hugepage_sizes =1 ; + platform_info->num_hugepage_sizes =1 ; tmp_hpi =open_shared_memory (eal_hugepage_info_path (), -sizeof (internal_conf->hugepage_info)); +sizeof (platform_info->hugepage_info));if (tmp_hpi ==NULL ) {EAL_LOG (ERR ,"Failed to open shared memory!" );return -1 ; } -memcpy (hpi, tmp_hpi,sizeof (internal_conf->hugepage_info)); +memcpy (hpi, tmp_hpi,sizeof (platform_info->hugepage_info)); -if (munmap (tmp_hpi,sizeof (internal_conf->hugepage_info)) <0 ) { +if (munmap (tmp_hpi,sizeof (platform_info->hugepage_info)) <0 ) {EAL_LOG (ERR ,"Failed to unmap shared memory!" );return -1 ; }
lib/eal/freebsd/eal_memory.c +9 -12
@@ -71,9 +71,8 @@ rte_eal_hugepage_init(void)uint64_t total_mem =0 ;void *addr;unsigned int i, j, seg_idx =0 ; -struct internal_config *internal_conf = -eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();/* get pointer to global configuration */ mcfg =rte_eal_get_configuration ()->mem_config;
@@ -113,13 +112,13 @@ rte_eal_hugepage_init(void) }/* map all hugepages and sort them */ -for (i =0 ; i < internal_conf->num_hugepage_sizes; i++) { +for (i =0 ; i < platform_info->num_hugepage_sizes; i++) {struct hugepage_info *hpi;rte_iova_t prev_end =0 ;uint64_t page_sz, mem_needed;unsigned int n_pages, max_pages; - hpi = &internal_conf->hugepage_info[i]; + hpi = &platform_info->hugepage_info[i]; page_sz = hpi->hugepage_sz; max_pages = hpi->num_pages[0 ]; mem_needed = RTE_ALIGN_CEIL(user_cfg->memory - total_mem,
@@ -285,15 +284,14 @@ attach_segment(const struct rte_memseg_list *msl, const struct rte_memseg *ms,int rte_eal_hugepage_attach (void ) { +struct eal_platform_info *platform_info =eal_get_platform_info ();struct hugepage_info *hpi;int fd_hugepage =-1 ;unsigned int i; -struct internal_config *internal_conf = -eal_get_internal_configuration (); - hpi = &internal_conf->hugepage_info[0 ]; + hpi = &platform_info->hugepage_info[0 ]; -for (i =0 ; i < internal_conf->num_hugepage_sizes; i++) { +for (i =0 ; i < platform_info->num_hugepage_sizes; i++) {const struct hugepage_info *cur_hpi = &hpi[i];struct attach_walk_args wa;
@@ -353,9 +351,8 @@ memseg_primary_init(void)struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config;int hpi_idx, msl_idx =0 ;struct rte_memseg_list *msl; -struct internal_config *internal_conf = -eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();/* no-huge does not need this at all */ if (user_cfg->no_hugetlbfs)
@@ -368,13 +365,13 @@ memseg_primary_init(void)*/ /* create memseg lists */ -for (hpi_idx =0 ; hpi_idx < (int ) internal_conf->num_hugepage_sizes; +for (hpi_idx =0 ; hpi_idx < (int ) platform_info->num_hugepage_sizes; hpi_idx++) {struct hugepage_info *hpi;uint64_t hugepage_sz;unsigned int n_segs; - hpi = &internal_conf->hugepage_info[hpi_idx]; + hpi = &platform_info->hugepage_info[hpi_idx]; hugepage_sz = hpi->hugepage_sz;/* no NUMA support on FreeBSD */
lib/eal/linux/eal.c +6 -8
@@ -412,20 +412,18 @@ rte_config_init(void)static void eal_hugedirs_unlock (void ) { +struct eal_platform_info *platform_info =eal_get_platform_info ();int i; -struct internal_config *internal_conf = -eal_get_internal_configuration (); -for (i =0 ; i <MAX_HUGEPAGE_SIZES ; i++) {/* skip uninitialized */ -if (internal_conf->hugepage_info[i].lock_descriptor <0 ) +if (platform_info->hugepage_info[i].lock_descriptor <0 )continue ;/* unlock hugepage file */ -flock (internal_conf->hugepage_info[i].lock_descriptor,LOCK_UN ); -close (internal_conf->hugepage_info[i].lock_descriptor); +flock (platform_info->hugepage_info[i].lock_descriptor,LOCK_UN ); +close (platform_info->hugepage_info[i].lock_descriptor);/* reset the field */ - internal_conf->hugepage_info[i].lock_descriptor =-1 ; + platform_info->hugepage_info[i].lock_descriptor =-1 ; } }
@@ -746,7 +744,7 @@ rte_eal_init(int argc, char **argv) goto err_out; }if (user_cfg->process_type ==RTE_PROC_PRIMARY && -eal_apply_hugepage_mem_sz_limits (internal_conf) <0 ) { +eal_apply_hugepage_mem_sz_limits () <0 ) {rte_eal_init_alert ("Cannot apply hugepage memory limits." ); rte_errno =EINVAL ; goto err_out;
lib/eal/linux/eal_hugepage_info.c +17 -20
@@ -453,8 +453,7 @@ hugepage_info_init(void)unsigned int reusable_pages;DIR *dir;struct dirent *dirent; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); dir =opendir (sys_dir_path);
@@ -475,7 +474,7 @@ hugepage_info_init(void)if (num_sizes >=MAX_HUGEPAGE_SIZES )break ; - hpi = &internal_conf->hugepage_info[num_sizes]; + hpi = &platform_info->hugepage_info[num_sizes]; hpi->hugepage_sz =rte_str_to_size (&dirent->d_name[dirent_start_len]);
@@ -546,17 +545,17 @@ hugepage_info_init(void)if (dirent !=NULL )return -1 ; - internal_conf->num_hugepage_sizes = num_sizes; + platform_info->num_hugepage_sizes = num_sizes;/* sort the page directory entries by size, largest to smallest */ -qsort (&internal_conf->hugepage_info[0 ], num_sizes, -sizeof (internal_conf->hugepage_info[0 ]), compare_hpi); +qsort (&platform_info->hugepage_info[0 ], num_sizes, +sizeof (platform_info->hugepage_info[0 ]), compare_hpi);/* now we have all info, check we have at least one valid size */ for (i =0 ; i < num_sizes; i++) {/* pages may no longer all be on socket 0, so check all */ unsigned int j, num_pages =0 ; -struct hugepage_info *hpi = &internal_conf->hugepage_info[i]; +struct hugepage_info *hpi = &platform_info->hugepage_info[i];for (j =0 ; j <RTE_MAX_NUMA_NODES ; j++) num_pages += hpi->num_pages[j];
@@ -578,8 +577,7 @@ eal_hugepage_info_init(void) {struct hugepage_info *hpi, *tmp_hpi;unsigned int i; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (hugepage_info_init () <0 )
@@ -589,26 +587,26 @@ eal_hugepage_info_init(void)if (user_cfg->no_shconf)return 0 ; - hpi = &internal_conf->hugepage_info[0 ]; + hpi = &platform_info->hugepage_info[0 ]; tmp_hpi =create_shared_memory (eal_hugepage_info_path (), -sizeof (internal_conf->hugepage_info)); +sizeof (platform_info->hugepage_info));if (tmp_hpi ==NULL ) {EAL_LOG (ERR ,"Failed to create shared memory!" );return -1 ; } -memcpy (tmp_hpi, hpi,sizeof (internal_conf->hugepage_info)); +memcpy (tmp_hpi, hpi,sizeof (platform_info->hugepage_info));/* we've copied file descriptors along with everything else, but they * will be invalid in secondary process, so overwrite them */ -for (i =0 ; i <RTE_DIM (internal_conf->hugepage_info); i++) { +for (i =0 ; i <RTE_DIM (platform_info->hugepage_info); i++) {struct hugepage_info *tmp = &tmp_hpi[i]; tmp->lock_descriptor =-1 ; } -if (munmap (tmp_hpi,sizeof (internal_conf->hugepage_info)) <0 ) { +if (munmap (tmp_hpi,sizeof (platform_info->hugepage_info)) <0 ) {EAL_LOG (ERR ,"Failed to unmap shared memory!" );return -1 ; }
@@ -617,21 +615,20 @@ eal_hugepage_info_init(void)int eal_hugepage_info_read (void ) { -struct internal_config *internal_conf = -eal_get_internal_configuration (); -struct hugepage_info *hpi = &internal_conf->hugepage_info[0 ]; +struct eal_platform_info *platform_info =eal_get_platform_info (); +struct hugepage_info *hpi = &platform_info->hugepage_info[0 ];struct hugepage_info *tmp_hpi; tmp_hpi =open_shared_memory (eal_hugepage_info_path (), -sizeof (internal_conf->hugepage_info)); +sizeof (platform_info->hugepage_info));if (tmp_hpi ==NULL ) {EAL_LOG (ERR ,"Failed to open shared memory!" );return -1 ; } -memcpy (hpi, tmp_hpi,sizeof (internal_conf->hugepage_info)); +memcpy (hpi, tmp_hpi,sizeof (platform_info->hugepage_info)); -if (munmap (tmp_hpi,sizeof (internal_conf->hugepage_info)) <0 ) { +if (munmap (tmp_hpi,sizeof (platform_info->hugepage_info)) <0 ) {EAL_LOG (ERR ,"Failed to unmap shared memory!" );return -1 ; }
lib/eal/linux/eal_memalloc.c +12 -15
@@ -966,9 +966,8 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, size_t page_sz,#endif struct alloc_walk_param wa;struct hugepage_info *hi =NULL ; -struct internal_config *internal_conf = -eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();memset (&wa,0 ,sizeof (wa));
@@ -976,10 +975,10 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, size_t page_sz,if (user_cfg->legacy_mem)return -1 ; -for (i =0 ; i < (int )RTE_DIM (internal_conf->hugepage_info); i++) { +for (i =0 ; i < (int )RTE_DIM (platform_info->hugepage_info); i++) {if (page_sz == - internal_conf->hugepage_info[i].hugepage_sz) { - hi = &internal_conf->hugepage_info[i]; + platform_info->hugepage_info[i].hugepage_sz) { + hi = &platform_info->hugepage_info[i];break ; } }
@@ -1036,9 +1035,8 @@ int eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs) { int seg, ret = 0; -struct internal_config *internal_conf = -eal_get_internal_configuration ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();/* dynamic free not supported in legacy mode */ if (user_cfg->legacy_mem)
@@ -1059,13 +1057,13 @@ eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs)memset (&wa,0 ,sizeof (wa)); -for (i =0 ; i < (int )RTE_DIM (internal_conf->hugepage_info); +for (i =0 ; i < (int )RTE_DIM (platform_info->hugepage_info); i++) { - hi = &internal_conf->hugepage_info[i]; + hi = &platform_info->hugepage_info[i];if (cur->hugepage_sz == hi->hugepage_sz)break ; } -if (i == (int )RTE_DIM (internal_conf->hugepage_info)) { +if (i == (int )RTE_DIM (platform_info->hugepage_info)) {EAL_LOG (ERR ,"Can't find relevant hugepage_info entry" ); ret =-1 ;continue ;
@@ -1329,11 +1327,10 @@ sync_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) {struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config;struct rte_memseg_list *primary_msl, *local_msl; +struct eal_platform_info *platform_info =eal_get_platform_info ();struct hugepage_info *hi =NULL ;unsigned int i;int msl_idx; -struct internal_config *internal_conf = -eal_get_internal_configuration ();if (msl->external)return 0 ;
@@ -1342,12 +1339,12 @@ sync_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) primary_msl = &mcfg->memsegs[msl_idx]; local_msl = &local_memsegs[msl_idx]; -for (i =0 ; i <RTE_DIM (internal_conf->hugepage_info); i++) { +for (i =0 ; i <RTE_DIM (platform_info->hugepage_info); i++) {uint64_t cur_sz = - internal_conf->hugepage_info[i].hugepage_sz; + platform_info->hugepage_info[i].hugepage_sz;uint64_t msl_sz = primary_msl->page_sz;if (msl_sz == cur_sz) { - hi = &internal_conf->hugepage_info[i]; + hi = &platform_info->hugepage_info[i];break ; } }
lib/eal/linux/eal_memory.c +29 -35
194 lines not on this page · raw message
lib/eal/windows/eal.c +1 -3
@@ -158,8 +158,6 @@ rte_eal_init(int argc, char **argv) {int i, fctret, bscan;const struct rte_config *config =rte_eal_get_configuration (); -struct internal_config *internal_conf = -eal_get_internal_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration ();bool has_phys_addr;enum rte_iova_mode iova_mode;
@@ -230,7 +228,7 @@ rte_eal_init(int argc, char **argv) goto err_out; }if (!user_cfg->no_hugetlbfs && -eal_apply_hugepage_mem_sz_limits (internal_conf) <0 ) { +eal_apply_hugepage_mem_sz_limits () <0 ) {rte_eal_init_alert ("Cannot apply hugepage memory limits" ); rte_errno =EINVAL ; goto err_out;
lib/eal/windows/eal_hugepages.c +3 -4
@@ -62,12 +62,11 @@ hugepage_info_init(void)struct hugepage_info *hpi;unsigned int socket_id;int ret =0 ; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();/* Only one hugepage size available on Windows. */ - internal_conf->num_hugepage_sizes =1 ; - hpi = &internal_conf->hugepage_info[0 ]; + platform_info->num_hugepage_sizes =1 ; + hpi = &platform_info->hugepage_info[0 ]; hpi->hugepage_sz =GetLargePageMinimum ();if (hpi->hugepage_sz ==0 )
lib/eal/windows/eal_memalloc.c +12 -14
@@ -33,7 +33,7 @@ eal_memalloc_get_seg_fd_offset(int list_idx, int seg_idx, size_t *offset)static int alloc_seg (struct rte_memseg *ms,void *requested_addr,int socket_id, -struct hugepage_info *hi) +const struct hugepage_info *hi) {HANDLE current_process;unsigned int numa_node;
@@ -166,7 +166,7 @@ free_seg(struct rte_memseg *ms) }struct alloc_walk_param { -struct hugepage_info *hi; +const struct hugepage_info *hi;struct rte_memseg **ms;size_t page_sz;unsigned int segs_allocated;
@@ -273,7 +273,7 @@ alloc_seg_walk(const struct rte_memseg_list *msl, void *arg) }struct free_walk_param { -struct hugepage_info *hi; +const struct hugepage_info *hi;struct rte_memseg *ms; }; static int
@@ -313,9 +313,8 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs,unsigned int i;int ret =-1 ;struct alloc_walk_param wa; -struct hugepage_info *hi =NULL ; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct hugepage_info *hi =NULL ; +const struct eal_platform_info *platform_info =eal_get_platform_info ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (user_cfg->legacy_mem) {
@@ -323,8 +322,8 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs,return -ENOTSUP ; } -for (i =0 ; i < internal_conf->num_hugepage_sizes; i++) { -struct hugepage_info *hpi = &internal_conf->hugepage_info[i]; +for (i =0 ; i < platform_info->num_hugepage_sizes; i++) { +const struct hugepage_info *hpi = &platform_info->hugepage_info[i];if (page_sz == hpi->hugepage_sz) { hi = hpi;break ;
@@ -368,8 +367,7 @@ int eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs) { int seg, ret = 0; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_platform_info *platform_info =eal_get_platform_info ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* dynamic free not supported in legacy mode */
@@ -378,7 +376,7 @@ eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs)for (seg =0 ; seg < n_segs; seg++) {struct rte_memseg *cur = ms[seg]; -struct hugepage_info *hi =NULL ; +const struct hugepage_info *hi =NULL ;struct free_walk_param wa;size_t i;int walk_res;
@@ -392,12 +390,12 @@ eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs)memset (&wa,0 ,sizeof (wa)); -for (i =0 ; i <RTE_DIM (internal_conf->hugepage_info); i++) { - hi = &internal_conf->hugepage_info[i]; +for (i =0 ; i <RTE_DIM (platform_info->hugepage_info); i++) { + hi = &platform_info->hugepage_info[i];if (cur->hugepage_sz == hi->hugepage_sz)break ; } -if (i ==RTE_DIM (internal_conf->hugepage_info)) { +if (i ==RTE_DIM (platform_info->hugepage_info)) {EAL_LOG (ERR ,"Can't find relevant hugepage_info entry" ); ret =-1 ;continue ;
Signature · 1 line
2.53.0
PATCH v2 11/39 eal: move runtime state to appropriate structure
In reply to Bruce RichardsonRemove the last of the fields from the internal config to the runtime state structure, allowing us to remove the general internal_config struct and its reference function.
--- lib/eal/common/eal_common_config.c | 10 ---------- lib/eal/common/eal_common_mcfg.c | 5 ++--- lib/eal/common/eal_common_memzone.c | 4 +++- lib/eal/common/eal_common_options.c | 18 +++++++++--------- lib/eal/common/eal_common_proc.c | 6 +++--- lib/eal/common/eal_common_thread.c | 8 ++++---- lib/eal/common/eal_internal_cfg.h | 8 +------- lib/eal/common/eal_options.h | 2 +- lib/eal/common/eal_private.h | 9 --------- lib/eal/freebsd/eal.c | 7 +++---- lib/eal/linux/eal.c | 7 +++---- 11 files changed, 29 insertions(+), 55 deletions(-)
lib/eal/common/eal_common_config.c +0 -10
@@ -37,9 +37,6 @@ static struct eal_platform_info eal_platform_info;/* internal runtime configuration */ static struct eal_runtime_state eal_runtime_state; -/* internal configuration */ -static struct internal_config internal_config; -RTE_EXPORT_SYMBOL (rte_eal_get_runtime_dir) const char *rte_eal_get_runtime_dir (void )
@@ -66,13 +63,6 @@ rte_eal_get_configuration(void)return &rte_config; } -/* Return a pointer to the internal configuration structure */ -struct internal_config * -eal_get_internal_configuration (void ) -{ -return &internal_config; -} -/* Return a pointer to the user configuration structure */ struct eal_user_cfg *eal_get_user_configuration (void )
lib/eal/common/eal_common_mcfg.c +2 -3
@@ -15,14 +15,13 @@ eal_mcfg_complete(void) {struct rte_config *cfg =rte_eal_get_configuration ();struct rte_mem_config *mcfg = cfg->mem_config; -struct internal_config *internal_conf = -eal_get_internal_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* ALL shared mem_config related INIT DONE */ if (cfg->process_type ==RTE_PROC_PRIMARY ) mcfg->magic =RTE_MAGIC ; - internal_conf->init_complete =1 ; + runtime_state->init_complete =1 ; }void
lib/eal/common/eal_common_memzone.c +3 -1
@@ -20,6 +20,7 @@#include "malloc_heap.h" #include "malloc_elem.h" +#include "eal_internal_cfg.h" #include "eal_private.h" #include "eal_memcfg.h"
@@ -30,9 +31,10 @@ RTE_EXPORT_SYMBOL(rte_memzone_max_set)int rte_memzone_max_set (size_t max) { +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct rte_mem_config *mcfg; -if (eal_get_internal_configuration ()->init_complete >0 ) { +if (runtime_state->init_complete >0 ) {EAL_LOG (ERR ,"Max memzone cannot be set after EAL init" );return -1 ; }
lib/eal/common/eal_common_options.c +9 -9
@@ -507,7 +507,7 @@ eal_get_hugefile_prefix(void) }void -eal_reset_internal_config (struct internal_config *internal_cfg) +eal_reset_internal_config (void ) {struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();
@@ -563,8 +563,8 @@ eal_reset_internal_config(struct internal_config *internal_cfg) user_cfg->no_telemetry = false; user_cfg->iova_mode =RTE_IOVA_DC ; user_cfg->user_mbuf_pool_ops_name =NULL ; -CPU_ZERO (&internal_cfg->ctrl_cpuset); - internal_cfg->init_complete =0 ; +CPU_ZERO (&runtime_state->ctrl_cpuset); + runtime_state->init_complete =0 ; user_cfg->max_simd_bitwidth.bitwidth =RTE_VECT_DEFAULT_SIMD_BITWIDTH ; user_cfg->max_simd_bitwidth.forced =0 ; }
@@ -2076,7 +2076,6 @@ eal_parse_huge_worker_stack(const char *arg)int eal_parse_args (void ) { -struct internal_config *int_cfg =eal_get_internal_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct rte_config *rte_cfg =rte_eal_get_configuration ();bool remap_lcores = (args.remap_lcore_ids !=NULL );
@@ -2449,7 +2448,7 @@ eal_parse_args(void) }#endif -if (eal_adjust_config (int_cfg) !=0 ) { +if (eal_adjust_config () !=0 ) {EAL_LOG (ERR ,"Invalid configuration" );return -1 ; }
@@ -2458,9 +2457,10 @@ eal_parse_args(void) }static void -compute_ctrl_threads_cpuset (struct internal_config *internal_cfg) +compute_ctrl_threads_cpuset (void ) { -rte_cpuset_t *cpuset = &internal_cfg->ctrl_cpuset; +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +rte_cpuset_t *cpuset = &runtime_state->ctrl_cpuset;rte_cpuset_t default_set;unsigned int lcore_id;
@@ -2501,7 +2501,7 @@ eal_cleanup_config(const struct eal_user_cfg *user_cfg) }int -eal_adjust_config (struct internal_config *internal_cfg) +eal_adjust_config (void ) {struct eal_user_cfg *user_cfg =eal_get_user_configuration ();int i;
@@ -2509,7 +2509,7 @@ eal_adjust_config(struct internal_config *internal_cfg)if (user_cfg->process_type ==RTE_PROC_AUTO ) user_cfg->process_type =eal_proc_type_detect (); -compute_ctrl_threads_cpuset (internal_cfg); +compute_ctrl_threads_cpuset ();/* if no memory amounts were requested, this will result in 0 and * will be overridden later, right after eal_hugepage_info_init() */
lib/eal/common/eal_common_proc.c +3 -3
@@ -359,8 +359,8 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s)struct action_entry *entry;struct rte_mp_msg *msg = &m->msg;rte_mp_t action =NULL ; -const struct internal_config *internal_conf = -eal_get_internal_configuration (); +const struct eal_runtime_state *runtime_state = +eal_get_runtime_state ();EAL_LOG (DEBUG ,"msg: %s" , msg->name);
@@ -397,7 +397,7 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s)pthread_mutex_unlock (&mp_mutex_action);if (!action) { -if (m->type ==MP_REQ && !internal_conf->init_complete) { +if (m->type ==MP_REQ && !runtime_state->init_complete) {/* if this is a request, and init is not yet complete, * and callback wasn't registered, we should tell the * requester to ignore our existence because we're not
lib/eal/common/eal_common_thread.c +4 -4
@@ -234,9 +234,8 @@ struct control_thread_params {static int control_thread_init (void *arg) { -struct internal_config *internal_conf = -eal_get_internal_configuration (); -rte_cpuset_t *cpuset = &internal_conf->ctrl_cpuset; +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +rte_cpuset_t *cpuset = &runtime_state->ctrl_cpuset;struct control_thread_params *params = arg;__rte_thread_init (rte_lcore_id (), cpuset);
@@ -354,11 +353,12 @@ RTE_EXPORT_SYMBOL(rte_thread_register)int rte_thread_register (void ) { +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();unsigned int lcore_id;rte_cpuset_t cpuset;/* EAL init flushes all lcores, we can't register before. */ -if (eal_get_internal_configuration ()->init_complete !=1 ) { +if (runtime_state->init_complete !=1 ) {EAL_LOG (DEBUG ,"Called %s before EAL init." , __func__); rte_errno =EINVAL ;return -1 ;
lib/eal/common/eal_internal_cfg.h +1 -7
@@ -110,12 +110,6 @@ struct eal_platform_info {struct eal_runtime_state {uint64_t hugepage_mem_sz_limits[MAX_HUGEPAGE_SIZES ];/**< default max memory per hugepage size */ -}; - -/** -* internal configuration -*/ -struct internal_config {rte_cpuset_t ctrl_cpuset;/**< cpuset for ctrl threads */ volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */
@@ -124,6 +118,6 @@ struct internal_config {struct eal_user_cfg *eal_get_user_configuration (void );struct eal_platform_info *eal_get_platform_info (void );struct eal_runtime_state *eal_get_runtime_state (void ); -void eal_reset_internal_config (struct internal_config *internal_cfg); +void eal_reset_internal_config (void );#endif /* EAL_INTERNAL_CFG_H */
lib/eal/common/eal_options.h +1 -1
@@ -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 (struct internal_config *internal_cfg); +int eal_adjust_config (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 );
lib/eal/common/eal_private.h +0 -9
@@ -726,15 +726,6 @@ eal_mem_set_dump(void *virt, size_t size, bool dump);int eal_set_runtime_dir (const char *run_dir); -/** -* Get the internal configuration structure. -* -* @return -* A pointer to the internal configuration structure. -*/ -struct internal_config * -eal_get_internal_configuration (void ); -/** * Get the current value of the rte_application_usage pointer *
lib/eal/freebsd/eal.c +3 -4
@@ -407,9 +407,8 @@ rte_eal_init(int argc, char **argv)char cpuset[RTE_CPU_AFFINITY_STR_LEN ];char thread_name[RTE_THREAD_NAME_SIZE ];const struct rte_config *config =rte_eal_get_configuration (); -struct internal_config *internal_conf = -eal_get_internal_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();bool has_phys_addr;enum rte_iova_mode iova_mode;
@@ -454,7 +453,7 @@ rte_eal_init(int argc, char **argv) goto err_out; } -eal_reset_internal_config (internal_conf); +eal_reset_internal_config ();if (rte_eal_cpu_init () <0 ) {rte_eal_init_alert ("Cannot detect lcores." );
@@ -751,7 +750,7 @@ rte_eal_init(int argc, char **argv)if (rte_eal_process_type () ==RTE_PROC_PRIMARY && !user_cfg->no_telemetry) {if (rte_telemetry_init (rte_eal_get_runtime_dir (),rte_version (), - &internal_conf->ctrl_cpuset) !=0 ) + &runtime_state->ctrl_cpuset) !=0 ) goto err_out; }
lib/eal/linux/eal.c +3 -4
@@ -569,9 +569,8 @@ rte_eal_init(int argc, char **argv)char thread_name[RTE_THREAD_NAME_SIZE ];bool phys_addrs;const struct rte_config *config =rte_eal_get_configuration (); -struct internal_config *internal_conf = -eal_get_internal_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* first check if we have been run before */ if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
@@ -614,7 +613,7 @@ rte_eal_init(int argc, char **argv) goto err_out; } -eal_reset_internal_config (internal_conf); +eal_reset_internal_config ();if (rte_eal_cpu_init () <0 ) {rte_eal_init_alert ("Cannot detect lcores." );
@@ -924,7 +923,7 @@ rte_eal_init(int argc, char **argv)if (rte_eal_process_type () ==RTE_PROC_PRIMARY && !user_cfg->no_telemetry) {if (rte_telemetry_init (rte_eal_get_runtime_dir (),rte_version (), - &internal_conf->ctrl_cpuset) !=0 ) + &runtime_state->ctrl_cpuset) !=0 ) goto err_out; }
Signature · 1 line
2.53.0
PATCH v2 12/39 eal: record details of all cpus in platform info
In reply to Bruce RichardsonPopulate the platform info structure with details of all the cores on the system.
--- lib/eal/common/eal_common_lcore.c | 19 ++++++++++++++ lib/eal/common/eal_internal_cfg.h | 16 ++++++++++-- lib/eal/common/eal_private.h | 8 ++++++ lib/eal/freebsd/eal_lcore.c | 16 ++++++++---- lib/eal/linux/eal_lcore.c | 43 +++++++++++++++++++++++++++++++ lib/eal/windows/eal_lcore.c | 6 +++++ 6 files changed, 101 insertions(+), 7 deletions(-)
lib/eal/common/eal_common_lcore.c +19 -0
@@ -153,6 +153,7 @@ rte_eal_cpu_init(void) {/* pointer to global configuration */ struct rte_config *config =rte_eal_get_configuration (); +struct eal_platform_info *platform_info =eal_get_platform_info ();unsigned lcore_id;unsigned count =0 ;unsigned int socket_id, prev_socket_id;
@@ -162,6 +163,24 @@ rte_eal_cpu_init(void)int lcore_to_socket_id[RTE_MAX_LCORE ] = {0 };#endif +/* allocate cpu_info for all CPUs visible to the OS */ + platform_info->cpu_count =eal_cpu_max (); + platform_info->cpu_info =calloc (platform_info->cpu_count, +sizeof (*platform_info->cpu_info)); +if (platform_info->cpu_info ==NULL ) { +EAL_LOG (ERR ,"Cannot allocate cpu_info array" ); +return -1 ; + } + +/* populate cpu_info with hardware topology for all detected CPUs */ +for (size_t cpu_id =0 ; cpu_id < platform_info->cpu_count; cpu_id++) { +if (eal_cpu_detected (cpu_id) ==0 ) +continue ; + platform_info->cpu_info[cpu_id].detected = true; + platform_info->cpu_info[cpu_id].numa_id =eal_cpu_socket_id (cpu_id); + platform_info->cpu_info[cpu_id].core_id =eal_cpu_core_id (cpu_id); + } +/* * Parse the maximum set of logical cores, detect the subset of running * ones and enable them by default.
lib/eal/common/eal_internal_cfg.h +14 -2
@@ -94,10 +94,22 @@ struct eal_user_cfg { };/** -* Discovered information about cores, memory, etc. on the system. -* Immutable after initialization, so no need for atomic types or locks. +* Hardware facts about a single physical CPU, populated during CPU discovery. +* Indexed by physical CPU ID (not DPDK lcore ID). +*/ +struct eal_cpu_info { +bool detected;/**< true if this CPU ID is valid and visible to the OS */ +unsigned int numa_id;/**< NUMA node this CPU belongs to */ +unsigned int core_id;/**< physical core number on its NUMA node */ +}; + +/** +* Discovered information about the system hardware. +* Immutable after discovery. */ struct eal_platform_info { +size_t cpu_count;/**< number of entries in cpu_info[] */ +struct eal_cpu_info *cpu_info;/**< per-physical-CPU hardware facts */ uint8_t num_hugepage_sizes;/**< how many sizes on this system */ struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES ]; };
lib/eal/common/eal_private.h +8 -0
@@ -404,6 +404,14 @@ unsigned eal_cpu_core_id(unsigned lcore_id);*/ int eal_cpu_detected (unsigned lcore_id); +/** +* Get the number of CPU IDs to allocate for platform CPU info. +* Returns max_cpu_id + 1: all valid CPU IDs are in [0, eal_cpu_max()). +* +* This function is private to the EAL. +*/ +size_t eal_cpu_max (void ); +/** * Set TSC frequency from precise value or estimation *
lib/eal/freebsd/eal_lcore.c +11 -5
@@ -2,7 +2,10 @@* Copyright(c) 2010-2014 Intel Corporation */ +#include <sched.h> +#include <errno.h> #include <unistd.h> +#include <string.h> #include <sys/sysctl.h> #include <rte_log.h>
@@ -21,18 +24,21 @@ eal_cpu_core_id(__rte_unused unsigned lcore_id)return 0 ; } -static int -eal_get_ncpus (void ) +size_t +eal_cpu_max (void ) {static int ncpu =-1 ;int mib[2 ] = {CTL_HW ,HW_NCPU };size_t len =sizeof (ncpu);if (ncpu <0 ) { -sysctl (mib,2 , &ncpu, &len,NULL ,0 ); +if (sysctl (mib,2 , &ncpu, &len,NULL ,0 ) !=0 ) { +EAL_LOG (ERR ,"sysctl failed to get number of CPUs: %s" ,strerror (errno)); +return CPU_SETSIZE ;/* fallback to CPU_SETSIZE */ + }EAL_LOG (INFO ,"Sysctl reports %d cpus" , ncpu); } -return ncpu; +return (size_t )ncpu; }unsigned
@@ -47,6 +53,6 @@ eal_cpu_socket_id(__rte_unused unsigned cpu_id)int eal_cpu_detected (unsigned lcore_id) { -const unsigned ncpus =eal_get_ncpus (); +const unsigned int ncpus =eal_cpu_max ();return lcore_id < ncpus; }
lib/eal/linux/eal_lcore.c +43 -0
62 lines not on this page · raw message
lib/eal/windows/eal_lcore.c +6 -0
@@ -273,6 +273,12 @@ eal_cpu_core_id(unsigned int lcore_id)return cpu_map.lcores[lcore_id].core_id; } +size_t +eal_cpu_max (void ) +{ +return (size_t )cpu_map.lcore_count; +} +unsigned int eal_socket_numa_node (unsigned int socket_id) {
Signature · 1 line
2.53.0
PATCH v2 13/39 eal: use platform info for lcore lookups
In reply to Bruce RichardsonRather than storing the lcore and numa fields in the lcore_config structure - which is a structure indexed by logical core id, rather than physical cpu - use the platform info struct as the one source of truth for cpu topology info.
--- lib/eal/common/eal_common_lcore.c | 38 +++++++++++++++++++----------- lib/eal/common/eal_common_thread.c | 37 ++++++++++++----------------- lib/eal/common/eal_private.h | 9 +++++-- 3 files changed, 46 insertions(+), 38 deletions(-)
lib/eal/common/eal_common_lcore.c +24 -14
@@ -51,6 +51,9 @@ int rte_lcore_index(int lcore_id)RTE_EXPORT_SYMBOL (rte_lcore_to_cpu_id) int rte_lcore_to_cpu_id(int lcore_id) { +const struct eal_platform_info *platform_info =eal_get_platform_info (); +unsigned int cpu; +if (unlikely (lcore_id >=RTE_MAX_LCORE ))return -1 ;
@@ -61,7 +64,11 @@ int rte_lcore_to_cpu_id(int lcore_id) lcore_id = (int )rte_lcore_id (); } -return lcore_config[lcore_id].core_id; +for (cpu =0 ; cpu <CPU_SETSIZE && cpu < platform_info->cpu_count; cpu++) { +if (CPU_ISSET (cpu, &lcore_config[lcore_id].cpuset)) +return (int )platform_info->cpu_info[cpu].core_id; + } +return -1 ; }RTE_EXPORT_SYMBOL (rte_lcore_cpuset)
@@ -127,7 +134,10 @@ RTE_EXPORT_SYMBOL(rte_lcore_to_socket_id)unsigned int rte_lcore_to_socket_id (unsigned int lcore_id) { -return lcore_config[lcore_id].numa_id; +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return (unsigned int )SOCKET_ID_ANY ; + +return (unsigned int )eal_cpuset_socket_id (&lcore_config[lcore_id].cpuset); } static int
@@ -191,16 +201,16 @@ rte_eal_cpu_init(void)/* init cpuset for per lcore config */ CPU_ZERO (&lcore_config[lcore_id].cpuset); -/* find socket first */ - socket_id =eal_cpu_socket_id (lcore_id); - lcore_to_socket_id[lcore_id] = socket_id; -if (eal_cpu_detected (lcore_id) ==0 ) { config->lcore_role[lcore_id] =ROLE_OFF ; lcore_config[lcore_id].core_index =-1 ;continue ; } +/* find socket first */ + socket_id = platform_info->cpu_info[lcore_id].numa_id; + lcore_to_socket_id[lcore_id] = socket_id; +/* By default, lcore 1:1 map to cpu id */ CPU_SET (lcore_id, &lcore_config[lcore_id].cpuset);
@@ -210,22 +220,22 @@ rte_eal_cpu_init(void)/* By default, each detected core is enabled */ config->lcore_role[lcore_id] =ROLE_RTE ; lcore_config[lcore_id].core_role =ROLE_RTE ; - lcore_config[lcore_id].core_id =eal_cpu_core_id (lcore_id); - lcore_config[lcore_id].numa_id = socket_id;EAL_LOG (DEBUG ,"Detected lcore %u as " "core %u on NUMA node %u" , - lcore_id, lcore_config[lcore_id].core_id, - lcore_config[lcore_id].numa_id); + lcore_id, + platform_info->cpu_info[lcore_id].core_id, + platform_info->cpu_info[lcore_id].numa_id); count++; }for (; lcore_id <CPU_SETSIZE ; lcore_id++) {if (eal_cpu_detected (lcore_id) ==0 )continue ; - socket_id =eal_cpu_socket_id (lcore_id); - lcore_to_socket_id[lcore_id] = socket_id; +if (unlikely (lcore_id >= platform_info->cpu_count)) +break ; + lcore_to_socket_id[lcore_id] = platform_info->cpu_info[lcore_id].numa_id;EAL_LOG (DEBUG ,"Skipped lcore %u as core %u on NUMA node %u" , - lcore_id,eal_cpu_core_id (lcore_id), - socket_id); + lcore_id, platform_info->cpu_info[lcore_id].core_id, + platform_info->cpu_info[lcore_id].numa_id); }/* Set the count of enabled logical cores of the EAL configuration */
lib/eal/common/eal_common_thread.c +15 -22
@@ -37,30 +37,25 @@ unsigned rte_socket_id(void)return RTE_PER_LCORE (_numa_id); } -static int -eal_cpuset_socket_id (rte_cpuset_t *cpusetp) +int +eal_cpuset_socket_id (const rte_cpuset_t *cpusetp) { -unsigned cpu =0 ; +const struct eal_platform_info *platform_info =eal_get_platform_info ();int socket_id =SOCKET_ID_ANY ; -int sid;if (cpusetp ==NULL )return SOCKET_ID_ANY ; -do { +for (unsigned int cpu =0 ; cpu <CPU_SETSIZE && cpu < platform_info->cpu_count; cpu++) {if (!CPU_ISSET (cpu, cpusetp))continue ; +int sid = (int )platform_info->cpu_info[cpu].numa_id;if (socket_id ==SOCKET_ID_ANY ) - socket_id =eal_cpu_socket_id (cpu); - - sid =eal_cpu_socket_id (cpu); -if (socket_id != sid) { - socket_id =SOCKET_ID_ANY ; -break ; - } - - }while (++cpu <CPU_SETSIZE ); + socket_id = sid; +else if (socket_id != sid) +return SOCKET_ID_ANY ; + }return socket_id; }
@@ -70,19 +65,17 @@ thread_update_affinity(rte_cpuset_t *cpusetp) {unsigned int lcore_id =rte_lcore_id (); -/* store numa_id in TLS for quick access */ -RTE_PER_LCORE (_numa_id) = -eal_cpuset_socket_id (cpusetp); -/* store cpuset in TLS for quick access */ -memmove (&RTE_PER_LCORE (_cpuset), cpusetp, -sizeof (rte_cpuset_t)); +memmove (&RTE_PER_LCORE (_cpuset), cpusetp,sizeof (rte_cpuset_t));if (lcore_id != (unsigned )LCORE_ID_ANY ) { -/* EAL thread will update lcore_config */ - lcore_config[lcore_id].numa_id =RTE_PER_LCORE (_numa_id); +/* EAL thread: update lcore_config cpuset first then find numa based on that */ memmove (&lcore_config[lcore_id].cpuset, cpusetp,sizeof (rte_cpuset_t)); +RTE_PER_LCORE (_numa_id) =rte_lcore_to_socket_id (lcore_id); + }else { +/* Non-EAL thread: preserve SOCKET_ID_ANY if cpuset spans NUMA nodes. */ +RTE_PER_LCORE (_numa_id) = (unsigned int )eal_cpuset_socket_id (cpusetp); } }
lib/eal/common/eal_private.h +7 -2
@@ -31,8 +31,6 @@ struct lcore_config {volatile int ret;/**< return value of function */ volatile RTE_ATOMIC (enum rte_lcore_state_t ) state;/**< lcore state */ -unsigned int numa_id;/**< NUMA node ID for this lcore */ -unsigned int core_id;/**< core number on socket for this lcore */ int core_index;/**< relative index, starting from 0 */ uint8_t core_role;/**< role of core eg: OFF, RTE, SERVICE */
@@ -96,6 +94,13 @@ int eal_collate_args(int argc, char **argv);*/ char *eal_cpuset_to_str (const rte_cpuset_t *cpuset); +/** +* Resolve a cpuset to a NUMA socket id. +* +* Returns SOCKET_ID_ANY if cpuset is NULL, empty, or spans multiple sockets. +*/ +int eal_cpuset_socket_id (const rte_cpuset_t *cpuset); +/** * Initialize the memzone subsystem (private to eal). *
Signature · 1 line
2.53.0
PATCH v2 14/39 eal: add macro for lowest set CPU bit in a set
In reply to Bruce RichardsonFreeBSD supports the CPU_FFS macro as part of the regular cpuset functions. Add this as RTE_CPU_FFS for all OS's.
From "man CPU_FFS" on FreeBSD 15:
The CPU_FFS() macro returns the 1-index of the first (lowest) CPU in cpuset, or zero if cpuset is empty. Like with ffs(3), to use the non- zero result of CPU_FFS() as a cpu_idx index parameter to any other cpuset(9) macro, you must subtract one from the result.
--- lib/eal/freebsd/include/rte_os.h | 2 ++ lib/eal/linux/include/rte_os.h | 10 ++++++++++ lib/eal/windows/include/rte_os.h | 1 + lib/eal/windows/include/sched.h | 10 ++++++++++ 4 files changed, 23 insertions(+)
lib/eal/freebsd/include/rte_os.h +2 -0
@@ -75,4 +75,6 @@ typedef cpuset_t rte_cpuset_t;#endif /* RTE_EAL_FREEBSD_CPUSET_LEGACY */ +#define RTE_CPU_FFS CPU_FFS +#endif /* _RTE_OS_H_ */
lib/eal/linux/include/rte_os.h +10 -0
@@ -41,6 +41,16 @@ typedef cpu_set_t rte_cpuset_t;RTE_CPU_FILL (&tmp); \CPU_XOR (dst, &tmp, src); \ } while (0) + +static inline int +rte_cpu_ffs (const rte_cpuset_t *s) +{ +for (unsigned int _i =0 ; _i <CPU_SETSIZE ; _i++) +if (CPU_ISSET (_i, s)) +return (int )(_i +1 ); +return 0 ; +} +#define RTE_CPU_FFS (s) rte_cpu_ffs(s)#endif #endif /* _RTE_OS_H_ */
lib/eal/windows/include/rte_os.h +1 -0
@@ -49,6 +49,7 @@ struct { \#define RTE_CPU_OR (dst, src1, src2) CPU_OR(dst, src1, src2)#define RTE_CPU_FILL (set) CPU_FILL(set)#define RTE_CPU_NOT (dst, src) CPU_NOT(dst, src) +#define RTE_CPU_FFS (s) CPU_FFS(s)/* This is an exception without "rte_" prefix, because Windows does have * ssize_t, but it's defined in <windows.h> which we avoid to expose.
lib/eal/windows/include/sched.h +10 -0
@@ -86,6 +86,16 @@ do { \ (dst)->_bits[_i] = (src)->_bits[_i] ^-1LL ; \ }while (0 ) +static inline int +cpu_ffs (const rte_cpuset_t *s) +{ +for (unsigned int _i =0 ; _i <CPU_SETSIZE ; _i++) +if (CPU_ISSET (_i, s)) +return (int )(_i +1 ); +return 0 ; +} +#define CPU_FFS (s) cpu_ffs(s) + #ifdef __cplusplus }#endif
Signature · 1 line
2.53.0
PATCH v2 15/39 eal: store lcore configuration in runtime data
In reply to Bruce RichardsonRemove the standalone lcore_config array and instead manage the lcore configuration as part of the runtime state.
--- lib/eal/common/eal_common_launch.c | 25 +++++++++------ lib/eal/common/eal_common_lcore.c | 49 ++++++++++++++++++----------- lib/eal/common/eal_common_options.c | 37 ++++++++++++---------- lib/eal/common/eal_common_thread.c | 24 ++++++++------ lib/eal/common/eal_internal_cfg.h | 19 +++++++++++ lib/eal/common/eal_private.h | 21 ------------- lib/eal/common/rte_service.c | 8 ++--- lib/eal/freebsd/eal.c | 23 ++++++-------- lib/eal/linux/eal.c | 24 +++++++------- lib/eal/unix/eal_unix_thread.c | 11 ++++--- lib/eal/windows/eal.c | 22 ++++++------- lib/eal/windows/eal_thread.c | 11 ++++--- 12 files changed, 147 insertions(+), 127 deletions(-)
lib/eal/common/eal_common_launch.c +16 -9
@@ -20,11 +20,13 @@ RTE_EXPORT_SYMBOL(rte_eal_wait_lcore)int rte_eal_wait_lcore (unsigned worker_id) { -while (rte_atomic_load_explicit (&lcore_config[worker_id].state, +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); + +while (rte_atomic_load_explicit (&runtime_state->lcore_cfg[worker_id].state, rte_memory_order_acquire) !=WAIT )rte_pause (); -return lcore_config[worker_id].ret; +return runtime_state->lcore_cfg[worker_id].ret; }/*
@@ -36,21 +38,23 @@ RTE_EXPORT_SYMBOL(rte_eal_remote_launch)int rte_eal_remote_launch (lcore_function_t *f,void *arg,unsigned int worker_id) { +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int rc = -EBUSY ;/* Check if the worker is in 'WAIT' state. Use acquire order * since 'state' variable is used as the guard variable. */ -if (rte_atomic_load_explicit (&lcore_config[worker_id].state, +if (rte_atomic_load_explicit (&runtime_state->lcore_cfg[worker_id].state, rte_memory_order_acquire) !=WAIT ) goto finish; - lcore_config[worker_id].arg = arg; + runtime_state->lcore_cfg[worker_id].arg = arg;/* Ensure that all the memory operations are completed * before the worker thread starts running the function. * Use worker thread function as the guard variable. */ -rte_atomic_store_explicit (&lcore_config[worker_id].f, f, rte_memory_order_release); +rte_atomic_store_explicit (&runtime_state->lcore_cfg[worker_id].f, f, + rte_memory_order_release); rc =eal_thread_wake_worker (worker_id);
@@ -69,12 +73,13 @@ int rte_eal_mp_remote_launch(int (*f)(void *), void *arg, enum rte_rmt_call_main_t call_main) { +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int lcore_id;int main_lcore =rte_get_main_lcore ();/* check state of lcores */ RTE_LCORE_FOREACH_WORKER (lcore_id) { -if (lcore_config[lcore_id].state !=WAIT ) +if (runtime_state->lcore_cfg[lcore_id].state !=WAIT )return -EBUSY ; }
@@ -84,8 +89,8 @@ rte_eal_mp_remote_launch(int (*f)(void *), void *arg, }if (call_main ==CALL_MAIN ) { - lcore_config[main_lcore].ret =f (arg); - lcore_config[main_lcore].state =WAIT ; + runtime_state->lcore_cfg[main_lcore].ret =f (arg); + runtime_state->lcore_cfg[main_lcore].state =WAIT ; }return 0 ;
@@ -98,7 +103,9 @@ RTE_EXPORT_SYMBOL(rte_eal_get_lcore_state)enum rte_lcore_state_t rte_eal_get_lcore_state (unsigned lcore_id) { -return lcore_config[lcore_id].state; +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); + +return runtime_state->lcore_cfg[lcore_id].state; }/*
lib/eal/common/eal_common_lcore.c +30 -19
170 lines not on this page · raw message
lib/eal/common/eal_common_options.c +20 -17
@@ -910,7 +910,7 @@ eal_parse_service_coremask(const char *coremask)if (cfg->lcore_role[idx] ==ROLE_RTE ) taken_lcore_count++; - lcore_config[idx].core_role =ROLE_SERVICE ; + cfg->lcore_role[idx] =ROLE_SERVICE ; count++; } }
@@ -921,8 +921,6 @@ eal_parse_service_coremask(const char *coremask)return -1 ;rte_bitset_clear_all (cfg->core_indices,RTE_MAX_LCORE ); -for (; idx <RTE_MAX_LCORE ; idx++) - lcore_config[idx].core_index =-1 ;if (count ==0 )return -1 ;
@@ -941,6 +939,7 @@ static int update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base) { struct rte_config *cfg = rte_eal_get_configuration(); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();unsigned int lcore_id = remap_base;unsigned int count =0 ;unsigned int i;
@@ -950,7 +949,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)rte_bitset_clear_all (cfg->core_indices,RTE_MAX_LCORE );for (i =0 ; i <RTE_MAX_LCORE ; i++) { cfg->lcore_role[i] =ROLE_OFF ; - lcore_config[i].core_index =-1 ; + runtime_state->lcore_cfg[i].core_index =-1 ; }/* now go through the cpuset */
@@ -979,9 +978,10 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)rte_bitset_set (cfg->core_indices, count); cfg->lcore_role[lcore_id] =ROLE_RTE ; - lcore_config[lcore_id].core_index = count; -CPU_ZERO (&lcore_config[lcore_id].cpuset); -CPU_SET (i, &lcore_config[lcore_id].cpuset); + runtime_state->lcore_cfg[lcore_id].core_index = count; +CPU_ZERO (&runtime_state->lcore_cfg[lcore_id].cpuset); +CPU_SET (i, &runtime_state->lcore_cfg[lcore_id].cpuset); + runtime_state->lcore_cfg[lcore_id].first_cpu = i;EAL_LOG (DEBUG ,"lcore %u mapped to physical core %u" , lcore_id, i); lcore_id++; count++;
@@ -1154,8 +1154,7 @@ eal_parse_service_corelist(const char *corelist)if (cfg->lcore_role[idx] ==ROLE_RTE ) taken_lcore_count++; - lcore_config[idx].core_role = -ROLE_SERVICE ; + cfg->lcore_role[idx] =ROLE_SERVICE ; count++; } }
@@ -1178,7 +1177,7 @@ eal_parse_service_corelist(const char *corelist)rte_cpuset_t service_cpuset;CPU_ZERO (&service_cpuset);for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (lcore_config[i].core_role ==ROLE_SERVICE ) +if (cfg->lcore_role[i] ==ROLE_SERVICE )CPU_SET (i, &service_cpuset); }if (CPU_COUNT (&service_cpuset) >0 ) {
@@ -1207,7 +1206,7 @@ eal_parse_main_lcore(const char *arg)return -1 ;/* ensure main core is not used as service core */ -if (lcore_config[cfg->main_lcore].core_role ==ROLE_SERVICE ) { +if (cfg->lcore_role[cfg->main_lcore] ==ROLE_SERVICE ) {EAL_LOG (ERR ,"Error: Main lcore is used as a service core" );return -1 ; }
@@ -1379,6 +1378,7 @@ static int eal_parse_lcores(const char *lcores) {struct rte_config *cfg =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();rte_cpuset_t lcore_set;unsigned int set_count;unsigned idx =0 ;
@@ -1403,8 +1403,9 @@ eal_parse_lcores(const char *lcores)rte_bitset_clear_all (cfg->core_indices,RTE_MAX_LCORE );for (idx =0 ; idx <RTE_MAX_LCORE ; idx++) { cfg->lcore_role[idx] =ROLE_OFF ; - lcore_config[idx].core_index =-1 ; -CPU_ZERO (&lcore_config[idx].cpuset); + runtime_state->lcore_cfg[idx].core_index =-1 ; +CPU_ZERO (&runtime_state->lcore_cfg[idx].cpuset); + runtime_state->lcore_cfg[idx].first_cpu =UINT16_MAX ; }/* Get list of cores */
@@ -1466,7 +1467,7 @@ eal_parse_lcores(const char *lcores)if (cfg->lcore_role[idx] !=ROLE_RTE ) {rte_bitset_set (cfg->core_indices, count); - lcore_config[idx].core_index = count; + runtime_state->lcore_cfg[idx].core_index = count; cfg->lcore_role[idx] =ROLE_RTE ; count++; }
@@ -1478,8 +1479,10 @@ eal_parse_lcores(const char *lcores)if (check_cpuset (&cpuset) <0 ) goto err; -rte_memcpy (&lcore_config[idx].cpuset, &cpuset, +rte_memcpy (&runtime_state->lcore_cfg[idx].cpuset, &cpuset,sizeof (rte_cpuset_t)); + runtime_state->lcore_cfg[idx].first_cpu = + (uint16_t )(RTE_CPU_FFS (&cpuset) -1 ); }/* some cores from the lcore_set can't be handled by EAL */
@@ -2467,7 +2470,7 @@ compute_ctrl_threads_cpuset(void)for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) {if (rte_lcore_has_role (lcore_id,ROLE_OFF ))continue ; -RTE_CPU_OR (cpuset, cpuset, &lcore_config[lcore_id].cpuset); +RTE_CPU_OR (cpuset, cpuset, &runtime_state->lcore_cfg[lcore_id].cpuset); }RTE_CPU_NOT (cpuset, cpuset);
@@ -2478,7 +2481,7 @@ compute_ctrl_threads_cpuset(void)/* if no remaining cpu, use main lcore cpu affinity */ if (!CPU_COUNT (cpuset)) { -memcpy (cpuset, &lcore_config[rte_get_main_lcore ()].cpuset, +memcpy (cpuset, &runtime_state->lcore_cfg[rte_get_main_lcore ()].cpuset,sizeof (*cpuset)); }
lib/eal/common/eal_common_thread.c +14 -10
@@ -69,9 +69,12 @@ thread_update_affinity(rte_cpuset_t *cpusetp)memmove (&RTE_PER_LCORE (_cpuset), cpusetp,sizeof (rte_cpuset_t));if (lcore_id != (unsigned )LCORE_ID_ANY ) { -/* EAL thread: update lcore_config cpuset first then find numa based on that */ -memmove (&lcore_config[lcore_id].cpuset, cpusetp, +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); + +/* EAL thread: update lcore_runtime cpuset first then find numa based on that */ +memmove (&runtime_state->lcore_cfg[lcore_id].cpuset, cpusetp,sizeof (rte_cpuset_t)); + runtime_state->lcore_cfg[lcore_id].first_cpu = (uint16_t )(RTE_CPU_FFS (cpusetp) -1 );RTE_PER_LCORE (_numa_id) =rte_lcore_to_socket_id (lcore_id); }else {/* Non-EAL thread: preserve SOCKET_ID_ANY if cpuset spans NUMA nodes. */
@@ -149,10 +152,11 @@ __rte_noreturn uint32_t eal_thread_loop(void *arg) {unsigned int lcore_id = (uintptr_t )arg; +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();char cpuset[RTE_CPU_AFFINITY_STR_LEN ];int ret; -__rte_thread_init (lcore_id, &lcore_config[lcore_id].cpuset); +__rte_thread_init (lcore_id, &runtime_state->lcore_cfg[lcore_id].cpuset); ret =eal_thread_dump_current_affinity (cpuset,sizeof (cpuset)); EAL_LOG(DEBUG, "lcore %u is ready (tid=%zx;cpuset=[%s%s])",
@@ -171,7 +175,7 @@ eal_thread_loop(void *arg)/* Set the state to 'RUNNING'. Use release order * since 'state' variable is used as the guard variable. */ -rte_atomic_store_explicit (&lcore_config[lcore_id].state,RUNNING , +rte_atomic_store_explicit (&runtime_state->lcore_cfg[lcore_id].state,RUNNING , rte_memory_order_release);eal_thread_ack_command ();
@@ -181,25 +185,25 @@ eal_thread_loop(void *arg)* are accessed only after update to 'f' is visible. * Wait till the update to 'f' is visible to the worker. */ -while ((f =rte_atomic_load_explicit (&lcore_config[lcore_id].f, +while ((f =rte_atomic_load_explicit (&runtime_state->lcore_cfg[lcore_id].f, rte_memory_order_acquire)) ==NULL )rte_pause ();rte_eal_trace_thread_lcore_running (lcore_id, f);/* call the function and store the return value */ - fct_arg = lcore_config[lcore_id].arg; + fct_arg = runtime_state->lcore_cfg[lcore_id].arg; ret =f (fct_arg); - lcore_config[lcore_id].ret = ret; - lcore_config[lcore_id].f =NULL ; - lcore_config[lcore_id].arg =NULL ; + runtime_state->lcore_cfg[lcore_id].ret = ret; + runtime_state->lcore_cfg[lcore_id].f =NULL ; + runtime_state->lcore_cfg[lcore_id].arg =NULL ;/* Store the state with release order to ensure that * the memory operations from the worker thread * are completed before the state is updated. * Use 'state' as the guard variable. */ -rte_atomic_store_explicit (&lcore_config[lcore_id].state,WAIT , +rte_atomic_store_explicit (&runtime_state->lcore_cfg[lcore_id].state,WAIT , rte_memory_order_release);rte_eal_trace_thread_lcore_stopped (lcore_id);
lib/eal/common/eal_internal_cfg.h +19 -0
@@ -16,6 +16,7 @@#include <stdint.h> #include <stdbool.h> +#include <rte_stdatomic.h> #include "eal_thread.h" #if defined(RTE_ARCH_ARM )
@@ -114,6 +115,23 @@ struct eal_platform_info {struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES ]; }; +/** +* Per-lcore runtime state, owned by EAL. +*/ +struct lcore_cfg { +int core_index;/**< relative index, starting from 0 */ +rte_cpuset_t cpuset;/**< cpu set which the lcore affinity to */ +uint16_t first_cpu;/**< lowest CPU set in cpuset, UINT16_MAX if none */ +/* Fields for executing code on a remote lcore */ +rte_thread_t thread_id;/**< thread identifier */ +int pipe_main2worker[2 ];/**< communication pipe with main */ +int pipe_worker2main[2 ];/**< communication pipe with main */ +RTE_ATOMIC (lcore_function_t *)volatile f;/**< function to call */ +void *volatile arg;/**< argument of function */ +volatile int ret;/**< return value of function */ +volatile RTE_ATOMIC (enum rte_lcore_state_t ) state;/**< lcore state */ +}; +/** * Internal EAL runtime state * May be modified at runtime, so access must be protected by locks or atomic types
@@ -125,6 +143,7 @@ struct eal_runtime_state {rte_cpuset_t ctrl_cpuset;/**< cpuset for ctrl threads */ volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */ +struct lcore_cfg lcore_cfg[RTE_MAX_LCORE ]; };struct eal_user_cfg *eal_get_user_configuration (void );
lib/eal/common/eal_private.h +0 -21
@@ -18,27 +18,6 @@#include "eal_internal_cfg.h" -/** -* Structure storing internal configuration (per-lcore) -*/ -struct lcore_config { -rte_thread_t thread_id;/**< thread identifier */ -int pipe_main2worker[2 ];/**< communication pipe with main */ -int pipe_worker2main[2 ];/**< communication pipe with main */ - -RTE_ATOMIC (lcore_function_t *)volatile f;/**< function to call */ -void *volatile arg;/**< argument of function */ -volatile int ret;/**< return value of function */ - -volatile RTE_ATOMIC (enum rte_lcore_state_t ) state;/**< lcore state */ -int core_index;/**< relative index, starting from 0 */ -uint8_t core_role;/**< role of core eg: OFF, RTE, SERVICE */ - -rte_cpuset_t cpuset;/**< cpu set which the lcore affinity to */ -}; - -extern struct lcore_config lcore_config[RTE_MAX_LCORE ]; -/** * The global RTE configuration structure. */
lib/eal/common/rte_service.c +3 -5
@@ -107,7 +107,7 @@ rte_service_init(void)int i;struct rte_config *cfg =rte_eal_get_configuration ();for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (lcore_config[i].core_role ==ROLE_SERVICE ) { +if (cfg->lcore_role[i] ==ROLE_SERVICE ) {if ((unsigned int )i == cfg->main_lcore)continue ;rte_service_lcore_add (i);
@@ -714,9 +714,6 @@ set_lcore_state(uint32_t lcore, int32_t state)struct core_state *cs =RTE_LCORE_VAR_LCORE (lcore, lcore_states); cfg->lcore_role[lcore] = state; -/* mark state in process local lcore_config */ - lcore_config[lcore].core_role = state; -/* update per-lcore optimized state tracking */ cs->is_service_core = (state ==ROLE_SERVICE );
@@ -1104,6 +1101,7 @@ RTE_EXPORT_SYMBOL(rte_service_dump)int32_t rte_service_dump (FILE *f,uint32_t id) { +struct rte_config *cfg =rte_eal_get_configuration ();uint32_t i;int print_one = (id !=UINT32_MAX );
@@ -1126,7 +1124,7 @@ rte_service_dump(FILE *f, uint32_t id)fprintf (f,"Service Cores Summary\n" );for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (lcore_config[i].core_role !=ROLE_SERVICE ) +if (cfg->lcore_role[i] !=ROLE_SERVICE )continue ;service_dump_calls_per_lcore (f, i);
lib/eal/freebsd/eal.c +10 -13
@@ -70,9 +70,6 @@ static struct flock wr_lock = { .l_len = RTE_SIZEOF_FIELD(struct rte_mem_config, memsegs), }; -/* internal configuration (per-core) */ -struct lcore_config lcore_config[RTE_MAX_LCORE ]; -/* used by rte_rdtsc() */ RTE_EXPORT_SYMBOL (rte_cycles_vmware_tsc_map) int rte_cycles_vmware_tsc_map;
@@ -408,7 +405,7 @@ rte_eal_init(int argc, char **argv)char thread_name[RTE_THREAD_NAME_SIZE ];const struct rte_config *config =rte_eal_get_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();bool has_phys_addr;enum rte_iova_mode iova_mode;
@@ -656,13 +653,13 @@ rte_eal_init(int argc, char **argv)eal_check_mem_on_local_socket ();if (rte_thread_set_affinity_by_id (rte_thread_self (), - &lcore_config[config->main_lcore].cpuset) !=0 ) { + &runtime_state->lcore_cfg[config->main_lcore].cpuset) !=0 ) {rte_eal_init_alert ("Cannot set affinity" ); rte_errno =EINVAL ; goto err_out; }__rte_thread_init (config->main_lcore, - &lcore_config[config->main_lcore].cpuset); + &runtime_state->lcore_cfg[config->main_lcore].cpuset); ret =eal_thread_dump_current_affinity (cpuset,sizeof (cpuset));
@@ -676,15 +673,15 @@ rte_eal_init(int argc, char **argv)* create communication pipes between main thread * and children */ -if (pipe (lcore_config[i].pipe_main2worker) <0 ) +if (pipe (runtime_state->lcore_cfg[i].pipe_main2worker) <0 )rte_panic ("Cannot create pipe\n" ); -if (pipe (lcore_config[i].pipe_worker2main) <0 ) +if (pipe (runtime_state->lcore_cfg[i].pipe_worker2main) <0 )rte_panic ("Cannot create pipe\n" ); - lcore_config[i].state =WAIT ; + runtime_state->lcore_cfg[i].state =WAIT ;/* create a thread for each lcore */ - ret =rte_thread_create (&lcore_config[i].thread_id,NULL , + ret =rte_thread_create (&runtime_state->lcore_cfg[i].thread_id,NULL , eal_thread_loop, (void *)(uintptr_t )i);if (ret !=0 )rte_panic ("Cannot create thread\n" );
@@ -694,10 +691,10 @@ rte_eal_init(int argc, char **argv)if (ret >=RTE_THREAD_NAME_SIZE )EAL_LOG (INFO ,"Worker thread name %s truncated" , thread_name); -rte_thread_set_name (lcore_config[i].thread_id, thread_name); +rte_thread_set_name (runtime_state->lcore_cfg[i].thread_id, thread_name); - ret =rte_thread_set_affinity_by_id (lcore_config[i].thread_id, - &lcore_config[i].cpuset); + ret =rte_thread_set_affinity_by_id (runtime_state->lcore_cfg[i].thread_id, + &runtime_state->lcore_cfg[i].cpuset);if (ret !=0 )rte_panic ("Cannot set affinity\n" ); }
lib/eal/linux/eal.c +11 -13
@@ -72,9 +72,6 @@ static struct flock wr_lock = { .l_len = RTE_SIZEOF_FIELD(struct rte_mem_config, memsegs), }; -/* internal configuration (per-core) */ -struct lcore_config lcore_config[RTE_MAX_LCORE ]; -/* used by rte_rdtsc() */ RTE_EXPORT_SYMBOL (rte_cycles_vmware_tsc_map) int rte_cycles_vmware_tsc_map;
@@ -519,6 +516,7 @@ eal_worker_thread_create(unsigned int lcore_id)size_t stack_size;int ret =-1 ;const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); stack_size = user_cfg->huge_worker_stack_size;if (stack_size !=0 ) {
@@ -545,7 +543,7 @@ eal_worker_thread_create(unsigned int lcore_id) } } -if (pthread_create ((pthread_t *)&lcore_config[lcore_id].thread_id.opaque_id, +if (pthread_create ((pthread_t *)&runtime_state->lcore_cfg[lcore_id].thread_id.opaque_id, attrp, eal_worker_thread_loop, (void *)(uintptr_t )lcore_id) ==0 ) ret =0 ;
@@ -570,7 +568,7 @@ rte_eal_init(int argc, char **argv)bool phys_addrs;const struct rte_config *config =rte_eal_get_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* first check if we have been run before */ if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
@@ -831,13 +829,13 @@ rte_eal_init(int argc, char **argv)eal_check_mem_on_local_socket ();if (rte_thread_set_affinity_by_id (rte_thread_self (), - &lcore_config[config->main_lcore].cpuset) !=0 ) { + &runtime_state->lcore_cfg[config->main_lcore].cpuset) !=0 ) {rte_eal_init_alert ("Cannot set affinity" ); rte_errno =EINVAL ; goto err_out; }__rte_thread_init (config->main_lcore, - &lcore_config[config->main_lcore].cpuset); + &runtime_state->lcore_cfg[config->main_lcore].cpuset); ret =eal_thread_dump_current_affinity (cpuset,sizeof (cpuset)); EAL_LOG(DEBUG, "Main lcore %u is ready (tid=%zx;cpuset=[%s%s])",
@@ -850,12 +848,12 @@ rte_eal_init(int argc, char **argv)* create communication pipes between main thread * and children */ -if (pipe (lcore_config[i].pipe_main2worker) <0 ) +if (pipe (runtime_state->lcore_cfg[i].pipe_main2worker) <0 )rte_panic ("Cannot create pipe\n" ); -if (pipe (lcore_config[i].pipe_worker2main) <0 ) +if (pipe (runtime_state->lcore_cfg[i].pipe_worker2main) <0 )rte_panic ("Cannot create pipe\n" ); - lcore_config[i].state =WAIT ; + runtime_state->lcore_cfg[i].state =WAIT ;/* create a thread for each lcore */ ret =eal_worker_thread_create (i);
@@ -867,10 +865,10 @@ rte_eal_init(int argc, char **argv)if (ret >=RTE_THREAD_NAME_SIZE )EAL_LOG (INFO ,"Worker thread name %s truncated" , thread_name); -rte_thread_set_name (lcore_config[i].thread_id, thread_name); +rte_thread_set_name (runtime_state->lcore_cfg[i].thread_id, thread_name); - ret =rte_thread_set_affinity_by_id (lcore_config[i].thread_id, - &lcore_config[i].cpuset); + ret =rte_thread_set_affinity_by_id (runtime_state->lcore_cfg[i].thread_id, + &runtime_state->lcore_cfg[i].cpuset);if (ret !=0 )rte_panic ("Cannot set affinity\n" ); }
lib/eal/unix/eal_unix_thread.c +7 -4
@@ -12,8 +12,9 @@int eal_thread_wake_worker (unsigned int worker_id) { -int m2w = lcore_config[worker_id].pipe_main2worker[1 ]; -int w2m = lcore_config[worker_id].pipe_worker2main[0 ]; +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +int m2w = runtime_state->lcore_cfg[worker_id].pipe_main2worker[1 ]; +int w2m = runtime_state->lcore_cfg[worker_id].pipe_worker2main[0 ];char c =0 ;int n;
@@ -35,11 +36,12 @@ voideal_thread_wait_command (void) {unsigned int lcore_id =rte_lcore_id (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int m2w;char c;int n; - m2w = lcore_config[lcore_id].pipe_main2worker[0 ]; + m2w = runtime_state->lcore_cfg[lcore_id].pipe_main2worker[0 ];do { n =read (m2w, &c,1 ); }while (n <0 && errno ==EINTR );
@@ -51,11 +53,12 @@ voideal_thread_ack_command (void) {unsigned int lcore_id =rte_lcore_id (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();char c =0 ;int w2m;int n; - w2m = lcore_config[lcore_id].pipe_worker2main[1 ]; + w2m = runtime_state->lcore_cfg[lcore_id].pipe_worker2main[1 ];do { n =write (w2m, &c,1 ); }while (n ==0 || (n <0 && errno ==EINTR ));
lib/eal/windows/eal.c +10 -12
@@ -39,9 +39,6 @@*/ static int mem_cfg_fd =-1 ; -/* internal configuration (per-core) */ -struct lcore_config lcore_config[RTE_MAX_LCORE ]; -/* Detect if we are a primary or a secondary process */ enum rte_proc_type_t eal_proc_type_detect (void )
@@ -159,6 +156,7 @@ rte_eal_init(int argc, char **argv)int i, fctret, bscan;const struct rte_config *config =rte_eal_get_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();bool has_phys_addr;enum rte_iova_mode iova_mode;int ret;
@@ -348,13 +346,13 @@ rte_eal_init(int argc, char **argv)eal_rand_init ();if (rte_thread_set_affinity_by_id (rte_thread_self (), - &lcore_config[config->main_lcore].cpuset) !=0 ) { + &runtime_state->lcore_cfg[config->main_lcore].cpuset) !=0 ) {rte_eal_init_alert ("Cannot set affinity" ); rte_errno =EINVAL ; goto err_out; }__rte_thread_init (config->main_lcore, - &lcore_config[config->main_lcore].cpuset); + &runtime_state->lcore_cfg[config->main_lcore].cpuset); ret =eal_thread_dump_current_affinity (cpuset,sizeof (cpuset)); EAL_LOG(DEBUG, "Main lcore %u is ready (tid=%zx;cpuset=[%s%s])",
@@ -367,17 +365,17 @@ rte_eal_init(int argc, char **argv)* create communication pipes between main thread * and children */ -if (_pipe (lcore_config[i].pipe_main2worker, +if (_pipe (runtime_state->lcore_cfg[i].pipe_main2worker,sizeof (char ), _O_BINARY) <0 )rte_panic ("Cannot create pipe\n" ); -if (_pipe (lcore_config[i].pipe_worker2main, +if (_pipe (runtime_state->lcore_cfg[i].pipe_worker2main,sizeof (char ), _O_BINARY) <0 )rte_panic ("Cannot create pipe\n" ); - lcore_config[i].state =WAIT ; + runtime_state->lcore_cfg[i].state =WAIT ;/* create a thread for each lcore */ -if (rte_thread_create (&lcore_config[i].thread_id,NULL , +if (rte_thread_create (&runtime_state->lcore_cfg[i].thread_id,NULL , eal_thread_loop, (void *)(uintptr_t )i) !=0 )rte_panic ("Cannot create thread\n" );
@@ -386,10 +384,10 @@ rte_eal_init(int argc, char **argv)if (ret >=RTE_THREAD_NAME_SIZE )EAL_LOG (INFO ,"Worker thread name %s truncated" , thread_name); -rte_thread_set_name (lcore_config[i].thread_id, thread_name); +rte_thread_set_name (runtime_state->lcore_cfg[i].thread_id, thread_name); - ret =rte_thread_set_affinity_by_id (lcore_config[i].thread_id, - &lcore_config[i].cpuset); + ret =rte_thread_set_affinity_by_id (runtime_state->lcore_cfg[i].thread_id, + &runtime_state->lcore_cfg[i].cpuset);if (ret !=0 )EAL_LOG (DEBUG ,"Cannot set affinity" ); }
lib/eal/windows/eal_thread.c +7 -4
@@ -20,8 +20,9 @@int eal_thread_wake_worker (unsigned int worker_id) { -int m2w = lcore_config[worker_id].pipe_main2worker[1 ]; -int w2m = lcore_config[worker_id].pipe_worker2main[0 ]; +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +int m2w = runtime_state->lcore_cfg[worker_id].pipe_main2worker[1 ]; +int w2m = runtime_state->lcore_cfg[worker_id].pipe_worker2main[0 ];char c =0 ;int n;
@@ -43,11 +44,12 @@ voideal_thread_wait_command (void) {unsigned int lcore_id =rte_lcore_id (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int m2w;char c;int n; - m2w = lcore_config[lcore_id].pipe_main2worker[0 ]; + m2w = runtime_state->lcore_cfg[lcore_id].pipe_main2worker[0 ];do { n =_read (m2w, &c,1 ); }while (n <0 && errno ==EINTR );
@@ -59,11 +61,12 @@ voideal_thread_ack_command (void) {unsigned int lcore_id =rte_lcore_id (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();char c =0 ;int w2m;int n; - w2m = lcore_config[lcore_id].pipe_worker2main[1 ]; + w2m = runtime_state->lcore_cfg[lcore_id].pipe_worker2main[1 ];do { n =_write (w2m, &c,1 ); }while (n ==0 || (n <0 && errno ==EINTR ));
Signature · 1 line
2.53.0
PATCH v2 16/39 eal: move core indices bitset to runtime state
In reply to Bruce RichardsonMove the bitset for tracking allocated lcore ids to the runtime configuration struct, to co-exist with the other lcore data.
--- lib/eal/common/eal_common_lcore.c | 12 +++++++----- lib/eal/common/eal_common_options.c | 11 ++++++----- lib/eal/common/eal_internal_cfg.h | 2 ++ lib/eal/common/eal_private.h | 3 --- 4 files changed, 15 insertions(+), 13 deletions(-)
lib/eal/common/eal_common_lcore.c +7 -5
@@ -223,7 +223,7 @@ rte_eal_cpu_init(void) runtime_state->lcore_cfg[lcore_id].first_cpu = lcore_id;/* This is the first time we discover the lcores, so the bitset should be zeroed */ -rte_bitset_set (config->core_indices, count); +rte_bitset_set (runtime_state->core_indices, count);/* By default, each detected core is enabled */ config->lcore_role[lcore_id] =ROLE_RTE ;
@@ -417,7 +417,7 @@ eal_lcore_non_eal_allocate(void)int core_index =-1 ;rte_rwlock_write_lock (&lcore_lock); - core_index =rte_bitset_find_first_clear (cfg->core_indices,RTE_MAX_LCORE ); + core_index =rte_bitset_find_first_clear (runtime_state->core_indices,RTE_MAX_LCORE );if (core_index ==-1 ) {EAL_LOG (DEBUG ,"No core_index available." ); lcore_id =RTE_MAX_LCORE ;
@@ -426,7 +426,7 @@ eal_lcore_non_eal_allocate(void)for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) {if (cfg->lcore_role[lcore_id] !=ROLE_OFF )continue ; -rte_bitset_set (cfg->core_indices, core_index); +rte_bitset_set (runtime_state->core_indices, core_index); runtime_state->lcore_cfg[lcore_id].core_index = core_index; cfg->lcore_role[lcore_id] =ROLE_NON_EAL ; cfg->lcore_count++;
@@ -449,7 +449,8 @@ eal_lcore_non_eal_allocate(void) }EAL_LOG (DEBUG ,"Initialization refused for lcore %u." , lcore_id); -rte_bitset_clear (cfg->core_indices, runtime_state->lcore_cfg[lcore_id].core_index); +rte_bitset_clear (runtime_state->core_indices, + runtime_state->lcore_cfg[lcore_id].core_index); runtime_state->lcore_cfg[lcore_id].core_index =-1 ; cfg->lcore_role[lcore_id] =ROLE_OFF ; cfg->lcore_count--;
@@ -473,7 +474,8 @@ eal_lcore_non_eal_release(unsigned int lcore_id) goto out; TAILQ_FOREACH(callback, &lcore_callbacks, next)callback_uninit (callback, lcore_id); -rte_bitset_clear (cfg->core_indices, runtime_state->lcore_cfg[lcore_id].core_index); +rte_bitset_clear (runtime_state->core_indices, + runtime_state->lcore_cfg[lcore_id].core_index); runtime_state->lcore_cfg[lcore_id].core_index =-1 ; cfg->lcore_role[lcore_id] =ROLE_OFF ; cfg->lcore_count--;
lib/eal/common/eal_common_options.c +6 -5
@@ -864,6 +864,7 @@ static int eal_parse_service_coremask(const char *coremask) {struct rte_config *cfg =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int i, j, idx =0 ;unsigned int count =0 ;char c;
@@ -920,7 +921,7 @@ eal_parse_service_coremask(const char *coremask)if (coremask[i] !='0' )return -1 ; -rte_bitset_clear_all (cfg->core_indices,RTE_MAX_LCORE ); +rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE );if (count ==0 )return -1 ;
@@ -946,7 +947,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)int ret =0 ;/* set everything to disabled first, then set up values */ -rte_bitset_clear_all (cfg->core_indices,RTE_MAX_LCORE ); +rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE );for (i =0 ; i <RTE_MAX_LCORE ; i++) { cfg->lcore_role[i] =ROLE_OFF ; runtime_state->lcore_cfg[i].core_index =-1 ;
@@ -976,7 +977,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)continue ; } -rte_bitset_set (cfg->core_indices, count); +rte_bitset_set (runtime_state->core_indices, count); cfg->lcore_role[lcore_id] =ROLE_RTE ; runtime_state->lcore_cfg[lcore_id].core_index = count;CPU_ZERO (&runtime_state->lcore_cfg[lcore_id].cpuset);
@@ -1400,7 +1401,7 @@ eal_parse_lcores(const char *lcores)CPU_ZERO (&cpuset);/* Reset lcore config */ -rte_bitset_clear_all (cfg->core_indices,RTE_MAX_LCORE ); +rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE );for (idx =0 ; idx <RTE_MAX_LCORE ; idx++) { cfg->lcore_role[idx] =ROLE_OFF ; runtime_state->lcore_cfg[idx].core_index =-1 ;
@@ -1466,7 +1467,7 @@ eal_parse_lcores(const char *lcores) set_count--;if (cfg->lcore_role[idx] !=ROLE_RTE ) { -rte_bitset_set (cfg->core_indices, count); +rte_bitset_set (runtime_state->core_indices, count); runtime_state->lcore_cfg[idx].core_index = count; cfg->lcore_role[idx] =ROLE_RTE ; count++;
lib/eal/common/eal_internal_cfg.h +2 -0
@@ -16,6 +16,7 @@#include <stdint.h> #include <stdbool.h> +#include <rte_bitset.h> #include <rte_stdatomic.h> #include "eal_thread.h"
@@ -144,6 +145,7 @@ struct eal_runtime_state {volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */ struct lcore_cfg lcore_cfg[RTE_MAX_LCORE ]; +RTE_BITSET_DECLARE (core_indices,RTE_MAX_LCORE );/**< currently allocated core_indices */ };struct eal_user_cfg *eal_get_user_configuration (void );
lib/eal/common/eal_private.h +0 -3
@@ -11,7 +11,6 @@#include <sys/queue.h> #include <dev_driver.h> -#include <rte_bitset.h> #include <rte_lcore.h> #include <rte_log.h> #include <rte_memory.h>
@@ -22,8 +21,6 @@* The global RTE configuration structure. */ struct rte_config { - RTE_BITSET_DECLARE(core_indices, - RTE_MAX_LCORE);/**< bitset of currently allocated core_indices */ uint32_t main_lcore;/**< Id of the main lcore */ uint32_t lcore_count;/**< Number of available logical cores. */ uint32_t numa_node_count;/**< Number of detected NUMA nodes. */
Signature · 1 line
2.53.0
PATCH v2 17/39 eal: cleanup CPU init function
In reply to Bruce RichardsonThe CPU init function did extra work in zeroing the runtime config for lcores, something that was being done a second time in configuring the argparsing stage when preparing to set up the correct cpu affinities for each lcore. Therefore we can remove that unnecessary initialization, and have the function not make any changes to "runtime_state" but only the "platform_info".
In the process we can make some other cleanups too:
* remove the limit on the lcore_to_socket_id array, and dynamically allocate it to the correct number of present cores.
* with the runtime lcore init gone, we can move the assignment to the lcore_to_socket_id into the first loop, allowing us to remove the second loop entirely.
* the log message about "skipping" lcores was incorrect for modern DPDK, since we no longer have a hard-link between physical core numbers and lcore ids. Therefore just report what cores are detected on what sockets.
--- lib/eal/common/eal_common_lcore.c | 92 +++++++++---------------------- 1 file changed, 25 insertions(+), 67 deletions(-)
lib/eal/common/eal_common_lcore.c +25 -67
@@ -166,18 +166,10 @@ socket_id_cmp(const void *a, const void *b)int rte_eal_cpu_init (void ) { -/* pointer to global configuration */ struct rte_config *config =rte_eal_get_configuration ();struct eal_platform_info *platform_info =eal_get_platform_info (); -struct eal_runtime_state *runtime_state =eal_get_runtime_state (); -unsigned lcore_id; -unsigned count =0 ; -unsigned int socket_id, prev_socket_id; -#if CPU_SETSIZE >RTE_MAX_LCORE -int lcore_to_socket_id[CPU_SETSIZE ] = {0 }; -#else -int lcore_to_socket_id[RTE_MAX_LCORE ] = {0 }; -#endif +int *lcore_to_socket_id; +size_t nb_detected_cpus =0 ;/* allocate cpu_info for all CPUs visible to the OS */ platform_info->cpu_count =eal_cpu_max ();
@@ -187,6 +179,12 @@ rte_eal_cpu_init(void)EAL_LOG (ERR ,"Cannot allocate cpu_info array" );return -1 ; } + lcore_to_socket_id =calloc (platform_info->cpu_count,sizeof (*lcore_to_socket_id)); +if (lcore_to_socket_id ==NULL ) { +EAL_LOG (ERR ,"Cannot allocate lcore_to_socket_id array" ); +free (platform_info->cpu_info); +return -1 ; + }/* populate cpu_info with hardware topology for all detected CPUs */ for (size_t cpu_id =0 ; cpu_id < platform_info->cpu_count; cpu_id++) {
@@ -195,71 +193,30 @@ rte_eal_cpu_init(void) platform_info->cpu_info[cpu_id].detected = true; platform_info->cpu_info[cpu_id].numa_id =eal_cpu_socket_id (cpu_id); platform_info->cpu_info[cpu_id].core_id =eal_cpu_core_id (cpu_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++) { - runtime_state->lcore_cfg[lcore_id].core_index = count; - -/* init cpuset for per lcore config */ -CPU_ZERO (&runtime_state->lcore_cfg[lcore_id].cpuset); - runtime_state->lcore_cfg[lcore_id].first_cpu =UINT16_MAX ; +/* store numa id for later processing to determine all unique numa nodes */ + lcore_to_socket_id[nb_detected_cpus++] = platform_info->cpu_info[cpu_id].numa_id; -if (eal_cpu_detected (lcore_id) ==0 ) { - config->lcore_role[lcore_id] =ROLE_OFF ; - runtime_state->lcore_cfg[lcore_id].core_index =-1 ; -continue ; - } - -/* find socket first */ - socket_id = platform_info->cpu_info[lcore_id].numa_id; - lcore_to_socket_id[lcore_id] = socket_id; - -/* By default, lcore 1:1 map to cpu id */ -CPU_SET (lcore_id, &runtime_state->lcore_cfg[lcore_id].cpuset); - runtime_state->lcore_cfg[lcore_id].first_cpu = lcore_id; - -/* This is the first time we discover the lcores, so the bitset should be zeroed */ -rte_bitset_set (runtime_state->core_indices, count); - -/* By default, each detected core is enabled */ - config->lcore_role[lcore_id] =ROLE_RTE ; -EAL_LOG (DEBUG ,"Detected lcore %u as " -"core %u on NUMA node %u" , - lcore_id, - platform_info->cpu_info[lcore_id].core_id, - platform_info->cpu_info[lcore_id].numa_id); - count++; - } -for (; lcore_id <CPU_SETSIZE ; lcore_id++) { -if (eal_cpu_detected (lcore_id) ==0 ) -continue ; -if (unlikely (lcore_id >= platform_info->cpu_count)) -break ; - lcore_to_socket_id[lcore_id] = platform_info->cpu_info[lcore_id].numa_id; -EAL_LOG (DEBUG ,"Skipped lcore %u as core %u on NUMA node %u" , - lcore_id, platform_info->cpu_info[lcore_id].core_id, - platform_info->cpu_info[lcore_id].numa_id); +EAL_LOG (DEBUG ,"Detected CPU %zu as core %u on NUMA node %u" , + cpu_id, + platform_info->cpu_info[cpu_id].core_id, + platform_info->cpu_info[cpu_id].numa_id); } -/* Set the count of enabled logical cores of the EAL configuration */ - config->lcore_count = count; -EAL_LOG (DEBUG , -"Maximum logical cores by configuration: %u" , -RTE_MAX_LCORE ); -EAL_LOG (INFO ,"Detected CPU lcores: %u" , config->lcore_count); +if (nb_detected_cpus ==0 ) { +EAL_LOG (ERR ,"No CPUs detected for platform topology" ); +free (platform_info->cpu_info); +free (lcore_to_socket_id); +return -1 ; + }/* sort all socket id's in ascending order */ -qsort (lcore_to_socket_id,RTE_DIM (lcore_to_socket_id), +qsort (lcore_to_socket_id, nb_detected_cpus,sizeof (lcore_to_socket_id[0 ]), socket_id_cmp); - prev_socket_id =-1 ; +int prev_socket_id =-1 ; config->numa_node_count =0 ; -for (lcore_id =0 ; lcore_id <RTE_DIM (lcore_to_socket_id); lcore_id++) { - socket_id = lcore_to_socket_id[lcore_id]; +for (size_t i =0 ; i < nb_detected_cpus; i++) { +int socket_id = lcore_to_socket_id[i];if (socket_id != prev_socket_id) config->numa_nodes[config->numa_node_count++] = socket_id; prev_socket_id = socket_id;
@@ -268,6 +225,7 @@ rte_eal_cpu_init(void) }EAL_LOG (INFO ,"Detected NUMA nodes: %u" , config->numa_node_count); +free (lcore_to_socket_id);return 0 ; }
Signature · 1 line
2.53.0
PATCH v2 18/39 eal: move NUMA node information to platform info struct
In reply to Bruce RichardsonThe numa node information for the platform is stored in rte_config but belongs more in platform info struct. Move the data to that location. In the process remove the hard-coded limit for RTE_MAX_NUMA_NODES for the array. At least for platform info, we can record details about all numa nodes, whatever the number.
--- lib/eal/common/eal_common_lcore.c | 59 ++++++++++++++++++++++--------- lib/eal/common/eal_internal_cfg.h | 2 ++ lib/eal/common/eal_private.h | 2 -- 3 files changed, 45 insertions(+), 18 deletions(-)
lib/eal/common/eal_common_lcore.c +43 -16
@@ -166,7 +166,6 @@ socket_id_cmp(const void *a, const void *b)int rte_eal_cpu_init (void ) { -struct rte_config *config =rte_eal_get_configuration ();struct eal_platform_info *platform_info =eal_get_platform_info ();int *lcore_to_socket_id;size_t nb_detected_cpus =0 ;
@@ -213,19 +212,47 @@ rte_eal_cpu_init(void)qsort (lcore_to_socket_id, nb_detected_cpus,sizeof (lcore_to_socket_id[0 ]), socket_id_cmp); -int prev_socket_id =-1 ; - config->numa_node_count =0 ; -for (size_t i =0 ; i < nb_detected_cpus; i++) { -int socket_id = lcore_to_socket_id[i]; -if (socket_id != prev_socket_id) - config->numa_nodes[config->numa_node_count++] = socket_id; - prev_socket_id = socket_id; -if (config->numa_node_count >=RTE_MAX_NUMA_NODES ) -break ; +/* allocate worst-case (one NUMA node per CPU), then dedup and shrink */ + platform_info->numa_nodes =calloc (platform_info->cpu_count, +sizeof (*platform_info->numa_nodes)); +if (platform_info->numa_nodes ==NULL ) { +EAL_LOG (ERR ,"Cannot allocate numa_nodes array" ); +free (lcore_to_socket_id); +free (platform_info->cpu_info); +return -1 ; } -EAL_LOG (INFO ,"Detected NUMA nodes: %u" , config->numa_node_count); +uint32_t numa_node_count =0 ; +int prev_socket_id =-1 ; +for (size_t cpu_id =0 ; cpu_id < nb_detected_cpus; cpu_id++) { +int socket_id = lcore_to_socket_id[cpu_id]; +if (socket_id != prev_socket_id) { + platform_info->numa_nodes[numa_node_count++] = socket_id; + prev_socket_id = socket_id; + } + }free (lcore_to_socket_id); + +if (numa_node_count >RTE_MAX_NUMA_NODES ) { +EAL_LOG (ERR ,"Detected %u NUMA nodes, but only RTE_MAX_NUMA_NODES (%u) are supported" , + numa_node_count,RTE_MAX_NUMA_NODES ); +free (platform_info->numa_nodes); + platform_info->numa_nodes =NULL ; +free (platform_info->cpu_info); + platform_info->cpu_info =NULL ; +return -1 ; + } + platform_info->numa_node_count = numa_node_count; + +/* shrink to the actual number of unique NUMA nodes found, +* realloc may fail, in that case we keep the original allocation +*/ +uint32_t *tmp =realloc (platform_info->numa_nodes, + numa_node_count *sizeof (*platform_info->numa_nodes)); +if (tmp !=NULL ) + platform_info->numa_nodes = tmp; +EAL_LOG (INFO ,"Detected NUMA nodes: %u" , platform_info->numa_node_count); +return 0 ; }
@@ -233,20 +260,20 @@ RTE_EXPORT_SYMBOL(rte_socket_count)unsigned int rte_socket_count (void ) { -const struct rte_config *config =rte_eal_get_configuration (); -return config->numa_node_count; +const struct eal_platform_info *platform_info =eal_get_platform_info (); +return platform_info->numa_node_count; }RTE_EXPORT_SYMBOL (rte_socket_id_by_idx) intrte_socket_id_by_idx (unsigned int idx) { -const struct rte_config *config =rte_eal_get_configuration (); -if (idx >= config->numa_node_count) { +const struct eal_platform_info *platform_info =eal_get_platform_info (); +if (idx >= platform_info->numa_node_count) { rte_errno =EINVAL ;return -1 ; } -return config->numa_nodes[idx]; +return platform_info->numa_nodes[idx]; }static rte_rwlock_t lcore_lock =RTE_RWLOCK_INITIALIZER ;
lib/eal/common/eal_internal_cfg.h +2 -0
@@ -112,6 +112,8 @@ struct eal_cpu_info {struct eal_platform_info {size_t cpu_count;/**< number of entries in cpu_info[] */ struct eal_cpu_info *cpu_info;/**< per-physical-CPU hardware facts */ +uint32_t numa_node_count;/**< number of detected NUMA nodes */ +uint32_t *numa_nodes;/**< sorted list of detected NUMA node IDs */ uint8_t num_hugepage_sizes;/**< how many sizes on this system */ struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES ]; };
lib/eal/common/eal_private.h +0 -2
@@ -23,8 +23,6 @@struct rte_config {uint32_t main_lcore;/**< Id of the main lcore */ uint32_t lcore_count;/**< Number of available logical cores. */ -uint32_t numa_node_count;/**< Number of detected NUMA nodes. */ -uint32_t numa_nodes[RTE_MAX_NUMA_NODES ];/**< List of detected NUMA nodes. */ uint32_t service_lcore_count;/**< Number of available service cores. */ enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE ];/**< State of cores. */
Signature · 1 line
2.53.0
PATCH v2 19/39 eal: move lcore role and count to runtime state
In reply to Bruce RichardsonMove the lcore role and lcore count values from rte_config struct to the runtime state struct. Update all call sites. The service_lcore_count value was set but never actually used, so just remove it from rte_config rather than moving it to the new structure.
--- lib/eal/common/eal_common_lcore.c | 53 ++++++++++++++--------------- lib/eal/common/eal_common_options.c | 37 +++++++++----------- lib/eal/common/eal_internal_cfg.h | 2 ++ lib/eal/common/eal_private.h | 3 -- lib/eal/common/rte_service.c | 14 ++++---- 5 files changed, 51 insertions(+), 58 deletions(-)
lib/eal/common/eal_common_lcore.c +25 -28
@@ -29,7 +29,7 @@ unsigned int rte_get_main_lcore(void)RTE_EXPORT_SYMBOL (rte_lcore_count) unsigned int rte_lcore_count(void) { -return rte_eal_get_configuration ()->lcore_count; +return eal_get_runtime_state ()->lcore_count; }RTE_EXPORT_SYMBOL (rte_lcore_index)
@@ -85,33 +85,33 @@ RTE_EXPORT_SYMBOL(rte_eal_lcore_role)enum rte_lcore_role_t rte_eal_lcore_role (unsigned int lcore_id) { -struct rte_config *cfg =rte_eal_get_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();if (lcore_id >=RTE_MAX_LCORE )return ROLE_OFF ; -return cfg->lcore_role[lcore_id]; +return runtime_state->lcore_role[lcore_id]; }RTE_EXPORT_SYMBOL (rte_lcore_has_role) intrte_lcore_has_role (unsigned int lcore_id,enum rte_lcore_role_t role) { -struct rte_config *cfg =rte_eal_get_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();if (lcore_id >=RTE_MAX_LCORE )return 0 ; -return cfg->lcore_role[lcore_id] == role; +return runtime_state->lcore_role[lcore_id] == role; }RTE_EXPORT_SYMBOL (rte_lcore_is_enabled) int rte_lcore_is_enabled(unsigned int lcore_id) { -struct rte_config *cfg =rte_eal_get_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();if (lcore_id >=RTE_MAX_LCORE )return 0 ; -return cfg->lcore_role[lcore_id] ==ROLE_RTE ; +return runtime_state->lcore_role[lcore_id] ==ROLE_RTE ; }RTE_EXPORT_SYMBOL (rte_get_next_lcore)
@@ -319,7 +319,7 @@ void * rte_lcore_callback_register(const char *name, rte_lcore_init_cb init, rte_lcore_uninit_cb uninit, void *arg) { - struct rte_config *cfg = rte_eal_get_configuration(); + struct eal_runtime_state *runtime_state = eal_get_runtime_state();struct lcore_callback *callback;unsigned int lcore_id;
@@ -339,7 +339,7 @@ rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,if (callback->init ==NULL ) goto no_init;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { -if (cfg->lcore_role[lcore_id] ==ROLE_OFF ) +if (runtime_state->lcore_role[lcore_id] ==ROLE_OFF )continue ;if (callback_init (callback, lcore_id) ==0 )continue ;
@@ -347,7 +347,7 @@ rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,* previous lcore. */ while (lcore_id-- !=0 ) { -if (cfg->lcore_role[lcore_id] ==ROLE_OFF ) +if (runtime_state->lcore_role[lcore_id] ==ROLE_OFF )continue ;callback_uninit (callback, lcore_id); }
@@ -369,7 +369,7 @@ RTE_EXPORT_SYMBOL(rte_lcore_callback_unregister)void rte_lcore_callback_unregister (void *handle) { -struct rte_config *cfg =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct lcore_callback *callback = handle;unsigned int lcore_id;
@@ -379,7 +379,7 @@ rte_lcore_callback_unregister(void *handle)if (callback->uninit ==NULL ) goto no_uninit;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { -if (cfg->lcore_role[lcore_id] ==ROLE_OFF ) +if (runtime_state->lcore_role[lcore_id] ==ROLE_OFF )continue ;callback_uninit (callback, lcore_id); }
@@ -394,7 +394,6 @@ rte_lcore_callback_unregister(void *handle)unsigned int eal_lcore_non_eal_allocate (void ) { -struct rte_config *cfg =rte_eal_get_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct lcore_callback *callback;struct lcore_callback *prev;
@@ -409,12 +408,12 @@ eal_lcore_non_eal_allocate(void) goto out; }for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { -if (cfg->lcore_role[lcore_id] !=ROLE_OFF ) +if (runtime_state->lcore_role[lcore_id] !=ROLE_OFF )continue ;rte_bitset_set (runtime_state->core_indices, core_index); runtime_state->lcore_cfg[lcore_id].core_index = core_index; - cfg->lcore_role[lcore_id] =ROLE_NON_EAL ; - cfg->lcore_count++; + runtime_state->lcore_role[lcore_id] =ROLE_NON_EAL ; + runtime_state->lcore_count++;break ; }if (lcore_id ==RTE_MAX_LCORE ) {
@@ -437,8 +436,8 @@ eal_lcore_non_eal_allocate(void)rte_bitset_clear (runtime_state->core_indices, runtime_state->lcore_cfg[lcore_id].core_index); runtime_state->lcore_cfg[lcore_id].core_index =-1 ; - cfg->lcore_role[lcore_id] =ROLE_OFF ; - cfg->lcore_count--; + runtime_state->lcore_role[lcore_id] =ROLE_OFF ; + runtime_state->lcore_count--; lcore_id =RTE_MAX_LCORE ; goto out; }
@@ -450,20 +449,19 @@ eal_lcore_non_eal_allocate(void)void eal_lcore_non_eal_release (unsigned int lcore_id) { -struct rte_config *cfg =rte_eal_get_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct lcore_callback *callback;rte_rwlock_write_lock (&lcore_lock); -if (cfg->lcore_role[lcore_id] !=ROLE_NON_EAL ) +if (runtime_state->lcore_role[lcore_id] !=ROLE_NON_EAL ) goto out; TAILQ_FOREACH(callback, &lcore_callbacks, next)callback_uninit (callback, lcore_id);rte_bitset_clear (runtime_state->core_indices, runtime_state->lcore_cfg[lcore_id].core_index); runtime_state->lcore_cfg[lcore_id].core_index =-1 ; - cfg->lcore_role[lcore_id] =ROLE_OFF ; - cfg->lcore_count--; + runtime_state->lcore_role[lcore_id] =ROLE_OFF ; + runtime_state->lcore_count--; out:rte_rwlock_write_unlock (&lcore_lock); }
@@ -472,13 +470,13 @@ RTE_EXPORT_SYMBOL(rte_lcore_iterate)int rte_lcore_iterate (rte_lcore_iterate_cb cb,void *arg) { -struct rte_config *cfg =rte_eal_get_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();unsigned int lcore_id;int ret =0 ;rte_rwlock_read_lock (&lcore_lock);for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { -if (cfg->lcore_role[lcore_id] ==ROLE_OFF ) +if (runtime_state->lcore_role[lcore_id] ==ROLE_OFF )continue ; ret =cb (lcore_id, arg);if (ret !=0 )
@@ -523,7 +521,6 @@ static int lcore_dump_cb(unsigned int lcore_id, void *arg) { const struct eal_runtime_state *runtime_state = eal_get_runtime_state(); -struct rte_config *cfg =rte_eal_get_configuration ();char *cpuset;struct rte_lcore_usage usage;rte_lcore_usage_cb usage_cb;
@@ -544,7 +541,7 @@ lcore_dump_cb(unsigned int lcore_id, void *arg) cpuset =eal_cpuset_to_str (&runtime_state->lcore_cfg[lcore_id].cpuset);fprintf (f,"lcore %u, socket %u, role %s, cpuset %s\n" , lcore_id,rte_lcore_to_socket_id (lcore_id), -lcore_role_str (cfg->lcore_role[lcore_id]), +lcore_role_str (runtime_state->lcore_role[lcore_id]), cpuset !=NULL ? cpuset :"<unknown>" );free (cpuset);free (usage_str);
@@ -597,7 +594,6 @@ static int lcore_telemetry_info_cb(unsigned int lcore_id, void *arg) { const struct eal_runtime_state *runtime_state = eal_get_runtime_state(); -struct rte_config *cfg =rte_eal_get_configuration ();struct lcore_telemetry_info *info = arg;char ratio_str[RTE_TEL_MAX_STRING_LEN ];struct rte_lcore_usage usage;
@@ -611,7 +607,8 @@ lcore_telemetry_info_cb(unsigned int lcore_id, void *arg)rte_tel_data_start_dict (info->d);rte_tel_data_add_dict_int (info->d,"lcore_id" , lcore_id);rte_tel_data_add_dict_int (info->d,"socket" ,rte_lcore_to_socket_id (lcore_id)); -rte_tel_data_add_dict_string (info->d,"role" ,lcore_role_str (cfg->lcore_role[lcore_id])); +rte_tel_data_add_dict_string (info->d,"role" , +lcore_role_str (runtime_state->lcore_role[lcore_id])); cpuset =rte_tel_data_alloc ();if (cpuset ==NULL )return -ENOMEM ;
lib/eal/common/eal_common_options.c +17 -20
@@ -863,7 +863,6 @@ static int xdigit2val(unsigned char c)static int eal_parse_service_coremask (const char *coremask) { -struct rte_config *cfg =rte_eal_get_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int i, j, idx =0 ;unsigned int count =0 ;
@@ -908,10 +907,10 @@ eal_parse_service_coremask(const char *coremask)return -1 ; } -if (cfg->lcore_role[idx] ==ROLE_RTE ) +if (runtime_state->lcore_role[idx] ==ROLE_RTE ) taken_lcore_count++; - cfg->lcore_role[idx] =ROLE_SERVICE ; + runtime_state->lcore_role[idx] =ROLE_SERVICE ; count++; } }
@@ -932,14 +931,12 @@ eal_parse_service_coremask(const char *coremask) "Please ensure -c or -l includes service cores"); } - cfg->service_lcore_count = count;return 0 ; }static int update_lcore_config (const rte_cpuset_t *cpuset,bool remap,uint16_t remap_base) { -struct rte_config *cfg =rte_eal_get_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();unsigned int lcore_id = remap_base;unsigned int count =0 ;
@@ -949,7 +946,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)/* set everything to disabled first, then set up values */ rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE );for (i =0 ; i <RTE_MAX_LCORE ; i++) { - cfg->lcore_role[i] =ROLE_OFF ; + runtime_state->lcore_role[i] =ROLE_OFF ; runtime_state->lcore_cfg[i].core_index =-1 ; }
@@ -978,7 +975,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base) }rte_bitset_set (runtime_state->core_indices, count); - cfg->lcore_role[lcore_id] =ROLE_RTE ; + runtime_state->lcore_role[lcore_id] =ROLE_RTE ; runtime_state->lcore_cfg[lcore_id].core_index = count;CPU_ZERO (&runtime_state->lcore_cfg[lcore_id].cpuset);CPU_SET (i, &runtime_state->lcore_cfg[lcore_id].cpuset);
@@ -993,7 +990,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base) ret =-1 ; }if (!ret) - cfg->lcore_count = count; + runtime_state->lcore_count = count;return ret; }
@@ -1112,7 +1109,7 @@ rte_eal_parse_coremask(const char *coremask, rte_cpuset_t *cpuset, bool limit_rastatic int eal_parse_service_corelist (const char *corelist) { -struct rte_config *cfg =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int i;unsigned count =0 ;char *end =NULL ;
@@ -1151,11 +1148,11 @@ eal_parse_service_corelist(const char *corelist)if (min ==RTE_MAX_LCORE ) min = idx;for (idx = min; idx <= max; idx++) { -if (cfg->lcore_role[idx] !=ROLE_SERVICE ) { -if (cfg->lcore_role[idx] ==ROLE_RTE ) +if (runtime_state->lcore_role[idx] !=ROLE_SERVICE ) { +if (runtime_state->lcore_role[idx] ==ROLE_RTE ) taken_lcore_count++; - cfg->lcore_role[idx] =ROLE_SERVICE ; + runtime_state->lcore_role[idx] =ROLE_SERVICE ; count++; } }
@@ -1178,7 +1175,7 @@ eal_parse_service_corelist(const char *corelist)rte_cpuset_t service_cpuset;CPU_ZERO (&service_cpuset);for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (cfg->lcore_role[i] ==ROLE_SERVICE ) +if (runtime_state->lcore_role[i] ==ROLE_SERVICE )CPU_SET (i, &service_cpuset); }if (CPU_COUNT (&service_cpuset) >0 ) {
@@ -1198,6 +1195,7 @@ eal_parse_main_lcore(const char *arg) {char *parsing_end;struct rte_config *cfg =rte_eal_get_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state (); errno =0 ; cfg->main_lcore = (uint32_t )strtol (arg, &parsing_end,0 );
@@ -1207,12 +1205,12 @@ eal_parse_main_lcore(const char *arg)return -1 ;/* ensure main core is not used as service core */ -if (cfg->lcore_role[cfg->main_lcore] ==ROLE_SERVICE ) { +if (runtime_state->lcore_role[cfg->main_lcore] ==ROLE_SERVICE ) {EAL_LOG (ERR ,"Error: Main lcore is used as a service core" );return -1 ; }/* check that we have the core recorded in the core list */ -if (cfg->lcore_role[cfg->main_lcore] !=ROLE_RTE ) { +if (runtime_state->lcore_role[cfg->main_lcore] !=ROLE_RTE ) {EAL_LOG (ERR ,"Error: Main lcore is not enabled for DPDK" );return -1 ; }
@@ -1378,7 +1376,6 @@ check_cpuset(rte_cpuset_t *set)static int eal_parse_lcores (const char *lcores) { -struct rte_config *cfg =rte_eal_get_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();rte_cpuset_t lcore_set;unsigned int set_count;
@@ -1403,7 +1400,7 @@ eal_parse_lcores(const char *lcores)/* Reset lcore config */ rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE );for (idx =0 ; idx <RTE_MAX_LCORE ; idx++) { - cfg->lcore_role[idx] =ROLE_OFF ; + runtime_state->lcore_role[idx] =ROLE_OFF ; runtime_state->lcore_cfg[idx].core_index =-1 ;CPU_ZERO (&runtime_state->lcore_cfg[idx].cpuset); runtime_state->lcore_cfg[idx].first_cpu =UINT16_MAX ;
@@ -1466,10 +1463,10 @@ eal_parse_lcores(const char *lcores)continue ; set_count--; -if (cfg->lcore_role[idx] !=ROLE_RTE ) { +if (runtime_state->lcore_role[idx] !=ROLE_RTE ) {rte_bitset_set (runtime_state->core_indices, count); runtime_state->lcore_cfg[idx].core_index = count; - cfg->lcore_role[idx] =ROLE_RTE ; + runtime_state->lcore_role[idx] =ROLE_RTE ; count++; }
@@ -1496,7 +1493,7 @@ eal_parse_lcores(const char *lcores)if (count ==0 ) goto err; - cfg->lcore_count = count; + runtime_state->lcore_count = count; ret =0 ; err:
lib/eal/common/eal_internal_cfg.h +2 -0
@@ -146,6 +146,8 @@ struct eal_runtime_state {rte_cpuset_t ctrl_cpuset;/**< cpuset for ctrl threads */ volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */ +uint32_t lcore_count;/**< Number of active lcore IDs (role != ROLE_OFF). */ +enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE ];/**< State of cores. */ struct lcore_cfg lcore_cfg[RTE_MAX_LCORE ];RTE_BITSET_DECLARE (core_indices,RTE_MAX_LCORE );/**< currently allocated core_indices */ };
lib/eal/common/eal_private.h +0 -3
@@ -22,9 +22,6 @@*/ struct rte_config {uint32_t main_lcore;/**< Id of the main lcore */ -uint32_t lcore_count;/**< Number of available logical cores. */ -uint32_t service_lcore_count;/**< Number of available service cores. */ -enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE ];/**< State of cores. */ /** Primary or secondary configuration */ enum rte_proc_type_t process_type;
lib/eal/common/rte_service.c +7 -7
@@ -105,9 +105,10 @@ rte_service_init(void)RTE_LCORE_VAR_ALLOC (lcore_states);int i; -struct rte_config *cfg =rte_eal_get_configuration (); +const struct rte_config *cfg =rte_eal_get_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (cfg->lcore_role[i] ==ROLE_SERVICE ) { +if (runtime_state->lcore_role[i] ==ROLE_SERVICE ) {if ((unsigned int )i == cfg->main_lcore)continue ;rte_service_lcore_add (i);
@@ -709,10 +710,9 @@ rte_service_map_lcore_get(uint32_t id, uint32_t lcore)static void set_lcore_state (uint32_t lcore,int32_t state) { -/* mark core state in hugepage backed config */ -struct rte_config *cfg =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct core_state *cs =RTE_LCORE_VAR_LCORE (lcore, lcore_states); - cfg->lcore_role[lcore] = state; + runtime_state->lcore_role[lcore] = state;/* update per-lcore optimized state tracking */ cs->is_service_core = (state ==ROLE_SERVICE );
@@ -1101,7 +1101,7 @@ RTE_EXPORT_SYMBOL(rte_service_dump)int32_t rte_service_dump (FILE *f,uint32_t id) { -struct rte_config *cfg =rte_eal_get_configuration (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();uint32_t i;int print_one = (id !=UINT32_MAX );
@@ -1124,7 +1124,7 @@ rte_service_dump(FILE *f, uint32_t id)fprintf (f,"Service Cores Summary\n" );for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (cfg->lcore_role[i] !=ROLE_SERVICE ) +if (runtime_state->lcore_role[i] !=ROLE_SERVICE )continue ;service_dump_calls_per_lcore (f, i);
Signature · 1 line
2.53.0
PATCH v2 20/39 eal: make lcore role a field in lcore config struct
In reply to Bruce RichardsonRather than having a separate array for lcore role, just make the role a field in the lcore_cfg struct.
--- lib/eal/common/eal_common_lcore.c | 28 ++++++++++++++-------------- lib/eal/common/eal_common_options.c | 26 +++++++++++++------------- lib/eal/common/eal_internal_cfg.h | 2 +- lib/eal/common/rte_service.c | 6 +++--- 4 files changed, 31 insertions(+), 31 deletions(-)
lib/eal/common/eal_common_lcore.c +14 -14
@@ -89,7 +89,7 @@ rte_eal_lcore_role(unsigned int lcore_id)if (lcore_id >=RTE_MAX_LCORE )return ROLE_OFF ; -return runtime_state->lcore_role[lcore_id]; +return runtime_state->lcore_cfg[lcore_id].role; }RTE_EXPORT_SYMBOL (rte_lcore_has_role)
@@ -101,7 +101,7 @@ rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role)if (lcore_id >=RTE_MAX_LCORE )return 0 ; -return runtime_state->lcore_role[lcore_id] == role; +return runtime_state->lcore_cfg[lcore_id].role == role; }RTE_EXPORT_SYMBOL (rte_lcore_is_enabled)
@@ -111,7 +111,7 @@ int rte_lcore_is_enabled(unsigned int lcore_id)if (lcore_id >=RTE_MAX_LCORE )return 0 ; -return runtime_state->lcore_role[lcore_id] ==ROLE_RTE ; +return runtime_state->lcore_cfg[lcore_id].role ==ROLE_RTE ; }RTE_EXPORT_SYMBOL (rte_get_next_lcore)
@@ -339,7 +339,7 @@ rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,if (callback->init ==NULL ) goto no_init;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { -if (runtime_state->lcore_role[lcore_id] ==ROLE_OFF ) +if (runtime_state->lcore_cfg[lcore_id].role ==ROLE_OFF )continue ;if (callback_init (callback, lcore_id) ==0 )continue ;
@@ -347,7 +347,7 @@ rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,* previous lcore. */ while (lcore_id-- !=0 ) { -if (runtime_state->lcore_role[lcore_id] ==ROLE_OFF ) +if (runtime_state->lcore_cfg[lcore_id].role ==ROLE_OFF )continue ;callback_uninit (callback, lcore_id); }
@@ -379,7 +379,7 @@ rte_lcore_callback_unregister(void *handle)if (callback->uninit ==NULL ) goto no_uninit;for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { -if (runtime_state->lcore_role[lcore_id] ==ROLE_OFF ) +if (runtime_state->lcore_cfg[lcore_id].role ==ROLE_OFF )continue ;callback_uninit (callback, lcore_id); }
@@ -408,11 +408,11 @@ eal_lcore_non_eal_allocate(void) goto out; }for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { -if (runtime_state->lcore_role[lcore_id] !=ROLE_OFF ) +if (runtime_state->lcore_cfg[lcore_id].role !=ROLE_OFF )continue ;rte_bitset_set (runtime_state->core_indices, core_index); runtime_state->lcore_cfg[lcore_id].core_index = core_index; - runtime_state->lcore_role[lcore_id] =ROLE_NON_EAL ; + runtime_state->lcore_cfg[lcore_id].role =ROLE_NON_EAL ; runtime_state->lcore_count++;break ; }
@@ -436,7 +436,7 @@ eal_lcore_non_eal_allocate(void)rte_bitset_clear (runtime_state->core_indices, runtime_state->lcore_cfg[lcore_id].core_index); runtime_state->lcore_cfg[lcore_id].core_index =-1 ; - runtime_state->lcore_role[lcore_id] =ROLE_OFF ; + runtime_state->lcore_cfg[lcore_id].role =ROLE_OFF ; runtime_state->lcore_count--; lcore_id =RTE_MAX_LCORE ; goto out;
@@ -453,14 +453,14 @@ eal_lcore_non_eal_release(unsigned int lcore_id)struct lcore_callback *callback;rte_rwlock_write_lock (&lcore_lock); -if (runtime_state->lcore_role[lcore_id] !=ROLE_NON_EAL ) +if (runtime_state->lcore_cfg[lcore_id].role !=ROLE_NON_EAL ) goto out; TAILQ_FOREACH(callback, &lcore_callbacks, next)callback_uninit (callback, lcore_id);rte_bitset_clear (runtime_state->core_indices, runtime_state->lcore_cfg[lcore_id].core_index); runtime_state->lcore_cfg[lcore_id].core_index =-1 ; - runtime_state->lcore_role[lcore_id] =ROLE_OFF ; + runtime_state->lcore_cfg[lcore_id].role =ROLE_OFF ; runtime_state->lcore_count--; out:rte_rwlock_write_unlock (&lcore_lock);
@@ -476,7 +476,7 @@ rte_lcore_iterate(rte_lcore_iterate_cb cb, void *arg)rte_rwlock_read_lock (&lcore_lock);for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { -if (runtime_state->lcore_role[lcore_id] ==ROLE_OFF ) +if (runtime_state->lcore_cfg[lcore_id].role ==ROLE_OFF )continue ; ret =cb (lcore_id, arg);if (ret !=0 )
@@ -541,7 +541,7 @@ lcore_dump_cb(unsigned int lcore_id, void *arg) cpuset =eal_cpuset_to_str (&runtime_state->lcore_cfg[lcore_id].cpuset);fprintf (f,"lcore %u, socket %u, role %s, cpuset %s\n" , lcore_id,rte_lcore_to_socket_id (lcore_id), -lcore_role_str (runtime_state->lcore_role[lcore_id]), +lcore_role_str (runtime_state->lcore_cfg[lcore_id].role), cpuset !=NULL ? cpuset :"<unknown>" );free (cpuset);free (usage_str);
@@ -608,7 +608,7 @@ lcore_telemetry_info_cb(unsigned int lcore_id, void *arg)rte_tel_data_add_dict_int (info->d,"lcore_id" , lcore_id);rte_tel_data_add_dict_int (info->d,"socket" ,rte_lcore_to_socket_id (lcore_id));rte_tel_data_add_dict_string (info->d,"role" , -lcore_role_str (runtime_state->lcore_role[lcore_id])); +lcore_role_str (runtime_state->lcore_cfg[lcore_id].role)); cpuset =rte_tel_data_alloc ();if (cpuset ==NULL )return -ENOMEM ;
lib/eal/common/eal_common_options.c +13 -13
@@ -907,10 +907,10 @@ eal_parse_service_coremask(const char *coremask)return -1 ; } -if (runtime_state->lcore_role[idx] ==ROLE_RTE ) +if (runtime_state->lcore_cfg[idx].role ==ROLE_RTE ) taken_lcore_count++; - runtime_state->lcore_role[idx] =ROLE_SERVICE ; + runtime_state->lcore_cfg[idx].role =ROLE_SERVICE ; count++; } }
@@ -946,7 +946,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)/* set everything to disabled first, then set up values */ rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE );for (i =0 ; i <RTE_MAX_LCORE ; i++) { - runtime_state->lcore_role[i] =ROLE_OFF ; + runtime_state->lcore_cfg[i].role =ROLE_OFF ; runtime_state->lcore_cfg[i].core_index =-1 ; }
@@ -975,7 +975,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base) }rte_bitset_set (runtime_state->core_indices, count); - runtime_state->lcore_role[lcore_id] =ROLE_RTE ; + runtime_state->lcore_cfg[lcore_id].role =ROLE_RTE ; runtime_state->lcore_cfg[lcore_id].core_index = count;CPU_ZERO (&runtime_state->lcore_cfg[lcore_id].cpuset);CPU_SET (i, &runtime_state->lcore_cfg[lcore_id].cpuset);
@@ -1148,11 +1148,11 @@ eal_parse_service_corelist(const char *corelist)if (min ==RTE_MAX_LCORE ) min = idx;for (idx = min; idx <= max; idx++) { -if (runtime_state->lcore_role[idx] !=ROLE_SERVICE ) { -if (runtime_state->lcore_role[idx] ==ROLE_RTE ) +if (runtime_state->lcore_cfg[idx].role !=ROLE_SERVICE ) { +if (runtime_state->lcore_cfg[idx].role ==ROLE_RTE ) taken_lcore_count++; - runtime_state->lcore_role[idx] =ROLE_SERVICE ; + runtime_state->lcore_cfg[idx].role =ROLE_SERVICE ; count++; } }
@@ -1175,7 +1175,7 @@ eal_parse_service_corelist(const char *corelist)rte_cpuset_t service_cpuset;CPU_ZERO (&service_cpuset);for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (runtime_state->lcore_role[i] ==ROLE_SERVICE ) +if (runtime_state->lcore_cfg[i].role ==ROLE_SERVICE )CPU_SET (i, &service_cpuset); }if (CPU_COUNT (&service_cpuset) >0 ) {
@@ -1205,12 +1205,12 @@ eal_parse_main_lcore(const char *arg)return -1 ;/* ensure main core is not used as service core */ -if (runtime_state->lcore_role[cfg->main_lcore] ==ROLE_SERVICE ) { +if (runtime_state->lcore_cfg[cfg->main_lcore].role ==ROLE_SERVICE ) {EAL_LOG (ERR ,"Error: Main lcore is used as a service core" );return -1 ; }/* check that we have the core recorded in the core list */ -if (runtime_state->lcore_role[cfg->main_lcore] !=ROLE_RTE ) { +if (runtime_state->lcore_cfg[cfg->main_lcore].role !=ROLE_RTE ) {EAL_LOG (ERR ,"Error: Main lcore is not enabled for DPDK" );return -1 ; }
@@ -1400,7 +1400,7 @@ eal_parse_lcores(const char *lcores)/* Reset lcore config */ rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE );for (idx =0 ; idx <RTE_MAX_LCORE ; idx++) { - runtime_state->lcore_role[idx] =ROLE_OFF ; + runtime_state->lcore_cfg[idx].role =ROLE_OFF ; runtime_state->lcore_cfg[idx].core_index =-1 ;CPU_ZERO (&runtime_state->lcore_cfg[idx].cpuset); runtime_state->lcore_cfg[idx].first_cpu =UINT16_MAX ;
@@ -1463,10 +1463,10 @@ eal_parse_lcores(const char *lcores)continue ; set_count--; -if (runtime_state->lcore_role[idx] !=ROLE_RTE ) { +if (runtime_state->lcore_cfg[idx].role !=ROLE_RTE ) {rte_bitset_set (runtime_state->core_indices, count); runtime_state->lcore_cfg[idx].core_index = count; - runtime_state->lcore_role[idx] =ROLE_RTE ; + runtime_state->lcore_cfg[idx].role =ROLE_RTE ; count++; }
lib/eal/common/eal_internal_cfg.h +1 -1
@@ -123,6 +123,7 @@ struct eal_platform_info {*/ struct lcore_cfg {int core_index;/**< relative index, starting from 0 */ +enum rte_lcore_role_t role;/**< role assigned to this lcore */ rte_cpuset_t cpuset;/**< cpu set which the lcore affinity to */ uint16_t first_cpu;/**< lowest CPU set in cpuset, UINT16_MAX if none */ /* Fields for executing code on a remote lcore */
@@ -147,7 +148,6 @@ struct eal_runtime_state {volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */ uint32_t lcore_count;/**< Number of active lcore IDs (role != ROLE_OFF). */ -enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE ];/**< State of cores. */ struct lcore_cfg lcore_cfg[RTE_MAX_LCORE ];RTE_BITSET_DECLARE (core_indices,RTE_MAX_LCORE );/**< currently allocated core_indices */ };
lib/eal/common/rte_service.c +3 -3
@@ -108,7 +108,7 @@ rte_service_init(void)const struct rte_config *cfg =rte_eal_get_configuration ();const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (runtime_state->lcore_role[i] ==ROLE_SERVICE ) { +if (runtime_state->lcore_cfg[i].role ==ROLE_SERVICE ) {if ((unsigned int )i == cfg->main_lcore)continue ;rte_service_lcore_add (i);
@@ -712,7 +712,7 @@ set_lcore_state(uint32_t lcore, int32_t state) {struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct core_state *cs =RTE_LCORE_VAR_LCORE (lcore, lcore_states); - runtime_state->lcore_role[lcore] = state; + runtime_state->lcore_cfg[lcore].role = state;/* update per-lcore optimized state tracking */ cs->is_service_core = (state ==ROLE_SERVICE );
@@ -1124,7 +1124,7 @@ rte_service_dump(FILE *f, uint32_t id)fprintf (f,"Service Cores Summary\n" );for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (runtime_state->lcore_role[i] !=ROLE_SERVICE ) +if (runtime_state->lcore_cfg[i].role !=ROLE_SERVICE )continue ;service_dump_calls_per_lcore (f, i);
Signature · 1 line
2.53.0
PATCH v2 21/39 eal: move main lcore setting to runtime config struct
In reply to Bruce RichardsonMove the main lcore setting from the rte_config struct to the new runtime structure. One additional wrinkle here is that this is an optional user setting, so it also needs to be stored in eal_user_cfg if specified. The difference is that the eal_user_cfg value is the raw value and can be "-1" if unspecified, while the runtime config value has to have a valid lcore id.
--- lib/eal/common/eal_common_dynmem.c | 4 +--- lib/eal/common/eal_common_lcore.c | 2 +- lib/eal/common/eal_common_options.c | 32 ++++++++++++++++------------- lib/eal/common/eal_internal_cfg.h | 2 ++ lib/eal/common/eal_private.h | 1 - lib/eal/common/rte_service.c | 3 +-- lib/eal/freebsd/eal.c | 12 +++++------ lib/eal/linux/eal.c | 12 +++++------ lib/eal/linux/eal_memory.c | 3 +-- lib/eal/windows/eal.c | 9 ++++---- 10 files changed, 38 insertions(+), 42 deletions(-)
lib/eal/common/eal_common_dynmem.c +1 -3
@@ -420,11 +420,9 @@ eal_dynmem_calc_num_pages_per_socket( total_size = user_cfg->memory;for (socket =0 ; socket <RTE_MAX_NUMA_NODES && total_size !=0 ; socket++) { -struct rte_config *cfg =rte_eal_get_configuration ();unsigned int main_lcore_socket; - main_lcore_socket = -rte_lcore_to_socket_id (cfg->main_lcore); + main_lcore_socket =rte_lcore_to_socket_id (rte_get_main_lcore ());if (main_lcore_socket != socket)continue ;
lib/eal/common/eal_common_lcore.c +1 -1
@@ -23,7 +23,7 @@RTE_EXPORT_SYMBOL (rte_get_main_lcore) unsigned int rte_get_main_lcore(void) { -return rte_eal_get_configuration ()->main_lcore; +return eal_get_runtime_state ()->main_lcore; }RTE_EXPORT_SYMBOL (rte_lcore_count)
lib/eal/common/eal_common_options.c +18 -14
@@ -1194,23 +1194,24 @@ static int eal_parse_main_lcore(const char *arg) {char *parsing_end; -struct rte_config *cfg =rte_eal_get_configuration (); -const struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +long main_lcore; +struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); errno =0 ; - cfg->main_lcore = (uint32_t )strtol (arg, &parsing_end,0 ); -if (errno || parsing_end[0 ] !=0 ) -return -1 ; -if (cfg->main_lcore >=RTE_MAX_LCORE ) + main_lcore =strtol (arg, &parsing_end,0 ); +if (errno || parsing_end[0 ] !=0 || main_lcore <0 || + main_lcore >=RTE_MAX_LCORE )return -1 ; + user_cfg->main_lcore = (int )main_lcore;/* ensure main core is not used as service core */ -if (runtime_state->lcore_cfg[cfg->main_lcore].role ==ROLE_SERVICE ) { +if (runtime_state->lcore_cfg[user_cfg->main_lcore].role ==ROLE_SERVICE ) {EAL_LOG (ERR ,"Error: Main lcore is used as a service core" );return -1 ; }/* check that we have the core recorded in the core list */ -if (runtime_state->lcore_cfg[cfg->main_lcore].role !=ROLE_RTE ) { +if (runtime_state->lcore_cfg[user_cfg->main_lcore].role !=ROLE_RTE ) {EAL_LOG (ERR ,"Error: Main lcore is not enabled for DPDK" );return -1 ; }
@@ -2078,7 +2079,7 @@ inteal_parse_args (void) {struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -struct rte_config *rte_cfg =rte_eal_get_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 ;
@@ -2202,13 +2203,16 @@ eal_parse_args(void)return -1 ; } } -if (args.main_lcore !=NULL ) { -if (eal_parse_main_lcore (args.main_lcore) <0 ) -return -1 ; + user_cfg->main_lcore =-1 ; +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 */ - rte_cfg->main_lcore =rte_get_next_lcore (-1 ,0 ,0 ); -if (rte_cfg->main_lcore >=RTE_MAX_LCORE ) { + 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 ; }
lib/eal/common/eal_internal_cfg.h +2 -0
@@ -93,6 +93,7 @@ struct eal_user_cfg {uint64_t limit;/**< memory limit in bytes */ } pagesz_mem_overrides[MAX_HUGEPAGE_SIZES ];unsigned int num_pagesz_mem_overrides;/**< number of stored overrides */ +int main_lcore;/**< ID of the main lcore */ };/**
@@ -147,6 +148,7 @@ struct eal_runtime_state {rte_cpuset_t ctrl_cpuset;/**< cpuset for ctrl threads */ volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */ +uint32_t main_lcore;/**< ID of the main lcore */ uint32_t lcore_count;/**< Number of active lcore IDs (role != ROLE_OFF). */ struct lcore_cfg lcore_cfg[RTE_MAX_LCORE ];RTE_BITSET_DECLARE (core_indices,RTE_MAX_LCORE );/**< currently allocated core_indices */
lib/eal/common/eal_private.h +0 -1
@@ -21,7 +21,6 @@* The global RTE configuration structure. */ struct rte_config { -uint32_t main_lcore;/**< Id of the main lcore */ /** Primary or secondary configuration */ enum rte_proc_type_t process_type;
lib/eal/common/rte_service.c +1 -2
@@ -105,11 +105,10 @@ rte_service_init(void)RTE_LCORE_VAR_ALLOC (lcore_states);int i; -const struct rte_config *cfg =rte_eal_get_configuration ();const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();for (i =0 ; i <RTE_MAX_LCORE ; i++) {if (runtime_state->lcore_cfg[i].role ==ROLE_SERVICE ) { -if ((unsigned int )i == cfg->main_lcore) +if ((unsigned int )i == runtime_state->main_lcore)continue ;rte_service_lcore_add (i); }
lib/eal/freebsd/eal.c +5 -7
@@ -358,9 +358,8 @@ static voideal_check_mem_on_local_socket (void) {int socket_id; -const struct rte_config *config =rte_eal_get_configuration (); - socket_id =rte_lcore_to_socket_id (config->main_lcore); + socket_id =rte_lcore_to_socket_id (rte_get_main_lcore ());if (rte_memseg_list_walk (check_socket, &socket_id) ==0 )EAL_LOG (WARNING ,"WARNING: Main core has no memory on local socket!" );
@@ -403,7 +402,6 @@ rte_eal_init(int argc, char **argv)uint32_t has_run =0 ;char cpuset[RTE_CPU_AFFINITY_STR_LEN ];char thread_name[RTE_THREAD_NAME_SIZE ]; -const struct rte_config *config =rte_eal_get_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();bool has_phys_addr;
@@ -653,18 +651,18 @@ rte_eal_init(int argc, char **argv)eal_check_mem_on_local_socket ();if (rte_thread_set_affinity_by_id (rte_thread_self (), - &runtime_state->lcore_cfg[config->main_lcore].cpuset) !=0 ) { + &runtime_state->lcore_cfg[rte_get_main_lcore ()].cpuset) !=0 ) {rte_eal_init_alert ("Cannot set affinity" ); rte_errno =EINVAL ; goto err_out; } -__rte_thread_init (config->main_lcore, - &runtime_state->lcore_cfg[config->main_lcore].cpuset); +__rte_thread_init (rte_get_main_lcore (), + &runtime_state->lcore_cfg[rte_get_main_lcore ()].cpuset); ret =eal_thread_dump_current_affinity (cpuset,sizeof (cpuset));EAL_LOG (DEBUG ,"Main lcore %u is ready (tid=%zx;cpuset=[%s%s])" , - config->main_lcore, (uintptr_t )pthread_self (), cpuset, +rte_get_main_lcore (), (uintptr_t )pthread_self (), cpuset, ret ==0 ?"" :"..." );RTE_LCORE_FOREACH_WORKER (i) {
lib/eal/linux/eal.c +5 -7
@@ -439,9 +439,8 @@ static voideal_check_mem_on_local_socket (void) {int socket_id; -const struct rte_config *config =rte_eal_get_configuration (); - socket_id =rte_lcore_to_socket_id (config->main_lcore); + socket_id =rte_lcore_to_socket_id (rte_get_main_lcore ());if (rte_memseg_list_walk (check_socket, &socket_id) ==0 )EAL_LOG (WARNING ,"WARNING: Main core has no memory on local socket!" );
@@ -566,7 +565,6 @@ rte_eal_init(int argc, char **argv)char cpuset[RTE_CPU_AFFINITY_STR_LEN ];char thread_name[RTE_THREAD_NAME_SIZE ];bool phys_addrs; -const struct rte_config *config =rte_eal_get_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();
@@ -829,17 +827,17 @@ rte_eal_init(int argc, char **argv)eal_check_mem_on_local_socket ();if (rte_thread_set_affinity_by_id (rte_thread_self (), - &runtime_state->lcore_cfg[config->main_lcore].cpuset) !=0 ) { + &runtime_state->lcore_cfg[rte_get_main_lcore ()].cpuset) !=0 ) {rte_eal_init_alert ("Cannot set affinity" ); rte_errno =EINVAL ; goto err_out; } -__rte_thread_init (config->main_lcore, - &runtime_state->lcore_cfg[config->main_lcore].cpuset); +__rte_thread_init (rte_get_main_lcore (), + &runtime_state->lcore_cfg[rte_get_main_lcore ()].cpuset); ret =eal_thread_dump_current_affinity (cpuset,sizeof (cpuset));EAL_LOG (DEBUG ,"Main lcore %u is ready (tid=%zx;cpuset=[%s%s])" , - config->main_lcore, (uintptr_t )pthread_self (), cpuset, +rte_get_main_lcore (), (uintptr_t )pthread_self (), cpuset, ret ==0 ?"" :"..." );RTE_LCORE_FOREACH_WORKER (i) {
lib/eal/linux/eal_memory.c +1 -2
@@ -1762,7 +1762,6 @@ memseg_primary_init_32(void)int hp_sizes = (int ) platform_info->num_hugepage_sizes;uint64_t max_socket_mem, cur_socket_mem;unsigned int main_lcore_socket; -struct rte_config *cfg =rte_eal_get_configuration ();bool skip;int ret;
@@ -1785,7 +1784,7 @@ memseg_primary_init_32(void)/* ...or if we didn't specifically request memory on *any* * socket, and this is not main lcore */ - main_lcore_socket =rte_lcore_to_socket_id (cfg->main_lcore); + main_lcore_socket =rte_lcore_to_socket_id (rte_get_main_lcore ()); skip |= active_sockets ==0 && socket_id != main_lcore_socket;if (skip) {
lib/eal/windows/eal.c +4 -5
@@ -154,7 +154,6 @@ int rte_eal_init(int argc, char **argv) { int i, fctret, bscan; -const struct rte_config *config =rte_eal_get_configuration ();struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();bool has_phys_addr;
@@ -346,17 +345,17 @@ rte_eal_init(int argc, char **argv)eal_rand_init ();if (rte_thread_set_affinity_by_id (rte_thread_self (), - &runtime_state->lcore_cfg[config->main_lcore].cpuset) !=0 ) { + &runtime_state->lcore_cfg[rte_get_main_lcore ()].cpuset) !=0 ) {rte_eal_init_alert ("Cannot set affinity" ); rte_errno =EINVAL ; goto err_out; } -__rte_thread_init (config->main_lcore, - &runtime_state->lcore_cfg[config->main_lcore].cpuset); +__rte_thread_init (rte_get_main_lcore (), + &runtime_state->lcore_cfg[rte_get_main_lcore ()].cpuset); ret =eal_thread_dump_current_affinity (cpuset,sizeof (cpuset));EAL_LOG (DEBUG ,"Main lcore %u is ready (tid=%zx;cpuset=[%s%s])" , - config->main_lcore,rte_thread_self ().opaque_id, cpuset, +rte_get_main_lcore (),rte_thread_self ().opaque_id, cpuset, ret ==0 ?"" :"..." );RTE_LCORE_FOREACH_WORKER (i) {
Signature · 1 line
2.53.0
PATCH v2 22/39 eal: move IOVA mode and process type to runtime cfg
In reply to Bruce RichardsonMove two more fields, iova_mode and process_type from old rte_config to eal_runtime_state struct.
--- lib/eal/common/eal_common_config.c | 4 ++-- lib/eal/common/eal_common_mcfg.c | 2 +- lib/eal/common/eal_internal_cfg.h | 2 ++ lib/eal/common/eal_private.h | 7 ------- lib/eal/freebsd/eal.c | 11 +++++------ lib/eal/linux/eal.c | 13 ++++++------- lib/eal/windows/eal.c | 2 +- 7 files changed, 17 insertions(+), 24 deletions(-)
lib/eal/common/eal_common_config.c +2 -2
@@ -88,7 +88,7 @@ RTE_EXPORT_SYMBOL(rte_eal_iova_mode)enum rte_iova_mode rte_eal_iova_mode (void ) { -return rte_eal_get_configuration ()->iova_mode; +return eal_get_runtime_state ()->iova_mode; }/* Get the EAL base address */
@@ -105,7 +105,7 @@ RTE_EXPORT_SYMBOL(rte_eal_process_type)enum rte_proc_type_t rte_eal_process_type (void ) { -return rte_config.process_type; +return eal_get_runtime_state ()->process_type; }/* Return user provided mbuf pool ops name */
lib/eal/common/eal_common_mcfg.c +1 -1
@@ -18,7 +18,7 @@ eal_mcfg_complete(void)struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* ALL shared mem_config related INIT DONE */ -if (cfg->process_type ==RTE_PROC_PRIMARY ) +if (runtime_state->process_type ==RTE_PROC_PRIMARY ) mcfg->magic =RTE_MAGIC ; runtime_state->init_complete =1 ;
lib/eal/common/eal_internal_cfg.h +2 -0
@@ -148,6 +148,8 @@ struct eal_runtime_state {rte_cpuset_t ctrl_cpuset;/**< cpuset for ctrl threads */ volatile unsigned int init_complete;/**< indicates whether EAL has completed initialization */ +enum rte_proc_type_t process_type;/**< primary or secondary process */ +enum rte_iova_mode iova_mode;/**< PA or VA IOVA mapping mode */ uint32_t main_lcore;/**< ID of the main lcore */ uint32_t lcore_count;/**< Number of active lcore IDs (role != ROLE_OFF). */ struct lcore_cfg lcore_cfg[RTE_MAX_LCORE ];
lib/eal/common/eal_private.h +0 -7
@@ -21,13 +21,6 @@* The global RTE configuration structure. */ struct rte_config { - -/** Primary or secondary configuration */ -enum rte_proc_type_t process_type; - -/** PA or VA mapping mode */ -enum rte_iova_mode iova_mode; -/** * Pointer to memory configuration, which may be shared across multiple * DPDK instances
lib/eal/freebsd/eal.c +5 -6
@@ -284,12 +284,12 @@ eal_proc_type_detect(void)static int rte_config_init (void ) { -struct rte_config *config =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); - config->process_type = user_cfg->process_type; + runtime_state->process_type = user_cfg->process_type; -switch (config->process_type) { +switch (runtime_state->process_type) {case RTE_PROC_PRIMARY :if (rte_eal_config_create () <0 )return -1 ;
@@ -313,8 +313,7 @@ rte_config_init(void)break ;case RTE_PROC_AUTO :case RTE_PROC_INVALID : -EAL_LOG (ERR ,"Invalid process type %d" , - config->process_type); +EAL_LOG (ERR ,"Invalid process type %d" , runtime_state->process_type);return -1 ; }
@@ -560,7 +559,7 @@ rte_eal_init(int argc, char **argv) goto err_out; } -rte_eal_get_configuration ()->iova_mode = iova_mode; + runtime_state->iova_mode = iova_mode;EAL_LOG (INFO ,"Selected IOVA mode '%s'" ,rte_eal_iova_mode () ==RTE_IOVA_PA ?"PA" :"VA" );
lib/eal/linux/eal.c +6 -7
@@ -368,12 +368,12 @@ eal_proc_type_detect(void)static int rte_config_init (void ) { -struct rte_config *config =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); - config->process_type = user_cfg->process_type; + runtime_state->process_type = user_cfg->process_type; -switch (config->process_type) { +switch (runtime_state->process_type) {case RTE_PROC_PRIMARY :if (rte_eal_config_create () <0 )return -1 ;
@@ -398,7 +398,7 @@ rte_config_init(void)case RTE_PROC_AUTO :case RTE_PROC_INVALID :EAL_LOG (ERR ,"Invalid process type %d" , - config->process_type); + runtime_state->process_type);return -1 ; }
@@ -707,10 +707,9 @@ rte_eal_init(int argc, char **argv)EAL_LOG (DEBUG ,"IOMMU is not available, selecting IOVA as PA mode." ); } } -rte_eal_get_configuration ()->iova_mode = iova_mode; + runtime_state->iova_mode = iova_mode; }else { -rte_eal_get_configuration ()->iova_mode = - user_cfg->iova_mode; + runtime_state->iova_mode = user_cfg->iova_mode; }if (rte_eal_iova_mode () ==RTE_IOVA_PA && !phys_addrs) {
lib/eal/windows/eal.c +1 -1
@@ -304,7 +304,7 @@ rte_eal_init(int argc, char **argv)EAL_LOG (DEBUG ,"Selected IOVA mode '%s'" , iova_mode ==RTE_IOVA_PA ?"PA" :"VA" ); -rte_eal_get_configuration ()->iova_mode = iova_mode; + runtime_state->iova_mode = iova_mode;if (rte_eal_memzone_init () <0 ) {rte_eal_init_alert ("Cannot init memzone" );
Signature · 1 line
2.53.0
PATCH v2 23/39 eal: move memory config pointer to runtime state struct
In reply to Bruce RichardsonRemove the final field from the rte_config struct - the mem_config pointer - and put it in the runtime state structure instead. The rte_config struct is now unused and ready for removal in a later commit.
--- lib/eal/common/eal_common_config.c | 15 ++++++--- lib/eal/common/eal_common_dynmem.c | 2 +- lib/eal/common/eal_common_mcfg.c | 23 ++++++------- lib/eal/common/eal_common_memory.c | 52 ++++++++++++++--------------- lib/eal/common/eal_common_memzone.c | 20 +++++------ lib/eal/common/eal_common_proc.c | 2 +- lib/eal/common/eal_common_tailqs.c | 6 ++-- lib/eal/common/eal_common_timer.c | 2 +- lib/eal/common/eal_internal_cfg.h | 4 +++ lib/eal/common/eal_memcfg.h | 3 ++ lib/eal/common/eal_private.h | 6 +--- lib/eal/common/malloc_heap.c | 22 ++++++------ lib/eal/common/malloc_mp.c | 2 +- lib/eal/common/rte_malloc.c | 14 ++++---- lib/eal/freebsd/eal.c | 22 ++++++------ lib/eal/freebsd/eal_memory.c | 6 ++-- lib/eal/linux/eal.c | 24 ++++++------- lib/eal/linux/eal_memalloc.c | 18 +++++----- lib/eal/linux/eal_memory.c | 14 ++++---- lib/eal/windows/eal.c | 6 ++-- lib/eal/windows/eal_memalloc.c | 4 +-- lib/eal/windows/eal_memory.c | 2 +- 22 files changed, 138 insertions(+), 131 deletions(-)
lib/eal/common/eal_common_config.c +11 -4
@@ -21,9 +21,7 @@ static struct rte_mem_config early_mem_config = { };/* Address of global and public configuration */ -static struct rte_config rte_config = { - .mem_config = &early_mem_config, -}; +static struct rte_config rte_config;/* platform-specific runtime dir */ static char runtime_dir[UNIX_PATH_MAX ];
@@ -35,7 +33,9 @@ static struct eal_user_cfg eal_user_cfg;static struct eal_platform_info eal_platform_info;/* internal runtime configuration */ -static struct eal_runtime_state eal_runtime_state; +static struct eal_runtime_state eal_runtime_state = { + .mem_config = &early_mem_config, +};RTE_EXPORT_SYMBOL (rte_eal_get_runtime_dir) const char *
@@ -63,6 +63,13 @@ rte_eal_get_configuration(void)return &rte_config; } +/* Return a pointer to the memory config structure */ +struct rte_mem_config * +eal_get_mcfg (void ) +{ +return eal_get_runtime_state ()->mem_config; +} +/* Return a pointer to the user configuration structure */ struct eal_user_cfg *eal_get_user_configuration (void )
lib/eal/common/eal_common_dynmem.c +1 -1
@@ -20,7 +20,7 @@int eal_dynmem_memseg_lists_init (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct memtype {uint64_t page_sz;int socket_id;
lib/eal/common/eal_common_mcfg.c +11 -12
@@ -13,8 +13,7 @@void eal_mcfg_complete (void ) { -struct rte_config *cfg =rte_eal_get_configuration (); -struct rte_mem_config *mcfg = cfg->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* ALL shared mem_config related INIT DONE */
@@ -27,7 +26,7 @@ eal_mcfg_complete(void)void eal_mcfg_wait_complete (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();/* wait until shared mem_config finish initialising */ rte_wait_until_equal_32 (&mcfg->magic,RTE_MAGIC , rte_memory_order_relaxed);
@@ -36,7 +35,7 @@ eal_mcfg_wait_complete(void)int eal_mcfg_check_version (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();/* check if version from memconfig matches compiled in macro */ if (mcfg->version !=RTE_VERSION )
@@ -48,7 +47,7 @@ eal_mcfg_check_version(void)void eal_mcfg_update_internal (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct eal_user_cfg *user_cfg =eal_get_user_configuration (); user_cfg->legacy_mem = mcfg->legacy_mem;
@@ -58,7 +57,7 @@ eal_mcfg_update_internal(void)void eal_mcfg_update_from_internal (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); mcfg->legacy_mem = user_cfg->legacy_mem;
@@ -71,7 +70,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_mcfg_mem_get_lock)rte_rwlock_t *rte_mcfg_mem_get_lock (void ) { -return &rte_eal_get_configuration ()->mem_config->memory_hotplug_lock; +return &eal_get_mcfg ()->memory_hotplug_lock; }RTE_EXPORT_SYMBOL (rte_mcfg_mem_read_lock)
@@ -106,7 +105,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_mcfg_tailq_get_lock)rte_rwlock_t *rte_mcfg_tailq_get_lock (void ) { -return &rte_eal_get_configuration ()->mem_config->qlock; +return &eal_get_mcfg ()->qlock; }RTE_EXPORT_SYMBOL (rte_mcfg_tailq_read_lock)
@@ -141,7 +140,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_mcfg_mempool_get_lock)rte_rwlock_t *rte_mcfg_mempool_get_lock (void ) { -return &rte_eal_get_configuration ()->mem_config->mplock; +return &eal_get_mcfg ()->mplock; }RTE_EXPORT_SYMBOL (rte_mcfg_mempool_read_lock)
@@ -176,7 +175,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_mcfg_timer_get_lock)rte_spinlock_t *rte_mcfg_timer_get_lock (void ) { -return &rte_eal_get_configuration ()->mem_config->tlock; +return &eal_get_mcfg ()->tlock; }RTE_EXPORT_SYMBOL (rte_mcfg_timer_lock)
@@ -197,13 +196,13 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_mcfg_ethdev_get_lock)rte_spinlock_t *rte_mcfg_ethdev_get_lock (void ) { -return &rte_eal_get_configuration ()->mem_config->ethdev_lock; +return &eal_get_mcfg ()->ethdev_lock; }RTE_EXPORT_SYMBOL (rte_mcfg_get_single_file_segments) boolrte_mcfg_get_single_file_segments (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();return (bool )mcfg->single_file_segments; }
lib/eal/common/eal_common_memory.c +25 -27
201 lines not on this page · raw message
lib/eal/common/eal_common_memzone.c +10 -10
@@ -39,7 +39,7 @@ rte_memzone_max_set(size_t max)return -1 ; } - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg ();if (mcfg ==NULL ) {EAL_LOG (ERR ,"Failed to set max memzone count" );return -1 ;
@@ -56,7 +56,7 @@ rte_memzone_max_get(void) {struct rte_mem_config *mcfg; - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg ();if (mcfg ==NULL || mcfg->max_memzone ==0 )return DEFAULT_MAX_MEMZONE_COUNT ;
@@ -72,7 +72,7 @@ memzone_lookup_thread_unsafe(const char *name)int i =0 ;/* get pointer to global configuration */ - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg (); arr = &mcfg->memzones;/*
@@ -116,7 +116,7 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,bool contig;/* get pointer to global configuration */ - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg (); arr = &mcfg->memzones;/* no more room in config */
@@ -248,7 +248,7 @@ rte_memzone_reserve_thread_safe(const char *name, size_t len, int socket_id,const struct rte_memzone *mz =NULL ;/* get pointer to global configuration */ - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg ();rte_rwlock_write_lock (&mcfg->mlock);
@@ -319,7 +319,7 @@ rte_memzone_free(const struct rte_memzone *mz)return -EINVAL ;rte_strlcpy (name, mz->name,RTE_MEMZONE_NAMESIZE ); - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg (); arr = &mcfg->memzones;rte_rwlock_write_lock (&mcfg->mlock);
@@ -357,7 +357,7 @@ rte_memzone_lookup(const char *name)struct rte_mem_config *mcfg;const struct rte_memzone *memzone =NULL ; - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg ();rte_rwlock_read_lock (&mcfg->mlock);
@@ -377,7 +377,7 @@ struct memzone_info {static void dump_memzone (const struct rte_memzone *mz,void *arg) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct rte_memseg_list *msl =NULL ;struct memzone_info *info = arg;void *cur_addr, *mz_end;
@@ -448,7 +448,7 @@ rte_eal_memzone_init(void)int ret =0 ;/* get pointer to global configuration */ - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg ();rte_rwlock_write_lock (&mcfg->mlock);
@@ -477,7 +477,7 @@ void rte_memzone_walk(void (*func)(const struct rte_memzone *, void *),struct rte_fbarray *arr;int i; - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg (); arr = &mcfg->memzones;rte_rwlock_read_lock (&mcfg->mlock);
lib/eal/common/eal_common_proc.c +1 -1
@@ -1359,7 +1359,7 @@ enum mp_status {static bool set_mp_status (enum mp_status status) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();uint8_t expected;uint8_t desired;
lib/eal/common/eal_common_tailqs.c +3 -3
@@ -29,7 +29,7 @@ struct rte_tailq_head * rte_eal_tailq_lookup(const char *name) {unsigned i; -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();if (name ==NULL ) { rte_errno =EINVAL ;
@@ -53,7 +53,7 @@ rte_dump_tailq(FILE *f)struct rte_mem_config *mcfg;unsigned i =0 ; - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg ();rte_mcfg_tailq_read_lock ();for (i =0 ; i <RTE_MAX_TAILQ ; i++) {
@@ -81,7 +81,7 @@ rte_eal_tailq_create(const char *name) (rte_tailqs_count + 1 < RTE_MAX_TAILQ)) {struct rte_mem_config *mcfg; - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg (); head = &mcfg->tailq_head[rte_tailqs_count];strlcpy (head->name, name,sizeof (head->name));TAILQ_INIT (&head->tailq_head);
lib/eal/common/eal_common_timer.c +1 -1
@@ -55,7 +55,7 @@ estimate_tsc_freq(void)void set_tsc_freq (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();uint64_t freq;if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) {
lib/eal/common/eal_internal_cfg.h +4 -0
@@ -20,6 +20,9 @@#include <rte_stdatomic.h> #include "eal_thread.h" +/* Forward declaration — full definition is in eal_memcfg.h */ +struct rte_mem_config ; +#if defined(RTE_ARCH_ARM )#define MAX_HUGEPAGE_SIZES 4/**< support up to 4 page sizes */ #else
@@ -154,6 +157,7 @@ struct eal_runtime_state {uint32_t lcore_count;/**< Number of active lcore IDs (role != ROLE_OFF). */ struct lcore_cfg lcore_cfg[RTE_MAX_LCORE ];RTE_BITSET_DECLARE (core_indices,RTE_MAX_LCORE );/**< currently allocated core_indices */ +struct rte_mem_config *mem_config;/**< pointer to memory config (in shared memory) */ };struct eal_user_cfg *eal_get_user_configuration (void );
lib/eal/common/eal_memcfg.h +3 -0
@@ -86,6 +86,9 @@ struct rte_mem_config {size_t max_memzone;/**< Maximum number of allocated memzones. */ }; +/* Return a pointer to the shared memory config */ +struct rte_mem_config *eal_get_mcfg (void ); +/* update internal config from shared mem config */ void eal_mcfg_update_internal (void );
lib/eal/common/eal_private.h +1 -5
@@ -21,11 +21,7 @@* The global RTE configuration structure. */ struct rte_config { -/** -* Pointer to memory configuration, which may be shared across multiple -* DPDK instances -*/ -struct rte_mem_config *mem_config; +int _unused;/**< dummy field to prevent empty struct */ };/**
lib/eal/common/malloc_heap.c +11 -11
@@ -71,7 +71,7 @@ check_hugepage_sz(unsigned flags, uint64_t hugepage_sz)int malloc_socket_to_heap_id (unsigned int socket_id) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();int i;for (i =0 ; i <RTE_MAX_HEAPS ; i++) {
@@ -107,7 +107,7 @@ static int malloc_add_seg(const struct rte_memseg_list *msl, const struct rte_memseg *ms, size_t len, void *arg __rte_unused) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();struct rte_memseg_list *found_msl;struct malloc_heap *heap;int msl_idx, heap_idx;
@@ -294,7 +294,7 @@ alloc_pages_on_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size, int socket, unsigned int flags, size_t align, size_t bound, bool contig, struct rte_memseg **ms, int n_segs) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();struct rte_memseg_list *msl;struct malloc_elem *elem =NULL ;size_t alloc_sz;
@@ -465,7 +465,7 @@ try_expand_heap_secondary(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size, int socket, unsigned int flags, size_t align, size_t bound, bool contig) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();struct malloc_mp_req req;int req_result;
@@ -534,7 +534,7 @@ static int alloc_more_mem_on_socket(struct malloc_heap *heap, size_t size, int socket, unsigned int flags, size_t align, size_t bound, bool contig) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();struct rte_memseg_list *requested_msls[RTE_MAX_MEMSEG_LISTS ];struct rte_memseg_list *other_msls[RTE_MAX_MEMSEG_LISTS ];uint64_t requested_pg_sz[RTE_MAX_MEMSEG_LISTS ];
@@ -642,7 +642,7 @@ static void * malloc_heap_alloc_on_heap_id(size_t size, unsigned int heap_id, unsigned int flags, size_t align, size_t bound, bool contig) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();struct malloc_heap *heap = &mcfg->malloc_heaps[heap_id];unsigned int size_flags = flags & ~RTE_MEMZONE_SIZE_HINT_ONLY ;int socket_id;
@@ -773,7 +773,7 @@ static void * heap_alloc_biggest_on_heap_id(unsigned int heap_id, unsigned int flags, size_t align, bool contig) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();struct malloc_heap *heap = &mcfg->malloc_heaps[heap_id];void *ret;
@@ -1175,7 +1175,7 @@ malloc_heap_create_external_seg(void *va_addr, rte_iova_t iova_addrs[], unsigned int n_pages, size_t page_sz, const char *seg_name, unsigned int socket_id) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();char fbarray_name[RTE_FBARRAY_NAME_LEN ];struct rte_memseg_list *msl =NULL ;struct rte_fbarray *arr;
@@ -1242,7 +1242,7 @@ struct extseg_walk_arg {static int extseg_walk (const struct rte_memseg_list *msl,void *arg) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct extseg_walk_arg *wa = arg;if (msl->base_va == wa->va_addr && msl->len == wa->len) {
@@ -1343,7 +1343,7 @@ malloc_heap_remove_external_memory(struct malloc_heap *heap, void *va_addr,int malloc_heap_create (struct malloc_heap *heap,const char *heap_name) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();uint32_t next_socket_id = mcfg->next_socket_id;/* prevent overflow. did you really create 2 billion heaps??? */
@@ -1397,7 +1397,7 @@ malloc_heap_destroy(struct malloc_heap *heap)int rte_eal_malloc_heap_init (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();unsigned int i;const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();
lib/eal/common/malloc_mp.c +1 -1
@@ -217,7 +217,7 @@ static int handle_alloc_request(const struct malloc_mp_req *m, struct mp_request *req) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();const struct malloc_req_alloc *ar = &m->alloc_req;struct malloc_heap *heap;struct malloc_elem *elem;
lib/eal/common/rte_malloc.c +7 -7
@@ -265,7 +265,7 @@ int rte_malloc_get_socket_stats(int socket, struct rte_malloc_socket_stats *socket_stats) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();int heap_idx; heap_idx =malloc_socket_to_heap_id (socket);
@@ -283,7 +283,7 @@ RTE_EXPORT_SYMBOL(rte_malloc_dump_heaps)void rte_malloc_dump_heaps (FILE *f) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();unsigned int idx;for (idx =0 ; idx <RTE_MAX_HEAPS ; idx++) {
@@ -296,7 +296,7 @@ RTE_EXPORT_SYMBOL(rte_malloc_heap_get_socket)int rte_malloc_heap_get_socket (const char *name) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct malloc_heap *heap =NULL ;unsigned int idx;int ret;
@@ -333,7 +333,7 @@ RTE_EXPORT_SYMBOL(rte_malloc_heap_socket_is_external)int rte_malloc_heap_socket_is_external (int socket_id) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();unsigned int idx;int ret =-1 ;
@@ -362,7 +362,7 @@ RTE_EXPORT_SYMBOL(rte_malloc_dump_stats)void rte_malloc_dump_stats(FILE *f, __rte_unused const char *type) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();unsigned int heap_id;struct rte_malloc_socket_stats sock_stats;
@@ -414,7 +414,7 @@ rte_malloc_virt2iova(const void *addr)static struct malloc_heap *find_named_heap (const char *name) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();unsigned int i;for (i =0 ; i <RTE_MAX_HEAPS ; i++) {
@@ -616,7 +616,7 @@ RTE_EXPORT_SYMBOL(rte_malloc_heap_create)int rte_malloc_heap_create (const char *heap_name) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct malloc_heap *heap =NULL ;int i, ret;
lib/eal/freebsd/eal.c +11 -11
@@ -93,7 +93,7 @@ eal_clean_runtime_dir(void)static int rte_eal_config_create (void ) { -struct rte_config *config =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();size_t page_sz =rte_mem_page_size ();size_t cfg_len =sizeof (struct rte_mem_config );
@@ -163,13 +163,13 @@ rte_eal_config_create(void)return -1 ; } -memcpy (rte_mem_cfg_addr, config->mem_config,sizeof (struct rte_mem_config )); - config->mem_config = rte_mem_cfg_addr; +memcpy (rte_mem_cfg_addr, runtime_state->mem_config,sizeof (struct rte_mem_config )); + runtime_state->mem_config = rte_mem_cfg_addr;/* store address of the config in the config itself so that secondary * processes could later map the config into this exact location */ - config->mem_config->mem_cfg_addr = (uintptr_t ) rte_mem_cfg_addr; + runtime_state->mem_config->mem_cfg_addr = (uintptr_t ) rte_mem_cfg_addr;return 0 ; }
@@ -179,7 +179,7 @@ rte_eal_config_attach(void) {void *rte_mem_cfg_addr;const char *pathname =eal_runtime_config_path (); -struct rte_config *config =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();
@@ -195,7 +195,7 @@ rte_eal_config_attach(void) } } - rte_mem_cfg_addr =mmap (NULL ,sizeof (*config->mem_config), + rte_mem_cfg_addr =mmap (NULL ,sizeof (*runtime_state->mem_config),PROT_READ ,MAP_SHARED , mem_cfg_fd,0 );/* don't close the fd here, it will be closed on reattach */ if (rte_mem_cfg_addr ==MAP_FAILED ) {
@@ -206,7 +206,7 @@ rte_eal_config_attach(void)return -1 ; } - config->mem_config = rte_mem_cfg_addr; + runtime_state->mem_config = rte_mem_cfg_addr;return 0 ; }
@@ -217,7 +217,7 @@ rte_eal_config_reattach(void) {struct rte_mem_config *mem_config;void *rte_mem_cfg_addr; -struct rte_config *config =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (user_cfg->no_shconf)
@@ -225,10 +225,10 @@ rte_eal_config_reattach(void)/* save the address primary process has mapped shared config to */ rte_mem_cfg_addr = - (void *)(uintptr_t )config->mem_config->mem_cfg_addr; + (void *)(uintptr_t )runtime_state->mem_config->mem_cfg_addr;/* unmap original config */ -munmap (config->mem_config,sizeof (struct rte_mem_config )); +munmap (runtime_state->mem_config,sizeof (struct rte_mem_config ));/* remap the config at proper address */ mem_config = (struct rte_mem_config *) mmap(rte_mem_cfg_addr,
@@ -249,7 +249,7 @@ rte_eal_config_reattach(void)return -1 ; } - config->mem_config = mem_config; + runtime_state->mem_config = mem_config;return 0 ; }
lib/eal/freebsd/eal_memory.c +3 -3
@@ -75,7 +75,7 @@ rte_eal_hugepage_init(void)struct eal_platform_info *platform_info =eal_get_platform_info ();/* get pointer to global configuration */ - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg ();/* for debug purposes, hugetlbfs can be disabled */ if (user_cfg->no_hugetlbfs) {
@@ -348,7 +348,7 @@ memseg_list_alloc(struct rte_memseg_list *msl)static int memseg_primary_init (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();int hpi_idx, msl_idx =0 ;struct rte_memseg_list *msl;const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();
@@ -412,7 +412,7 @@ memseg_primary_init(void)static int memseg_secondary_init (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();int msl_idx =0 ;struct rte_memseg_list *msl;
lib/eal/linux/eal.c +12 -12
@@ -173,9 +173,9 @@ eal_clean_runtime_dir(void)static int rte_eal_config_create (void ) { -struct rte_config *config =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();size_t page_sz =rte_mem_page_size (); -size_t cfg_len =sizeof (*config->mem_config); +size_t cfg_len =sizeof (*runtime_state->mem_config);size_t cfg_len_aligned =RTE_ALIGN (cfg_len, page_sz);void *rte_mem_cfg_addr, *mapped_mem_cfg_addr;int retval;
@@ -243,14 +243,14 @@ rte_eal_config_create(void)return -1 ; } -memcpy (rte_mem_cfg_addr, config->mem_config,sizeof (struct rte_mem_config )); - config->mem_config = rte_mem_cfg_addr; +memcpy (rte_mem_cfg_addr, runtime_state->mem_config,sizeof (struct rte_mem_config )); + runtime_state->mem_config = rte_mem_cfg_addr;/* store address of the config in the config itself so that secondary * processes could later map the config into this exact location */ - config->mem_config->mem_cfg_addr = (uintptr_t ) rte_mem_cfg_addr; - config->mem_config->dma_maskbits =0 ; + runtime_state->mem_config->mem_cfg_addr = (uintptr_t ) rte_mem_cfg_addr; + runtime_state->mem_config->dma_maskbits =0 ;return 0 ; }
@@ -259,7 +259,7 @@ rte_eal_config_create(void)static int rte_eal_config_attach (void ) { -struct rte_config *config =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct rte_mem_config *mem_config;const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();
@@ -288,7 +288,7 @@ rte_eal_config_attach(void)return -1 ; } - config->mem_config = mem_config; + runtime_state->mem_config = mem_config;return 0 ; }
@@ -297,7 +297,7 @@ rte_eal_config_attach(void)static int rte_eal_config_reattach (void ) { -struct rte_config *config =rte_eal_get_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct rte_mem_config *mem_config;void *rte_mem_cfg_addr;const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();
@@ -307,10 +307,10 @@ rte_eal_config_reattach(void)/* save the address primary process has mapped shared config to */ rte_mem_cfg_addr = - (void *) (uintptr_t ) config->mem_config->mem_cfg_addr; + (void *) (uintptr_t ) runtime_state->mem_config->mem_cfg_addr;/* unmap original config */ -munmap (config->mem_config,sizeof (struct rte_mem_config )); +munmap (runtime_state->mem_config,sizeof (struct rte_mem_config ));/* remap the config at proper address */ mem_config = (struct rte_mem_config *) mmap(rte_mem_cfg_addr,
@@ -333,7 +333,7 @@ rte_eal_config_reattach(void)return -1 ; } - config->mem_config = mem_config; + runtime_state->mem_config = mem_config;return 0 ; }
lib/eal/linux/eal_memalloc.c +9 -9
@@ -761,7 +761,7 @@ struct alloc_walk_param {static int alloc_seg_walk (const struct rte_memseg_list *msl,void *arg) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct alloc_walk_param *wa = arg;struct rte_memseg_list *cur_msl;size_t page_sz;
@@ -895,7 +895,7 @@ struct free_walk_param {static int free_seg_walk (const struct rte_memseg_list *msl,void *arg) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct rte_memseg_list *found_msl;struct free_walk_param *wa = arg;uintptr_t start_addr, end_addr;
@@ -1325,7 +1325,7 @@ sync_existing(struct rte_memseg_list *primary_msl,static int sync_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct rte_memseg_list *primary_msl, *local_msl;struct eal_platform_info *platform_info =eal_get_platform_info ();struct hugepage_info *hi =NULL ;
@@ -1378,7 +1378,7 @@ static int secondary_msl_create_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();struct rte_memseg_list *primary_msl, *local_msl;char name[RTE_FBARRAY_NAME_LEN ];int msl_idx, ret;
@@ -1427,7 +1427,7 @@ static int secondary_msl_destroy_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();struct rte_memseg_list *local_msl;int msl_idx, ret;
@@ -1510,7 +1510,7 @@ static int fd_list_create_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + struct rte_mem_config *mcfg = eal_get_mcfg();unsigned int len;int msl_idx;
@@ -1526,7 +1526,7 @@ fd_list_create_walk(const struct rte_memseg_list *msl,static int fd_list_destroy_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();int msl_idx;if (msl->external)
@@ -1540,7 +1540,7 @@ fd_list_destroy_walk(const struct rte_memseg_list *msl, void *arg __rte_unused)int eal_memalloc_set_seg_fd (int list_idx,int seg_idx,int fd) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* single file segments mode doesn't support individual segment fd's */
@@ -1595,7 +1595,7 @@ eal_memalloc_get_seg_fd(int list_idx, int seg_idx)int eal_memalloc_get_seg_fd_offset (int list_idx,int seg_idx,size_t *offset) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (user_cfg->single_file_segments) {
lib/eal/linux/eal_memory.c +7 -7
@@ -679,7 +679,7 @@ unmap_unneeded_hugepages(struct hugepage_file *hugepg_tbl,static int remap_segment (struct hugepage_file *hugepages,int seg_start,int seg_end) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct rte_memseg_list *msl;struct rte_fbarray *arr;int cur_page, seg_len;
@@ -839,7 +839,7 @@ static int __rte_unused prealloc_segments(struct hugepage_file *hugepages, int n_pages) {const struct eal_platform_info *platform_info =eal_get_platform_info (); -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();int cur_page, seg_start_page, end_seg, new_memseg;unsigned int hpi_idx, socket, i;int n_contig_segs, n_segs;
@@ -1137,7 +1137,7 @@ eal_legacy_hugepage_init(void)memset (used_hp,0 ,sizeof (used_hp));/* get pointer to global configuration */ - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg ();/* hugetlbfs can be disabled */ if (user_cfg->no_hugetlbfs) {
@@ -1514,7 +1514,7 @@ getFileSize(int fd)static int eal_legacy_hugepage_attach (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct hugepage_file *hp =NULL ;unsigned int num_hp =0 ;unsigned int i =0 ;
@@ -1687,7 +1687,7 @@ memseg_primary_init_32(void) {/* limit total amount of memory on 32-bit */ const uint64_t mem32_max_mem =2ULL <<30 ; -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();int active_sockets, hpi_idx, msl_idx =0 ;unsigned int socket_id, i;struct rte_memseg_list *msl;
@@ -1889,7 +1889,7 @@ memseg_primary_init(void) static int __rte_unusedmemseg_secondary_init_dynmem (void) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();int msl_idx =0 ;struct rte_memseg_list *msl;void *mem_va_addr;
@@ -1940,7 +1940,7 @@ memseg_secondary_init_dynmem(void)static int memseg_secondary_init_legacy (void ) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();int msl_idx =0 ;struct rte_memseg_list *msl;
lib/eal/windows/eal.c +3 -3
@@ -45,7 +45,7 @@ eal_proc_type_detect(void) {enum rte_proc_type_t ptype =RTE_PROC_PRIMARY ;const char *pathname =eal_runtime_config_path (); -const struct rte_config *config =rte_eal_get_configuration (); +const struct rte_mem_config *config =eal_get_mcfg ();/* if we can open the file but not get a write-lock we are a secondary * process. NOTE: if we get a file handle back, we keep that open
@@ -55,14 +55,14 @@ eal_proc_type_detect(void) _O_RDWR, _SH_DENYNO, _S_IREAD | _S_IWRITE);if (err ==0 ) {OVERLAPPED soverlapped = {0 }; - soverlapped.Offset =sizeof (*config->mem_config); + soverlapped.Offset =sizeof (*config); soverlapped.OffsetHigh =0 ;HANDLE hwinfilehandle = (HANDLE )_get_osfhandle (mem_cfg_fd);if (!LockFileEx (hwinfilehandle,LOCKFILE_EXCLUSIVE_LOCK |LOCKFILE_FAIL_IMMEDIATELY ,0 , -sizeof (*config->mem_config),0 , &soverlapped)) +sizeof (*config),0 , &soverlapped)) ptype =RTE_PROC_SECONDARY ; }
lib/eal/windows/eal_memalloc.c +2 -2
@@ -178,7 +178,7 @@ struct alloc_walk_param {static int alloc_seg_walk (const struct rte_memseg_list *msl,void *arg) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct alloc_walk_param *wa = arg;struct rte_memseg_list *cur_msl;size_t page_sz;
@@ -279,7 +279,7 @@ struct free_walk_param {static int free_seg_walk (const struct rte_memseg_list *msl,void *arg) { -struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_mem_config *mcfg =eal_get_mcfg ();struct rte_memseg_list *found_msl;struct free_walk_param *wa = arg;uintptr_t start_addr, end_addr;
lib/eal/windows/eal_memory.c +1 -1
@@ -677,7 +677,7 @@ eal_nohuge_init(void)uint64_t mem_sz, page_sz;void *addr; - mcfg =rte_eal_get_configuration ()->mem_config; + mcfg =eal_get_mcfg ();struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* nohuge mode is legacy mode */
Signature · 1 line
2.53.0
PATCH v2 24/39 eal: remove rte_config structure
In reply to Bruce RichardsonThe rte_config structure is no longer used, so remove it, and the function returning a pointer to it.
In the process, as a general cleanup, remove references to rte_config in error or info messages where it no longer makes sense to do so. For example, messages around creating or attaching to the shared memory config were referencing "rte_config", even though rte_config itself hasn't been in shared memory.
--- lib/eal/common/eal_common_config.c | 10 ---------- lib/eal/common/eal_private.h | 15 --------------- lib/eal/freebsd/eal.c | 18 +++++++++--------- lib/eal/include/rte_memzone.h | 10 +++++----- lib/eal/include/rte_tailq.h | 2 +- lib/eal/linux/eal.c | 18 +++++++++--------- 6 files changed, 24 insertions(+), 49 deletions(-)
lib/eal/common/eal_common_config.c +0 -10
@@ -20,9 +20,6 @@ static struct rte_mem_config early_mem_config = { .memory_hotplug_lock = RTE_RWLOCK_INITIALIZER, }; -/* Address of global and public configuration */ -static struct rte_config rte_config; -/* platform-specific runtime dir */ static char runtime_dir[UNIX_PATH_MAX ];
@@ -56,13 +53,6 @@ eal_set_runtime_dir(const char *run_dir)return 0 ; } -/* Return a pointer to the configuration structure */ -struct rte_config * -rte_eal_get_configuration (void ) -{ -return &rte_config; -} -/* Return a pointer to the memory config structure */ struct rte_mem_config *eal_get_mcfg (void )
lib/eal/common/eal_private.h +0 -15
@@ -17,21 +17,6 @@#include "eal_internal_cfg.h" -/** -* The global RTE configuration structure. -*/ -struct rte_config { -int _unused;/**< dummy field to prevent empty struct */ -}; - -/** -* Get the global configuration structure. -* -* @return -* A pointer to the global configuration structure. -*/ -struct rte_config *rte_eal_get_configuration (void ); -/** * Put the argument list into a structure. *
lib/eal/freebsd/eal.c +9 -9
@@ -145,7 +145,7 @@ rte_eal_config_create(void) rte_mem_cfg_addr =eal_get_virtual_area (rte_mem_cfg_addr, &cfg_len_aligned, page_sz,0 ,0 );if (rte_mem_cfg_addr ==NULL ) { -EAL_LOG (ERR ,"Cannot mmap memory for rte_config" ); +EAL_LOG (ERR ,"Cannot mmap shared memory config" );close (mem_cfg_fd); mem_cfg_fd =-1 ;return -1 ;
@@ -156,7 +156,7 @@ rte_eal_config_create(void) cfg_len_aligned,PROT_READ |PROT_WRITE , MAP_SHARED | MAP_FIXED, mem_cfg_fd, 0);if (mapped_mem_cfg_addr ==MAP_FAILED ) { -EAL_LOG (ERR ,"Cannot remap memory for rte_config: %s" ,strerror (errno)); +EAL_LOG (ERR ,"Cannot remap shared memory config: %s" ,strerror (errno));munmap (rte_mem_cfg_addr, cfg_len);close (mem_cfg_fd); mem_cfg_fd =-1 ;
@@ -201,7 +201,7 @@ rte_eal_config_attach(void)if (rte_mem_cfg_addr ==MAP_FAILED ) {close (mem_cfg_fd); mem_cfg_fd =-1 ; -EAL_LOG (ERR ,"Cannot mmap memory for rte_config! error %i (%s)" , +EAL_LOG (ERR ,"Cannot mmap shared memory config! error %i (%s)" , errno,strerror (errno));return -1 ; }
@@ -239,12 +239,12 @@ rte_eal_config_reattach(void)if (mem_config ==MAP_FAILED || mem_config != rte_mem_cfg_addr) {if (mem_config !=MAP_FAILED ) { -EAL_LOG (ERR ,"Cannot mmap memory for rte_config at [%p], got [%p] - please use '--base-virtaddr' option" , +EAL_LOG (ERR ,"Cannot mmap shared memory config at [%p], got [%p] - please use '--base-virtaddr' option" , rte_mem_cfg_addr, mem_config);munmap (mem_config,sizeof (struct rte_mem_config ));return -1 ; } -EAL_LOG (ERR ,"Cannot mmap memory for rte_config! error %i (%s)" , +EAL_LOG (ERR ,"Cannot mmap shared memory config! error %i (%s)" , errno,strerror (errno));return -1 ; }
@@ -280,9 +280,9 @@ eal_proc_type_detect(void)return ptype; } -/* Sets up rte_config structure with the pointer to shared memory config.*/ +/* Attaches to or creates the shared memory config for this process. */ static int -rte_config_init (void ) +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 ();
@@ -485,7 +485,7 @@ rte_eal_init(int argc, char **argv) goto err_out; } -if (rte_config_init () <0 ) { +if (eal_mem_config_init () <0 ) {rte_eal_init_alert ("Cannot init config" ); goto err_out; }
@@ -564,7 +564,7 @@ rte_eal_init(int argc, char **argv) rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA");if (!user_cfg->no_hugetlbfs) { -/* rte_config isn't initialized yet */ +/* shared mem config not yet attached */ ret = user_cfg->process_type ==RTE_PROC_PRIMARY ?eal_hugepage_info_init () :eal_hugepage_info_read ();
lib/eal/include/rte_memzone.h +5 -5
@@ -13,8 +13,8 @@* portions of physical memory. These zones are identified by a name. * * The memzone descriptors are shared by all partitions and are -* located in a known place of physical memory. This zone is accessed -* using rte_eal_get_configuration(). The lookup (by name) of a +* located in a known place of physical memory accessible via the +* shared memory config. The lookup (by name) of a * memory zone can be done in any partition and returns the same * physical address. *
@@ -137,7 +137,7 @@ size_t rte_memzone_max_get(void);* A pointer to a correctly-filled read-only memzone descriptor, or NULL * on error. * On error case, rte_errno will be set appropriately: -* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure +* - E_RTE_NO_CONFIG - function could not get pointer to shared memory config * - ENOSPC - the maximum number of memzones has already been allocated * - EEXIST - a memzone with the same name already exists * - ENOMEM - no appropriate memory area found in which to create memzone
@@ -202,7 +202,7 @@ const struct rte_memzone *rte_memzone_reserve(const char *name,* A pointer to a correctly-filled read-only memzone descriptor, or NULL * on error. * On error case, rte_errno will be set appropriately: -* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure +* - E_RTE_NO_CONFIG - function could not get pointer to shared memory config * - ENOSPC - the maximum number of memzones has already been allocated * - EEXIST - a memzone with the same name already exists * - ENOMEM - no appropriate memory area found in which to create memzone
@@ -273,7 +273,7 @@ const struct rte_memzone *rte_memzone_reserve_aligned(const char *name,* A pointer to a correctly-filled read-only memzone descriptor, or NULL * on error. * On error case, rte_errno will be set appropriately: -* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure +* - E_RTE_NO_CONFIG - function could not get pointer to shared memory config * - ENOSPC - the maximum number of memzones has already been allocated * - EEXIST - a memzone with the same name already exists * - ENOMEM - no appropriate memory area found in which to create memzone
lib/eal/include/rte_tailq.h +1 -1
@@ -29,7 +29,7 @@ RTE_TAILQ_HEAD(rte_tailq_entry_head, rte_tailq_entry);/** * The structure defining a tailq header entry for storing -* in the rte_config structure in shared memory. Each tailq +* in shared memory. Each tailq * is identified by name. * Any library storing a set of objects e.g. rings, mempools, hash-tables, * is recommended to use an entry here, so as to make it easy for
lib/eal/linux/eal.c +9 -9
@@ -225,7 +225,7 @@ rte_eal_config_create(void) rte_mem_cfg_addr =eal_get_virtual_area (rte_mem_cfg_addr, &cfg_len_aligned, page_sz,0 ,0 );if (rte_mem_cfg_addr ==NULL ) { -EAL_LOG (ERR ,"Cannot mmap memory for rte_config" ); +EAL_LOG (ERR ,"Cannot mmap shared memory config" );close (mem_cfg_fd); mem_cfg_fd =-1 ;return -1 ;
@@ -239,7 +239,7 @@ rte_eal_config_create(void)munmap (rte_mem_cfg_addr, cfg_len);close (mem_cfg_fd); mem_cfg_fd =-1 ; -EAL_LOG (ERR ,"Cannot remap memory for rte_config" ); +EAL_LOG (ERR ,"Cannot remap shared memory config" );return -1 ; }
@@ -283,7 +283,7 @@ rte_eal_config_attach(void)if (mem_config ==MAP_FAILED ) {close (mem_cfg_fd); mem_cfg_fd =-1 ; -EAL_LOG (ERR ,"Cannot mmap memory for rte_config! error %i (%s)" , +EAL_LOG (ERR ,"Cannot mmap shared memory config! error %i (%s)" , errno,strerror (errno));return -1 ; }
@@ -323,12 +323,12 @@ rte_eal_config_reattach(void)if (mem_config ==MAP_FAILED || mem_config != rte_mem_cfg_addr) {if (mem_config !=MAP_FAILED ) {/* errno is stale, don't use */ -EAL_LOG (ERR ,"Cannot mmap memory for rte_config at [%p], got [%p] - please use '--base-virtaddr' option" , +EAL_LOG (ERR ,"Cannot mmap shared memory config at [%p], got [%p] - please use '--base-virtaddr' option" , rte_mem_cfg_addr, mem_config);munmap (mem_config,sizeof (struct rte_mem_config ));return -1 ; } -EAL_LOG (ERR ,"Cannot mmap memory for rte_config! error %i (%s)" , +EAL_LOG (ERR ,"Cannot mmap shared memory config! error %i (%s)" , errno,strerror (errno));return -1 ; }
@@ -364,9 +364,9 @@ eal_proc_type_detect(void)return ptype; } -/* Sets up rte_config structure with the pointer to shared memory config.*/ +/* Attaches to or creates the shared memory config for this process. */ static int -rte_config_init (void ) +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 ();
@@ -640,7 +640,7 @@ rte_eal_init(int argc, char **argv) goto err_out; } -if (rte_config_init () <0 ) { +if (eal_mem_config_init () <0 ) {rte_eal_init_alert ("Cannot init config" ); goto err_out; }
@@ -728,7 +728,7 @@ rte_eal_init(int argc, char **argv) rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA");if (!user_cfg->no_hugetlbfs) { -/* rte_config isn't initialized yet */ +/* shared mem config not yet attached */ ret = user_cfg->process_type ==RTE_PROC_PRIMARY ?eal_hugepage_info_init () :eal_hugepage_info_read ();
Signature · 1 line
2.53.0
PATCH v2 25/39 eal: separate runtime state update from arg parsing
In reply to Bruce RichardsonThe 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.
--- 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 +-- lib/eal/linux/eal_vfio.c | 9 ++-- 5 files changed, 39 insertions(+), 54 deletions(-)
lib/eal/common/eal_common_options.c +31 -37
@@ -2079,7 +2079,6 @@ inteal_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 ;
@@ -2207,17 +2206,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 ;
@@ -2442,23 +2430,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
@@ -2506,20 +2482,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 ; }
lib/eal/common/eal_options.h +1 -1
@@ -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 );
lib/eal/freebsd/eal.c +2 -5
@@ -285,9 +285,6 @@ static inteal_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 :
@@ -565,7 +562,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 ) {
@@ -573,7 +570,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 ;
lib/eal/linux/eal.c +2 -5
@@ -369,9 +369,6 @@ static inteal_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 :
@@ -729,7 +726,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 ) {
@@ -737,7 +734,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 ;
lib/eal/linux/eal_vfio.c +3 -6
@@ -482,8 +482,7 @@ vfio_get_group_fd(struct vfio_config *vfio_cfg,* knowledge of them. Requesting a group fd from the primary for a * container it doesn't know about would be incorrect. */ -const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -bool mp_request = (user_cfg->process_type ==RTE_PROC_SECONDARY ) && +bool mp_request = (rte_eal_process_type () ==RTE_PROC_SECONDARY ) && (vfio_cfg == default_vfio_cfg); vfio_group_fd =vfio_open_group_fd (iommu_group_num, mp_request);
@@ -770,7 +769,6 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,int iommu_group_num;rte_uuid_t vf_token;int i, ret; -const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* get group number */ ret =rte_vfio_get_group_num (sysfs_base, dev_addr, &iommu_group_num);
@@ -852,7 +850,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,* Note this can happen several times with the hotplug * functionality. */ -if (user_cfg->process_type ==RTE_PROC_PRIMARY && +if (rte_eal_process_type () ==RTE_PROC_PRIMARY && vfio_cfg->vfio_active_groups ==1 &&vfio_group_device_count (vfio_group_fd) ==0 ) {const struct vfio_iommu_type *t;
@@ -1105,7 +1103,6 @@ rte_vfio_enable(const char *modname)unsigned int i, j;int vfio_available;DIR *dir; -const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();rte_spinlock_recursive_t lock =RTE_SPINLOCK_RECURSIVE_INITIALIZER ;
@@ -1149,7 +1146,7 @@ rte_vfio_enable(const char *modname) }closedir (dir); -if (user_cfg->process_type ==RTE_PROC_PRIMARY ) { +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) {if (vfio_mp_sync_setup () ==-1 ) { default_vfio_cfg->vfio_container_fd =-1 ; }else {
Signature · 1 line
2.53.0
PATCH v2 26/39 eal: move device options staging list into user cfg
In reply to Bruce RichardsonThe file-static devopt_list in eal_common_options.c holds device options (-a/-b/--vdev) staged during arg parsing for later consumption by eal_option_device_parse(). Rather than holding this as file local static data, store it in the user_cfg struct.
--- lib/eal/common/eal_common_options.c | 21 ++++++--------------- lib/eal/common/eal_internal_cfg.h | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-)
lib/eal/common/eal_common_options.c +6 -15
@@ -305,18 +305,6 @@ static const char *default_solib_dir = RTE_EAL_PMD_PATH; RTE_PMD_EXPORT_SYMBOL(const char, dpdk_solib_path)[] ="DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH ; -TAILQ_HEAD (device_option_list, device_option); - -struct device_option { -TAILQ_ENTRY (device_option) next; - -enum rte_devtype type; -char arg[]; -}; - -static struct device_option_list devopt_list = -TAILQ_HEAD_INITIALIZER (devopt_list); -/* Returns rte_usage_hook_t */ rte_usage_hook_t eal_get_application_usage_hook (void )
@@ -454,6 +442,7 @@ eal_clean_saved_args(void)static int eal_option_device_add (enum rte_devtype type,const char *arg) { +struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct device_option *devopt;size_t arglen;int ret;
@@ -472,25 +461,26 @@ eal_option_device_add(enum rte_devtype type, const char *arg)free (devopt);return -EINVAL ; } -TAILQ_INSERT_TAIL (&devopt_list, devopt, next); +TAILQ_INSERT_TAIL (&user_cfg->devopt_list, devopt, next);return 0 ; }int eal_option_device_parse (void ) { +struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct device_option *devopt;void *tmp;int ret =0 ; - RTE_TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) { + RTE_TAILQ_FOREACH_SAFE(devopt, &user_cfg->devopt_list, next, tmp) {if (ret ==0 ) { ret =rte_devargs_add (devopt->type, devopt->arg);if (ret)EAL_LOG (ERR ,"Unable to parse device '%s'" , devopt->arg); } -TAILQ_REMOVE (&devopt_list, devopt, next); +TAILQ_REMOVE (&user_cfg->devopt_list, devopt, next);free (devopt); }return ret;
@@ -514,6 +504,7 @@ eal_reset_internal_config(void)struct eal_platform_info *platform_info =eal_get_platform_info ();int i; +TAILQ_INIT (&user_cfg->devopt_list); user_cfg->memory =0 ; user_cfg->force_nrank =0 ; user_cfg->force_nchannel =0 ;
lib/eal/common/eal_internal_cfg.h +15 -0
@@ -10,6 +10,9 @@#ifndef EAL_INTERNAL_CFG_H #define EAL_INTERNAL_CFG_H +#include <sys/queue.h> + +#include <rte_devargs.h> #include <rte_eal.h> #include <rte_os_shim.h> #include <rte_pci_dev_feature_defs.h>
@@ -55,11 +58,23 @@ struct hugepage_file_discipline {bool unlink_existing; }; +/** +* A single device option (-a/-b/--vdev) staged during arg parsing. +* Lives in user_cfg->devopt_list; drained by eal_option_device_parse(). +*/ +struct device_option { +TAILQ_ENTRY (device_option) next; +enum rte_devtype type; +char arg[]; +}; +TAILQ_HEAD (eal_devopt_list, device_option); +/** * User-provided EAL initialization configuration. * Immutable after initialization, so no need for atomic types or locks. */ struct eal_user_cfg { +struct eal_devopt_list devopt_list;/**< staged device options (-a/-b/--vdev) */ size_t memory;/**< amount of asked memory */ size_t huge_worker_stack_size;/**< worker thread stack size */ enum rte_proc_type_t process_type;/**< requested process type */
Signature · 1 line
2.53.0
PATCH v2 27/39 eal: separate plugin paths from loaded plugin objects
In reply to Bruce RichardsonThe one data structure in eal managed both the loaded plugins and the list of plugin paths provided by the user, separating the two rather awkwardly by using a flag value. Since we have separate user_cfg and runtime_state structures, separate the plugin info between the two structs - user provided directory and file paths in one, and actual loaded .so paths and pointers in the other.
--- lib/eal/common/eal_common_options.c | 248 +++++++++++++++------------- lib/eal/common/eal_internal_cfg.h | 22 +++ 2 files changed, 158 insertions(+), 112 deletions(-)
lib/eal/common/eal_common_options.c +136 -112
@@ -277,21 +277,6 @@ eal_collate_args(int argc, char **argv)return retval -1 ; } -TAILQ_HEAD (shared_driver_list, shared_driver); - -/* Definition for shared object drivers. */ -struct shared_driver { -TAILQ_ENTRY (shared_driver) next; - -char name[PATH_MAX ]; -void * lib_handle; -bool from_cmdline;/**< true if from -d flag, false if driver found in a directory */ -}; - -/* List of external loadable drivers */ -static struct shared_driver_list solib_list = -TAILQ_HEAD_INITIALIZER (solib_list); -#ifndef RTE_EXEC_ENV_WINDOWS /* Default path of external loadable drivers */ static const char *default_solib_dir =RTE_EAL_PMD_PATH ;
@@ -505,6 +490,8 @@ eal_reset_internal_config(void)int i;TAILQ_INIT (&user_cfg->devopt_list); +TAILQ_INIT (&user_cfg->plugin_list); +TAILQ_INIT (&runtime_state->loaded_plugins); user_cfg->memory =0 ; user_cfg->force_nrank =0 ; user_cfg->force_nchannel =0 ;
@@ -561,19 +548,18 @@ eal_reset_internal_config(void) }static int -eal_plugin_add (const char *path,bool from_cmdline) +eal_plugin_path_add (const char *path) { -struct shared_driver *solib; +struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_plugin_path *p; - solib =malloc (sizeof (*solib)); -if (solib ==NULL ) { -EAL_LOG (ERR ,"malloc(solib) failed" ); + p =malloc (sizeof (*p)); +if (p ==NULL ) { +EAL_LOG (ERR ,"malloc(plugin_path) failed" );return -1 ; } -memset (solib,0 ,sizeof (*solib)); -strlcpy (solib->name, path,PATH_MAX ); - solib->from_cmdline = from_cmdline; -TAILQ_INSERT_TAIL (&solib_list, solib, next); +strlcpy (p->name, path,PATH_MAX ); +TAILQ_INSERT_TAIL (&user_cfg->plugin_list, p, next);return 0 ; }
@@ -595,53 +581,6 @@ ends_with(const char *str, const char *tail)return str_len >= tail_len &&strcmp (&str[str_len - tail_len], tail) ==0 ; } -static int -eal_plugindir_init (const char *path) -{ -struct dirent *dent =NULL ; -DIR *d =NULL ; - -if (path ==NULL || *path =='\0' ) -return 0 ; - - d =opendir (path); -if (d ==NULL ) { -EAL_LOG (ERR ,"failed to open directory %s: %s" , - path,strerror (errno)); -return -1 ; - } - -while ((dent =readdir (d)) !=NULL ) { -char *sopath =NULL ; -struct stat sb; - -if (!ends_with (dent->d_name,".so" ) && !ends_with (dent->d_name,".so." ABI_VERSION )) -continue ; - -if (asprintf (&sopath,"%s/%s" , path, dent->d_name) <0 ) { -EAL_LOG (ERR ,"failed to create full path %s/%s" , - path, dent->d_name); -continue ; - } - -/* if a regular file, add to list to load */ -if (!(stat (sopath, &sb) ==0 &&S_ISREG (sb.st_mode))) { -free (sopath); -continue ; - } - -if (eal_plugin_add (sopath, false) ==-1 ) { -free (sopath); -break ; - } -free (sopath); - } - -closedir (d); -/* XXX this ignores failures from readdir() itself */ -return (dent ==NULL ) ?0 :-1 ; -} -static int verify_perms (const char *dirpath) {
@@ -713,6 +652,65 @@ eal_dlopen(const char *pathname)return retval; } +static int +eal_plugindir_init (const char *path) +{ +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +struct dirent *dent =NULL ; +DIR *d =NULL ; + +if (path ==NULL || *path =='\0' ) +return 0 ; + + d =opendir (path); +if (d ==NULL ) { +EAL_LOG (ERR ,"failed to open directory %s: %s" , + path,strerror (errno)); +return -1 ; + } + +while ((dent =readdir (d)) !=NULL ) { +char *sopath =NULL ; +struct shared_driver *solib; +struct stat sb; + +if (!ends_with (dent->d_name,".so" ) && !ends_with (dent->d_name,".so." ABI_VERSION )) +continue ; + +if (asprintf (&sopath,"%s/%s" , path, dent->d_name) <0 ) { +EAL_LOG (ERR ,"failed to create full path %s/%s" , + path, dent->d_name); +continue ; + } + +/* if not a regular file, skip */ +if (!(stat (sopath, &sb) ==0 &&S_ISREG (sb.st_mode))) { +free (sopath); +continue ; + } + + solib =calloc (1 ,sizeof (*solib)); +if (solib ==NULL ) { +free (sopath); +break ; + } +strlcpy (solib->name, sopath,PATH_MAX ); +free (sopath); + +EAL_LOG (DEBUG ,"open shared lib %s" , solib->name); + solib->lib_handle =eal_dlopen (solib->name); +if (solib->lib_handle ==NULL ) { +free (solib); +break ; + } +TAILQ_INSERT_TAIL (&runtime_state->loaded_plugins, solib, next); + } + +closedir (d); +/* XXX this ignores failures from readdir() itself */ +return (dent ==NULL ) ?0 :-1 ; +} +static int is_shared_build (void ) {
@@ -753,37 +751,45 @@ is_shared_build(void)int eal_plugins_init (void ) { -struct shared_driver *solib =NULL ; +struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +struct eal_plugin_path *p;struct stat sb; -/* If we are not statically linked, add default driver loading -* path if it exists as a directory. -* (Using dlopen with NOLOAD flag on EAL, will return NULL if the EAL -* shared library is not already loaded i.e. it's statically linked.) -*/ +TAILQ_INIT (&runtime_state->loaded_plugins); + +/* If we are not statically linked, scan the default driver directory. */ if (is_shared_build () && *default_solib_dir !='\0' &&stat (default_solib_dir, &sb) ==0 && -S_ISDIR (sb.st_mode)) -eal_plugin_add (default_solib_dir, false); - - TAILQ_FOREACH(solib, &solib_list, next) { +S_ISDIR (sb.st_mode)) { +if (eal_plugindir_init (default_solib_dir) ==-1 ) { +EAL_LOG (ERR ,"Cannot init plugin directory %s" , + default_solib_dir); +return -1 ; + } + } -if (stat (solib->name, &sb) ==0 &&S_ISDIR (sb.st_mode)) { -if (eal_plugindir_init (solib->name) ==-1 ) { -EAL_LOG (ERR , -"Cannot init plugin directory %s" , - solib->name); + TAILQ_FOREACH(p, &user_cfg->plugin_list, next) { +if (stat (p->name, &sb) ==0 &&S_ISDIR (sb.st_mode)) { +if (eal_plugindir_init (p->name) ==-1 ) { +EAL_LOG (ERR ,"Cannot init plugin directory %s" , + p->name);return -1 ; } }else { -EAL_LOG (DEBUG ,"open shared lib %s" , - solib->name); +struct shared_driver *solib =calloc (1 ,sizeof (*solib)); +if (solib ==NULL ) +return -1 ; +strlcpy (solib->name, p->name,PATH_MAX ); +EAL_LOG (DEBUG ,"open shared lib %s" , solib->name); solib->lib_handle =eal_dlopen (solib->name); -if (solib->lib_handle ==NULL ) +if (solib->lib_handle ==NULL ) { +free (solib);return -1 ; + } +TAILQ_INSERT_TAIL (&runtime_state->loaded_plugins, solib, next); } - }return 0 ; }
@@ -793,40 +799,58 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_eal_driver_path_next)const char *rte_eal_driver_path_next (const char *start,bool cmdline_only) { -struct shared_driver *solib; +if (cmdline_only) { +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_plugin_path *p; -if (start ==NULL ) { - solib =TAILQ_FIRST (&solib_list); - }else { -/* Find the current entry based on the name string */ - TAILQ_FOREACH(solib, &solib_list, next) { -if (start == solib->name) { - solib =TAILQ_NEXT (solib, next); -break ; +if (start ==NULL ) { + p =TAILQ_FIRST (&user_cfg->plugin_list); + }else { + TAILQ_FOREACH(p, &user_cfg->plugin_list, next) { +if (start == p->name) { + p =TAILQ_NEXT (p, next); +break ; + } } +if (p ==NULL ) +return NULL ; } -if (solib ==NULL ) -return NULL ; - } +return p ? p->name :NULL ; + }else { +const struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +struct shared_driver *solib; -/* Skip entries that were expanded from directories if cmdline_only is true */ -if (cmdline_only) { -while (solib !=NULL && !solib->from_cmdline) - solib =TAILQ_NEXT (solib, next); +if (start ==NULL ) { + solib =TAILQ_FIRST (&runtime_state->loaded_plugins); + }else { + TAILQ_FOREACH(solib, &runtime_state->loaded_plugins, next) { +if (start == solib->name) { + solib =TAILQ_NEXT (solib, next); +break ; + } + } +if (solib ==NULL ) +return NULL ; + } +return solib ? solib->name :NULL ; } - -return solib ? solib->name :NULL ; }RTE_EXPORT_INTERNAL_SYMBOL (rte_eal_driver_path_count) unsigned intrte_eal_driver_path_count (bool cmdline_only) { -struct shared_driver *solib;unsigned int count =0 ; - TAILQ_FOREACH(solib, &solib_list, next) { -if (!cmdline_only || solib->from_cmdline) +if (cmdline_only) { +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_plugin_path *p; +TAILQ_FOREACH (p, &user_cfg->plugin_list, next) + count++; + }else { +const struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +struct shared_driver *solib; +TAILQ_FOREACH (solib, &runtime_state->loaded_plugins, next) count++; }
@@ -2106,7 +2130,7 @@ eal_parse_args(void)return -1 ;/* driver loading options */ TAILQ_FOREACH(arg, &args.driver_path, next) -if (eal_plugin_add (arg->arg, true) <0 ) +if (eal_plugin_path_add (arg->arg) <0 )return -1 ;if (remap_lcores && args.remap_lcore_ids != (void *)1 ) {
lib/eal/common/eal_internal_cfg.h +22 -0
@@ -58,6 +58,16 @@ struct hugepage_file_discipline {bool unlink_existing; }; +/** +* A plugin path provided by the user via -d, staged during arg parsing. +* Lives in user_cfg->plugin_list; consumed by eal_plugins_init(). +*/ +struct eal_plugin_path { +TAILQ_ENTRY (eal_plugin_path) next; +char name[PATH_MAX ]; +}; +TAILQ_HEAD (eal_plugin_path_list, eal_plugin_path); +/** * A single device option (-a/-b/--vdev) staged during arg parsing. * Lives in user_cfg->devopt_list; drained by eal_option_device_parse().
@@ -75,6 +85,7 @@ TAILQ_HEAD(eal_devopt_list, device_option);*/ struct eal_user_cfg {struct eal_devopt_list devopt_list;/**< staged device options (-a/-b/--vdev) */ +struct eal_plugin_path_list plugin_list;/**< user-provided plugin paths (-d) */ size_t memory;/**< amount of asked memory */ size_t huge_worker_stack_size;/**< worker thread stack size */ enum rte_proc_type_t process_type;/**< requested process type */
@@ -155,6 +166,16 @@ struct lcore_cfg {volatile RTE_ATOMIC (enum rte_lcore_state_t ) state;/**< lcore state */ }; +/** +* A plugin loaded by EAL, including directory-expanded entries. +*/ +struct shared_driver { +TAILQ_ENTRY (shared_driver) next; +char name[PATH_MAX ]; +void *lib_handle; +}; +TAILQ_HEAD (eal_solib_list, shared_driver); +/** * Internal EAL runtime state * May be modified at runtime, so access must be protected by locks or atomic types
@@ -173,6 +194,7 @@ struct eal_runtime_state {struct lcore_cfg lcore_cfg[RTE_MAX_LCORE ];RTE_BITSET_DECLARE (core_indices,RTE_MAX_LCORE );/**< currently allocated core_indices */ struct rte_mem_config *mem_config;/**< pointer to memory config (in shared memory) */ +struct eal_solib_list loaded_plugins;/**< all plugins loaded by eal_plugins_init() */ };struct eal_user_cfg *eal_get_user_configuration (void );
Signature · 1 line
2.53.0
PATCH v2 28/39 eal: simplify internal driver path iteration APIs
In reply to Bruce RichardsonThe APIs for counting and iterating the driver paths originally iterated the mixed list of both user-provided paths and loaded .so paths. However, in practice only the user-provided paths were ever queried.
Since supporting both types of iteration is duplicating the work in code (because we now have two different lists of different types to iterate) just drop the unused iteration support and update the API to only iterate the user-provided list. This simplifies the API (dropping a parameter), the implementation (removing iteration of the runtime_cfg list), and has no ABI impacts since the APIs are explicitly marked as internal. The iteration macro is updated to match the APIs too.
--- app/test/process.h | 4 +- lib/eal/common/eal_common_options.c | 60 ++++++++--------------------- lib/eal/include/rte_eal.h | 35 ++++++----------- 3 files changed, 31 insertions(+), 68 deletions(-)
app/test/process.h +2 -2
@@ -62,7 +62,7 @@ add_parameter_driver_path(char **argv, int max_capacity)const char *driver_path;int count =0 ; - RTE_EAL_DRIVER_PATH_FOREACH(driver_path, true) { +RTE_EAL_DRIVER_PATH_FOREACH (driver_path) {if (asprintf (&argv[count],PREFIX_DRIVER_PATH "%s" , driver_path) <0 )break ;
@@ -100,7 +100,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)return -1 ; else if (pid == 0) { allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); - driver_path_num =rte_eal_driver_path_count (true); + driver_path_num =rte_eal_driver_path_count (); argv_num = numargs + allow_num + driver_path_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy)
lib/eal/common/eal_common_options.c +17 -43
79 lines not on this page · raw message
lib/eal/include/rte_eal.h +12 -23
@@ -493,57 +493,46 @@ rte_eal_get_runtime_dir(void);/** * @internal -* Iterate to the next driver path. +* Iterate to the next user-provided driver path. * -* This function iterates through the list of dynamically loaded drivers, -* or driver paths that were specified via -d or --driver-path command-line -* options during EAL initialization. +* This function iterates through the driver paths that were specified +* via -d or --driver-path command-line options during EAL initialization. * * @param start * Starting iteration point. The iteration will start at the first driver path if NULL. -* @param cmdline_only -* If true, only iterate paths from command line (-d flags). -* If false, iterate all paths including those expanded from directories. * * @return * Next driver path string, NULL if there is none. */ __rte_internal const char * -rte_eal_driver_path_next (const char *start,bool cmdline_only); +rte_eal_driver_path_next (const char *start);/** * @internal -* Iterate over all driver paths. +* Iterate over all user-provided driver paths. * * This macro provides a convenient way to iterate through all driver paths -* that were loaded via -d flags during EAL initialization. +* that were specified via -d flags during EAL initialization. * * @param path * Iterator variable of type const char * -* @param cmdline_only -* If true, only iterate paths from command line (-d flags). -* If false, iterate all paths including those expanded from directories. */ -#define RTE_EAL_DRIVER_PATH_FOREACH (path, cmdline_only) \ - for (path = rte_eal_driver_path_next(NULL, cmdline_only); \ +#define RTE_EAL_DRIVER_PATH_FOREACH (path) \ + for (path = rte_eal_driver_path_next(NULL); \ path != NULL; \ - path = rte_eal_driver_path_next(path, cmdline_only)) + path = rte_eal_driver_path_next(path))/** * @internal -* Get count of driver paths. -* -* @param cmdline_only -* If true, only count paths from command line (-d flags). -* If false, count all paths including those expanded from directories. +* Get count of user-provided driver paths. * * @return -* Number of driver paths. +* Number of driver paths specified via -d flags during EAL initialization. */ __rte_internal unsigned int -rte_eal_driver_path_count (bool cmdline_only); +rte_eal_driver_path_count (void ); #ifdef __cplusplus }
Signature · 1 line
2.53.0
PATCH v2 29/39 eal: move trace config into user config struct
In reply to Bruce RichardsonThe trace settings (pattern list, directory, buffer size, mode) were previously stored directly in the internal struct trace singleton during arg parsing, via helper functions. Move these setting into eal_user_cfg and drop the helper functions.
NOTE: after these changes, eal_cleanup_config needs a non-const user config pointer to cleanup. Rather than making the pointer in rte_eal_cleanup non-const, make eal_cleanup_config like all the other functions in the cleanup chain in taking no parameters. Then it can define its own non-const user config pointer internally.
--- lib/eal/common/eal_common_options.c | 53 ++++++++++-- lib/eal/common/eal_common_trace.c | 30 +++++-- lib/eal/common/eal_common_trace_utils.c | 104 ------------------------ lib/eal/common/eal_internal_cfg.h | 15 ++++ lib/eal/common/eal_options.h | 2 +- lib/eal/common/eal_trace.h | 11 --- lib/eal/freebsd/eal.c | 3 +- lib/eal/linux/eal.c | 2 +- lib/eal/windows/eal.c | 4 +- 9 files changed, 87 insertions(+), 137 deletions(-)
lib/eal/common/eal_common_options.c +47 -6
@@ -14,6 +14,7 @@#include <sys/queue.h> #ifndef RTE_EXEC_ENV_WINDOWS #include <dlfcn.h> +#include <fnmatch.h> #include <libgen.h> #endif #include <sys/stat.h>
@@ -491,6 +492,7 @@ eal_reset_internal_config(void)TAILQ_INIT (&user_cfg->devopt_list);TAILQ_INIT (&user_cfg->plugin_list); +STAILQ_INIT (&user_cfg->trace_patterns);TAILQ_INIT (&runtime_state->loaded_plugins); user_cfg->memory =0 ; user_cfg->force_nrank =0 ;
@@ -2321,28 +2323,56 @@ eal_parse_args(void)EAL_LOG (WARNING ,"Tracing is not supported on Windows, ignoring tracing parameters" );#else TAILQ_FOREACH(arg, &args.trace, next) { -if (eal_trace_args_save (arg->arg) <0 ) { -EAL_LOG (ERR ,"invalid trace parameter, '%s'" , arg->arg); +struct eal_trace_arg *ta =malloc (sizeof (*ta)); +if (ta ==NULL ) { +EAL_LOG (ERR ,"failed to allocate trace arg for '%s'" , arg->arg);return -1 ; } + ta->val =strdup (arg->arg); +if (ta->val ==NULL ) { +EAL_LOG (ERR ,"failed to allocate trace arg for '%s'" , arg->arg); +free (ta); +return -1 ; + } +STAILQ_INSERT_TAIL (&user_cfg->trace_patterns, ta, next); }if (args.trace_dir !=NULL ) { -if (eal_trace_dir_args_save (args.trace_dir) <0 ) { +if (asprintf (&user_cfg->trace_dir,"%s/" , args.trace_dir) ==-1 ) {EAL_LOG (ERR ,"invalid trace directory, '%s'" , args.trace_dir);return -1 ; } }if (args.trace_bufsz !=NULL ) { -if (eal_trace_bufsz_args_save (args.trace_bufsz) <0 ) { +uint64_t bufsz =rte_str_to_size (args.trace_bufsz); +if (bufsz ==0 ) {EAL_LOG (ERR ,"invalid trace buffer size, '%s'" , args.trace_bufsz);return -1 ; } + user_cfg->trace_bufsz = bufsz; }if (args.trace_mode !=NULL ) { -if (eal_trace_mode_args_save (args.trace_mode) <0 ) { +size_t len =strlen (args.trace_mode); +char *pattern; +if (len ==0 ) { +EAL_LOG (ERR ,"trace mode value is empty" ); +return -1 ; + } + pattern =calloc (1 , len +2 ); +if (pattern ==NULL ) { +EAL_LOG (ERR ,"failed to allocate memory for trace mode" ); +return -1 ; + } +sprintf (pattern,"%s*" , args.trace_mode); +if (fnmatch (pattern,"overwrite" ,0 ) ==0 ) + user_cfg->trace_mode =RTE_TRACE_MODE_OVERWRITE ; +else if (fnmatch (pattern,"discard" ,0 ) ==0 ) + user_cfg->trace_mode =RTE_TRACE_MODE_DISCARD ; +else {EAL_LOG (ERR ,"invalid trace mode, '%s'" , args.trace_mode); +free (pattern);return -1 ; } +free (pattern); }#endif
@@ -2461,8 +2491,19 @@ compute_ctrl_threads_cpuset(void) }int -eal_cleanup_config (const struct eal_user_cfg *user_cfg) +eal_cleanup_config (void ) { +struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_trace_arg *ta; + +/* free trace patterns list */ +while (!STAILQ_EMPTY (&user_cfg->trace_patterns)) { + ta =STAILQ_FIRST (&user_cfg->trace_patterns); +STAILQ_REMOVE_HEAD (&user_cfg->trace_patterns, next); +free (ta->val); +free (ta); + } +free (user_cfg->trace_dir);free (user_cfg->hugefile_prefix);free (user_cfg->hugepage_dir);free (user_cfg->user_mbuf_pool_ops_name);
lib/eal/common/eal_common_trace.c +21 -9
@@ -24,7 +24,7 @@ RTE_DEFINE_PER_LCORE(void *, trace_mem); static RTE_DEFINE_PER_LCORE(char *, ctf_field);static struct trace_point_head tp_list =STAILQ_HEAD_INITIALIZER (tp_list); -static struct trace trace = { .args =STAILQ_HEAD_INITIALIZER (trace.args), }; +static struct trace trace;struct trace *trace_obj_get (void )
@@ -41,7 +41,8 @@ trace_list_head_get(void)int eal_trace_init (void ) { -struct trace_arg *arg; +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +const struct eal_trace_arg *arg;/* Trace memory should start with 8B aligned for natural alignment */ RTE_BUILD_BUG_ON ((offsetof(struct __rte_trace_header , mem) %8 ) !=0 );
@@ -58,14 +59,24 @@ eal_trace_init(void)if (trace_has_duplicate_entry ()) goto fail; +/* Copy trace directory from user config (trace.dir may be reallocated later) */ +if (user_cfg->trace_dir !=NULL ) { + trace.dir =strdup (user_cfg->trace_dir); +if (trace.dir ==NULL ) { + rte_errno =ENOMEM ; + goto fail; + } + } + +/* Apply buffer size from user config, then fill in default if still 0 */ + trace.buff_len = user_cfg->trace_bufsz; +trace_bufsz_args_apply (); +/* Generate UUID ver 4 with total size of events and number of * events */ trace_uuid_generate (); -/* Apply buffer size configuration for trace output */ -trace_bufsz_args_apply (); -/* Generate CTF TDSL metadata */ if (trace_metadata_create () <0 ) goto fail;
@@ -74,11 +85,11 @@ eal_trace_init(void)if (trace_epoch_time_save () <0 ) goto free_meta; -/* Apply global configurations */ - STAILQ_FOREACH(arg, &trace.args, next) +/* Apply trace pattern filters from user config */ + STAILQ_FOREACH(arg, &user_cfg->trace_patterns, next)trace_args_apply (arg->val); -rte_trace_mode_set (trace.mode); +rte_trace_mode_set (user_cfg->trace_mode);return 0 ;
@@ -94,7 +105,8 @@ eal_trace_fini(void) {trace_mem_free ();trace_metadata_destroy (); -eal_trace_args_free (); +free (trace.dir); + trace.dir =NULL ; }RTE_EXPORT_EXPERIMENTAL_SYMBOL (rte_trace_is_enabled,20.05 )
lib/eal/common/eal_common_trace_utils.c +0 -104
128 lines not on this page · raw message
lib/eal/common/eal_internal_cfg.h +15 -0
@@ -16,6 +16,7 @@#include <rte_eal.h> #include <rte_os_shim.h> #include <rte_pci_dev_feature_defs.h> +#include <rte_trace.h> #include <stdint.h> #include <stdbool.h>
@@ -58,6 +59,16 @@ struct hugepage_file_discipline {bool unlink_existing; }; +/** +* A saved trace pattern string from --trace, staged during arg parsing. +* Lives in user_cfg->trace_patterns; applied during eal_trace_init(). +*/ +struct eal_trace_arg { +STAILQ_ENTRY (eal_trace_arg) next; +char *val; +}; +STAILQ_HEAD (eal_trace_arg_list, eal_trace_arg); +/** * A plugin path provided by the user via -d, staged during arg parsing. * Lives in user_cfg->plugin_list; consumed by eal_plugins_init().
@@ -86,6 +97,10 @@ TAILQ_HEAD(eal_devopt_list, device_option);struct eal_user_cfg {struct eal_devopt_list devopt_list;/**< staged device options (-a/-b/--vdev) */ struct eal_plugin_path_list plugin_list;/**< user-provided plugin paths (-d) */ +struct eal_trace_arg_list trace_patterns;/**< saved --trace patterns */ +char *trace_dir;/**< trace output directory (NULL = use default) */ +uint64_t trace_bufsz;/**< trace buffer size in bytes (0 = use default 1 MB) */ +enum rte_trace_mode trace_mode;/**< trace mode (default RTE_TRACE_MODE_OVERWRITE) */ size_t memory;/**< amount of asked memory */ size_t huge_worker_stack_size;/**< worker thread stack size */ enum rte_proc_type_t process_type;/**< requested process type */
lib/eal/common/eal_options.h +1 -1
@@ -15,7 +15,7 @@ int eal_parse_args(void);int eal_option_device_parse (void );int eal_apply_hugepage_mem_sz_limits (void );int eal_apply_runtime_state (void ); -int eal_cleanup_config (const struct eal_user_cfg *user_cfg); +int eal_cleanup_config (void );enum rte_proc_type_t eal_proc_type_detect (void );int eal_plugins_init (void );int eal_save_args (int argc,char **argv);
lib/eal/common/eal_trace.h +0 -11
@@ -42,11 +42,6 @@ struct thread_mem_meta {enum trace_area_e area; }; -struct trace_arg { -STAILQ_ENTRY (trace_arg) next; -char *val; -}; -struct trace {char *dir;int register_errno;
@@ -54,7 +49,6 @@ struct trace {enum rte_trace_mode mode;rte_uuid_t uuid;uint32_t buff_len; - STAILQ_HEAD(, trace_arg) args;uint32_t nb_trace_points;uint32_t nb_trace_mem_list;struct thread_mem_meta *lcore_meta;
@@ -107,10 +101,5 @@ void trace_mem_per_thread_free(void);/* EAL interface */ int eal_trace_init (void );void eal_trace_fini (void ); -int eal_trace_args_save (const char *val); -void eal_trace_args_free (void ); -int eal_trace_dir_args_save (const char *val); -int eal_trace_mode_args_save (const char *val); -int eal_trace_bufsz_args_save (const char *val);#endif /* __EAL_TRACE_H */
lib/eal/freebsd/eal.c +1 -2
@@ -768,7 +768,6 @@ rte_eal_cleanup(void)return -1 ; } -struct eal_user_cfg *user_cfg =eal_get_user_configuration ();rte_service_finalize ();eal_bus_cleanup ();rte_mp_channel_cleanup ();
@@ -777,7 +776,7 @@ rte_eal_cleanup(void)eal_trace_fini ();/* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach (); -eal_cleanup_config (user_cfg); +eal_cleanup_config ();eal_lcore_var_cleanup ();return 0 ; }
lib/eal/linux/eal.c +1 -1
@@ -980,7 +980,7 @@ rte_eal_cleanup(void)/* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach ();rte_eal_malloc_heap_cleanup (); -eal_cleanup_config (user_cfg); +eal_cleanup_config ();eal_lcore_var_cleanup ();rte_eal_log_cleanup ();return 0 ;
lib/eal/windows/eal.c +1 -3
@@ -136,14 +136,12 @@ RTE_EXPORT_SYMBOL(rte_eal_cleanup)int rte_eal_cleanup (void ) { -struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -eal_intr_thread_cancel ();eal_mem_virt2iova_cleanup ();eal_bus_cleanup ();/* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach (); -eal_cleanup_config (user_cfg); +eal_cleanup_config ();eal_lcore_var_cleanup ();return 0 ; }
Signature · 1 line
2.53.0
PATCH v2 30/39 eal: record service cores in user config struct
In reply to Bruce RichardsonThe user provided service coremask or service corelist needs to be recorded in the user config struct, so store it there as a cpuset.
--- lib/eal/common/eal_common_options.c | 157 ++++++++-------------------- lib/eal/common/eal_internal_cfg.h | 1 + 2 files changed, 46 insertions(+), 112 deletions(-)
lib/eal/common/eal_common_options.c +45 -112
@@ -545,6 +545,7 @@ eal_reset_internal_config(void) user_cfg->user_mbuf_pool_ops_name =NULL ;CPU_ZERO (&runtime_state->ctrl_cpuset); runtime_state->init_complete =0 ; +CPU_ZERO (&user_cfg->service_cpuset); user_cfg->max_simd_bitwidth.bitwidth =RTE_VECT_DEFAULT_SIMD_BITWIDTH ; user_cfg->max_simd_bitwidth.forced =0 ; }
@@ -852,21 +853,20 @@ static int xdigit2val(unsigned char c) }static int -eal_parse_service_coremask (const char *coremask) +eal_parse_service_coremask (const char *coremask,rte_cpuset_t *cpuset) {struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int i, j, idx =0 ;unsigned int count =0 ;char c;int val; -uint32_t taken_lcore_count =0 ;EAL_LOG (WARNING ,"'-s <service-coremask>' is deprecated, and will be removed in a future release." );EAL_LOG (WARNING ,"\tUse '-S <service-corelist>' option instead." );if (coremask ==NULL )return -1 ; -/* Remove all blank characters ahead and after . +/* Remove all blank characters ahead and after. * Remove 0x/0X if exists. */ while (isblank (*coremask))
@@ -888,20 +888,9 @@ eal_parse_service_coremask(const char *coremask)return -1 ; } val =xdigit2val (c); -for (j =0 ; j <BITS_PER_HEX && idx <RTE_MAX_LCORE ; - j++, idx++) { +for (j =0 ; j <BITS_PER_HEX && idx <RTE_MAX_LCORE ; j++, idx++) {if ((1 << j) & val) { - -if (eal_cpu_detected (idx) ==0 ) { -EAL_LOG (ERR , -"lcore %u unavailable" , idx); -return -1 ; - } - -if (runtime_state->lcore_cfg[idx].role ==ROLE_RTE ) - taken_lcore_count++; - - runtime_state->lcore_cfg[idx].role =ROLE_SERVICE ; +CPU_SET (idx, cpuset); count++; } }
@@ -913,16 +902,15 @@ eal_parse_service_coremask(const char *coremask)rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE ); -if (count ==0 ) -return -1 ; - -if (taken_lcore_count != count) { -EAL_LOG (WARNING , -"Not all service cores are in the coremask. " -"Please ensure -c or -l includes service cores" ); - } +return count >0 ?0 :-1 ; +} -return 0 ; +static int +eal_parse_service_corelist (const char *corelist,rte_cpuset_t *cpuset) +{ +if (rte_argparse_parse_type (corelist,RTE_ARGPARSE_VALUE_TYPE_CORELIST , cpuset) !=0 ) +return -1 ; +return CPU_COUNT (cpuset) >0 ?0 :-1 ; } static int
@@ -1097,89 +1085,6 @@ rte_eal_parse_coremask(const char *coremask, rte_cpuset_t *cpuset, bool limit_rareturn 0 ; } -static int -eal_parse_service_corelist (const char *corelist) -{ -struct eal_runtime_state *runtime_state =eal_get_runtime_state (); -int i; -unsigned count =0 ; -char *end =NULL ; -uint32_t min, max, idx; -uint32_t taken_lcore_count =0 ; - -if (corelist ==NULL ) -return -1 ; - -/* Remove all blank characters ahead and after */ -while (isblank (*corelist)) - corelist++; - i =strlen (corelist); -while ((i >0 ) &&isblank (corelist[i -1 ])) - i--; - -/* Get list of cores */ - min =RTE_MAX_LCORE ; -do { -while (isblank (*corelist)) - corelist++; -if (*corelist =='\0' ) -return -1 ; - errno =0 ; - idx =strtoul (corelist, &end,10 ); -if (errno || end ==NULL ) -return -1 ; -if (idx >=RTE_MAX_LCORE ) -return -1 ; -while (isblank (*end)) - end++; -if (*end =='-' ) { - min = idx; - }else if ((*end ==',' ) || (*end =='\0' )) { - max = idx; -if (min ==RTE_MAX_LCORE ) - min = idx; -for (idx = min; idx <= max; idx++) { -if (runtime_state->lcore_cfg[idx].role !=ROLE_SERVICE ) { -if (runtime_state->lcore_cfg[idx].role ==ROLE_RTE ) - taken_lcore_count++; - - runtime_state->lcore_cfg[idx].role =ROLE_SERVICE ; - count++; - } - } - min =RTE_MAX_LCORE ; - }else -return -1 ; - corelist = end +1 ; - }while (*end !='\0' ); - -if (count ==0 ) -return -1 ; - -if (taken_lcore_count != count) { -EAL_LOG (WARNING , -"Not all service cores were in the coremask. " -"Please ensure -c or -l includes service cores" ); - } - -/* log the configured service cores for debugging */ -rte_cpuset_t service_cpuset; -CPU_ZERO (&service_cpuset); -for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (runtime_state->lcore_cfg[i].role ==ROLE_SERVICE ) -CPU_SET (i, &service_cpuset); - } -if (CPU_COUNT (&service_cpuset) >0 ) { -char *cpuset_str =eal_cpuset_to_str (&service_cpuset); -if (cpuset_str !=NULL ) { -EAL_LOG (DEBUG ,"Service cores configured: %s" , cpuset_str); -free (cpuset_str); - } - } - -return 0 ; -} -/* Changes the lcore id of the main thread */ static int eal_parse_main_lcore (const char *arg)
@@ -1196,8 +1101,8 @@ eal_parse_main_lcore(const char *arg)return -1 ; user_cfg->main_lcore = (int )main_lcore; -/* ensure main core is not used as service core */ -if (runtime_state->lcore_cfg[user_cfg->main_lcore].role ==ROLE_SERVICE ) { +/* check main core is not already down as a service core */ +if (CPU_ISSET (user_cfg->main_lcore, &user_cfg->service_cpuset)) {EAL_LOG (ERR ,"Error: Main lcore is used as a service core" );return -1 ; }
@@ -2181,13 +2086,15 @@ eal_parse_args(void)/* service core options */ if (args.service_coremask !=NULL ) { -if (eal_parse_service_coremask (args.service_coremask) <0 ) { +if (eal_parse_service_coremask (args.service_coremask, + &user_cfg->service_cpuset) <0 ) {EAL_LOG (ERR ,"invalid service coremask: '%s'" , args.service_coremask);return -1 ; } }else if (args.service_corelist !=NULL ) { -if (eal_parse_service_corelist (args.service_corelist) <0 ) { +if (eal_parse_service_corelist (args.service_corelist, + &user_cfg->service_cpuset) <0 ) {EAL_LOG (ERR ,"invalid service core list: '%s'" , args.service_corelist);return -1 ;
@@ -2517,6 +2424,32 @@ eal_apply_runtime_state(void)struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +/* Apply service core roles: service_cpuset bits are lcore IDs */ +if (CPU_COUNT (&user_cfg->service_cpuset) >0 ) { +unsigned int i; +char *cpuset_str; + +for (i =0 ; i <RTE_MAX_LCORE ; i++) { +if (!CPU_ISSET (i, &user_cfg->service_cpuset)) +continue ; +if (eal_cpu_detected (i) ==0 ) { +EAL_LOG (ERR ,"Requested service lcore %u unavailable" , i); +return -1 ; + } +if (runtime_state->lcore_cfg[i].role !=ROLE_RTE ) { +EAL_LOG (WARNING , +"service lcore %u is not in the enabled lcore set; please ensure -c or -l includes service cores" , + i); + } + runtime_state->lcore_cfg[i].role =ROLE_SERVICE ; + } + cpuset_str =eal_cpuset_to_str (&user_cfg->service_cpuset); +if (cpuset_str !=NULL ) { +EAL_LOG (DEBUG ,"Service cores configured: %s" , cpuset_str); +free (cpuset_str); + } + } +/* set the main lcore */ if (user_cfg->main_lcore !=-1 ) { runtime_state->main_lcore = user_cfg->main_lcore;
lib/eal/common/eal_internal_cfg.h +1 -0
@@ -137,6 +137,7 @@ struct eal_user_cfg {uint64_t limit;/**< memory limit in bytes */ } pagesz_mem_overrides[MAX_HUGEPAGE_SIZES ];unsigned int num_pagesz_mem_overrides;/**< number of stored overrides */ +rte_cpuset_t service_cpuset;/**< each bit set is one lcore ID to use as service core */ int main_lcore;/**< ID of the main lcore */ };
Signature · 1 line
2.53.0
PATCH v2 31/39 eal: store user-provided lcore info in user config struct
In reply to Bruce RichardsonThe user provides details of what lcores are to run on what cpus in a variety of ways. Map all those to a single array of cpusets in the user_cfg struct, such that each lcore id has a cpuset of physical lcore ids if it is to be used. Then post-parse of args, we can use that to appropriately populate the runtime configuration.
--- lib/eal/common/eal_common_options.c | 151 ++++++++++++++++++---------- lib/eal/common/eal_internal_cfg.h | 9 +- lib/eal/freebsd/eal.c | 1 + lib/eal/linux/eal.c | 1 + lib/eal/windows/eal.c | 1 + 5 files changed, 109 insertions(+), 54 deletions(-)
lib/eal/common/eal_common_options.c +98 -53
@@ -546,6 +546,10 @@ eal_reset_internal_config(void)CPU_ZERO (&runtime_state->ctrl_cpuset); runtime_state->init_complete =0 ;CPU_ZERO (&user_cfg->service_cpuset); +for (i =0 ; i <RTE_MAX_LCORE ; i++) { +free (user_cfg->lcore_cpusets[i]); + user_cfg->lcore_cpusets[i] =NULL ; + } user_cfg->max_simd_bitwidth.bitwidth =RTE_VECT_DEFAULT_SIMD_BITWIDTH ; user_cfg->max_simd_bitwidth.forced =0 ; }
@@ -913,23 +917,20 @@ eal_parse_service_corelist(const char *corelist, rte_cpuset_t *cpuset)return CPU_COUNT (cpuset) >0 ?0 :-1 ; } +/* Expand a flat cpuset into lcore_cpusets[], assigning lcore IDs. +* If remap is false: lcore_id == physical CPU id (identity mapping). +* If remap is true: lcore IDs are assigned sequentially from remap_base. +* Returns the number of lcores configured, or -1 on error. +*/ static int -update_lcore_config (const rte_cpuset_t *cpuset,bool remap,uint16_t remap_base) +eal_expand_cpuset_to_map (const rte_cpuset_t *cpuset,bool remap,uint16_t remap_base, +rte_cpuset_t **lcore_cpusets) { -struct eal_runtime_state *runtime_state =eal_get_runtime_state ();unsigned int lcore_id = remap_base;unsigned int count =0 ;unsigned int i;int ret =0 ; -/* set everything to disabled first, then set up values */ -rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE ); -for (i =0 ; i <RTE_MAX_LCORE ; i++) { - runtime_state->lcore_cfg[i].role =ROLE_OFF ; - runtime_state->lcore_cfg[i].core_index =-1 ; - } - -/* now go through the cpuset */ for (i =0 ; i <CPU_SETSIZE ; i++) {if (CPU_ISSET (i, cpuset)) {if (eal_cpu_detected (i) ==0 ) {
@@ -953,12 +954,17 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)continue ; } -rte_bitset_set (runtime_state->core_indices, count); - runtime_state->lcore_cfg[lcore_id].role =ROLE_RTE ; - runtime_state->lcore_cfg[lcore_id].core_index = count; -CPU_ZERO (&runtime_state->lcore_cfg[lcore_id].cpuset); -CPU_SET (i, &runtime_state->lcore_cfg[lcore_id].cpuset); - runtime_state->lcore_cfg[lcore_id].first_cpu = i; + lcore_cpusets[lcore_id] =malloc (sizeof (rte_cpuset_t)); +if (lcore_cpusets[lcore_id] ==NULL ) { +EAL_LOG (ERR ,"failed to allocate cpuset for lcore %u" , lcore_id); +for (unsigned int j =0 ; j < lcore_id; j++) { +free (lcore_cpusets[j]); + lcore_cpusets[j] =NULL ; + } +return -1 ; + } +CPU_ZERO (lcore_cpusets[lcore_id]); +CPU_SET (i, lcore_cpusets[lcore_id]);EAL_LOG (DEBUG ,"lcore %u mapped to physical core %u" , lcore_id, i); lcore_id++; count++;
@@ -968,9 +974,9 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, uint16_t remap_base)EAL_LOG (ERR ,"No valid lcores in core list" ); ret =-1 ; } -if (!ret) - runtime_state->lcore_count = count; -return ret; +if (ret ==-1 ) +return -1 ; +return (int )count; } static int
@@ -1092,7 +1098,6 @@ eal_parse_main_lcore(const char *arg)char *parsing_end;long main_lcore;struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -struct eal_runtime_state *runtime_state =eal_get_runtime_state (); errno =0 ; main_lcore =strtol (arg, &parsing_end,0 );
@@ -1106,8 +1111,9 @@ eal_parse_main_lcore(const char *arg)EAL_LOG (ERR ,"Error: Main lcore is used as a service core" );return -1 ; } -/* check that we have the core recorded in the core list */ -if (runtime_state->lcore_cfg[user_cfg->main_lcore].role !=ROLE_RTE ) { + +/* lcore_cpusets is always populated before eal_parse_main_lcore is called */ +if (user_cfg->lcore_cpusets[user_cfg->main_lcore] ==NULL ) {EAL_LOG (ERR ,"Error: Main lcore is not enabled for DPDK" );return -1 ; }
@@ -1269,15 +1275,18 @@ check_cpuset(rte_cpuset_t *set)* lcore 6 runs on cpuset 0x41 (cpu 0,6) * lcore 7 runs on cpuset 0x80 (cpu 7) * lcore 8 runs on cpuset 0x100 (cpu 8) +* +* Writes the physical-CPU affinity for each mentioned lcore_id into +* cpusets[lcore_id]. Slots not mentioned are left as NULL. +* Returns the number of distinct lcore IDs configured, or -1 on error. */ static int -eal_parse_lcores (const char *lcores) +eal_parse_lcores_to_map (const char *lcores,rte_cpuset_t **cpusets) { -struct eal_runtime_state *runtime_state =eal_get_runtime_state ();rte_cpuset_t lcore_set;unsigned int set_count; -unsigned idx =0 ; -unsigned count =0 ; +unsigned int idx; +int count =0 ;const char *lcore_start =NULL ;const char *end =NULL ;int offset;
@@ -1294,15 +1303,6 @@ eal_parse_lcores(const char *lcores)CPU_ZERO (&cpuset); -/* Reset lcore config */ -rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE ); -for (idx =0 ; idx <RTE_MAX_LCORE ; idx++) { - runtime_state->lcore_cfg[idx].role =ROLE_OFF ; - runtime_state->lcore_cfg[idx].core_index =-1 ; -CPU_ZERO (&runtime_state->lcore_cfg[idx].cpuset); - runtime_state->lcore_cfg[idx].first_cpu =UINT16_MAX ; - } -/* Get list of cores */ do { while (isblank(*lcores))
@@ -1351,7 +1351,7 @@ eal_parse_lcores(const char *lcores)/* without '@', by default using lcore_set as cpuset */ if (*lcores !='@' ) -rte_memcpy (&cpuset, &lcore_set,sizeof (cpuset)); +memcpy (&cpuset, &lcore_set,sizeof (cpuset)); set_count =CPU_COUNT (&lcore_set);/* start to update lcore_set */
@@ -1360,13 +1360,6 @@ eal_parse_lcores(const char *lcores)continue ; set_count--; -if (runtime_state->lcore_cfg[idx].role !=ROLE_RTE ) { -rte_bitset_set (runtime_state->core_indices, count); - runtime_state->lcore_cfg[idx].core_index = count; - runtime_state->lcore_cfg[idx].role =ROLE_RTE ; - count++; - } -if (lflags) {CPU_ZERO (&cpuset);CPU_SET (idx, &cpuset);
@@ -1374,10 +1367,16 @@ eal_parse_lcores(const char *lcores)if (check_cpuset (&cpuset) <0 ) goto err; -rte_memcpy (&runtime_state->lcore_cfg[idx].cpuset, &cpuset, -sizeof (rte_cpuset_t)); - runtime_state->lcore_cfg[idx].first_cpu = - (uint16_t )(RTE_CPU_FFS (&cpuset) -1 ); +if (cpusets[idx] ==NULL ) { + cpusets[idx] =malloc (sizeof (rte_cpuset_t)); +if (cpusets[idx] ==NULL ) { +EAL_LOG (ERR ,"failed to allocate cpuset for lcore %u" , idx); + ret =-1 ; + goto err; + } + count++; + } +memcpy (cpusets[idx], &cpuset,sizeof (rte_cpuset_t)); }/* some cores from the lcore_set can't be handled by EAL */
@@ -1390,11 +1389,14 @@ eal_parse_lcores(const char *lcores)if (count ==0 ) goto err; - runtime_state->lcore_count = count; - ret =0 ; - + ret = count; err: - +if (ret ==-1 ) { +for (unsigned int j =0 ; j <RTE_MAX_LCORE ; j++) { +free (cpusets[j]); + cpusets[j] =NULL ; + } + }return ret; }
@@ -2036,7 +2038,7 @@ eal_parse_args(void)/* First handle the special case where we have explicit core mapping/remapping */ if (manual_lcore_mapping) { -if (eal_parse_lcores (args.lcores) <0 ) { +if (eal_parse_lcores_to_map (args.lcores, user_cfg->lcore_cpusets) <0 ) {EAL_LOG (ERR ,"invalid lcore mapping list: '%s'" , args.lcores);return -1 ; }
@@ -2074,7 +2076,8 @@ eal_parse_args(void)EAL_LOG (DEBUG ,"Cores selected by %s: %s" , cpuset_source, cpuset_str);free (cpuset_str); } -if (update_lcore_config (&cpuset, remap_lcores, lcore_id_base) <0 ) { +if (eal_expand_cpuset_to_map (&cpuset, remap_lcores, lcore_id_base, + user_cfg->lcore_cpusets) <0 ) {char *available =available_cores (); EAL_LOG(ERR, "invalid coremask or core-list parameter, please check specified cores are part of %s",
@@ -2414,7 +2417,46 @@ eal_cleanup_config(void)free (user_cfg->hugefile_prefix);free (user_cfg->hugepage_dir);free (user_cfg->user_mbuf_pool_ops_name); +for (unsigned int i =0 ; i <RTE_MAX_LCORE ; i++) { +free (user_cfg->lcore_cpusets[i]); + user_cfg->lcore_cpusets[i] =NULL ; + } + +return 0 ; +} + +static int +eal_apply_lcore_config (void ) +{ +struct eal_user_cfg *user_cfg =eal_get_user_configuration (); + +/* lcore_cpusets[] is always populated at parse time for all input forms */ +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +unsigned int i; +unsigned int count =0 ; +rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE ); +for (i =0 ; i <RTE_MAX_LCORE ; i++) { +if (user_cfg->lcore_cpusets[i] ==NULL ) { + runtime_state->lcore_cfg[i].role =ROLE_OFF ; + runtime_state->lcore_cfg[i].core_index =-1 ; +CPU_ZERO (&runtime_state->lcore_cfg[i].cpuset); + runtime_state->lcore_cfg[i].first_cpu =UINT16_MAX ; +continue ; + } +rte_bitset_set (runtime_state->core_indices, count); + runtime_state->lcore_cfg[i].role =ROLE_RTE ; + runtime_state->lcore_cfg[i].core_index = count++; +memcpy (&runtime_state->lcore_cfg[i].cpuset, + user_cfg->lcore_cpusets[i],sizeof (rte_cpuset_t)); + runtime_state->lcore_cfg[i].first_cpu = + (uint16_t )(RTE_CPU_FFS (&runtime_state->lcore_cfg[i].cpuset) -1 ); + } +if (count ==0 ) { +EAL_LOG (ERR ,"No valid lcores in core list" ); +return -1 ; + } + runtime_state->lcore_count = count;return 0 ; }
@@ -2424,6 +2466,9 @@ eal_apply_runtime_state(void)struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +if (eal_apply_lcore_config () <0 ) +return -1 ; +/* Apply service core roles: service_cpuset bits are lcore IDs */ if (CPU_COUNT (&user_cfg->service_cpuset) >0 ) {unsigned int i;
lib/eal/common/eal_internal_cfg.h +8 -1
@@ -138,7 +138,14 @@ struct eal_user_cfg { } pagesz_mem_overrides[MAX_HUGEPAGE_SIZES ];unsigned int num_pagesz_mem_overrides;/**< number of stored overrides */ rte_cpuset_t service_cpuset;/**< each bit set is one lcore ID to use as service core */ -int main_lcore;/**< ID of the main lcore */ + +/** Per-lcore cpuset array, always populated at arg-parse time for all input forms +* (-c coremask, -l corelist, --lcores with or without '@'/'()'). +* Each non-NULL slot is an individually heap-allocated rte_cpuset_t. +* NULL means the corresponding lcore ID is not configured. +*/ +rte_cpuset_t *lcore_cpusets[RTE_MAX_LCORE ]; +int main_lcore;/**< ID of the main lcore */ };/**
lib/eal/freebsd/eal.c +1 -0
@@ -750,6 +750,7 @@ rte_eal_init(int argc, char **argv)return fctret; err_out:rte_atomic_store_explicit (&run_once,0 , rte_memory_order_relaxed); +eal_cleanup_config ();eal_clean_saved_args ();return -1 ; }
lib/eal/linux/eal.c +1 -0
@@ -925,6 +925,7 @@ rte_eal_init(int argc, char **argv) err_out:rte_atomic_store_explicit (&run_once,0 , rte_memory_order_relaxed); +eal_cleanup_config ();eal_clean_saved_args ();return -1 ; }
lib/eal/windows/eal.c +1 -0
@@ -414,6 +414,7 @@ rte_eal_init(int argc, char **argv)return fctret; err_out: +eal_cleanup_config ();eal_clean_saved_args ();return -1 ; }
Signature · 1 line
2.53.0
PATCH v2 32/39 eal: clarify docs on params taking lcore IDs
In reply to Bruce RichardsonThe documentation doesn't make clear how the parameters to service core and main lcore EAL flags relate to the regular --lcores parameter when mapping lcores to physical CPU ids.
For example, when looking to add service cores to process run using the command "/path/to/app -R -l 40-50", it's not clear whether the service cores list parameter should be "-S 49-50" i.e. physical CPU ids, or "-S 9-10" i.e. logical lcore IDs. Update the docs to make it clear its the latter.
--- doc/guides/linux_gsg/eal_args.include.rst | 38 +++++++++++++++++++++-- lib/eal/common/eal_option_list.h | 6 ++-- 2 files changed, 38 insertions(+), 6 deletions(-)
doc/guides/linux_gsg/eal_args.include.rst +35 -3
@@ -89,13 +89,45 @@ Lcore-related options and the use of ``()`` for core groupings, are not allowed when ``-R`` or ``--remap-lcore-ids`` is also used. -* ``--main-lcore <core ID>`` +* ``--main-lcore <lcore ID>`` - Core ID that is used as main. + Set the lcore ID to use for the main thread. + The value is a DPDK lcore ID, not a physical CPU ID, + and must be present in the enabled lcore set (as configured by ``-l``/``--lcores``). + + In the simple case, without any explicit lcore-to-CPU mapping, + lcore IDs equal physical CPU IDs so the distinction does not matter. + The two differ when ``-R``/``--remap-lcore-ids`` assigns sequential lcore IDs to higher-numbered physical CPUs, + or when the ``@`` mapping syntax in ``--lcores`` is used. + In those cases the lcore ID must be specified here, not the physical CPU ID. + + Example using ``--lcores`` explicit mapping: + ``--lcores=1@31,2@32,3@33 --main-lcore 2`` selects the thread with lcore ID 2, + running on physical CPU 32, as the main thread. + + Example using ``-R`` remapping: + ``-l 31-33 -R --main-lcore 1`` starts three threads on physical CPUs 31, 32 and 33, remapped to lcore IDs 0, 1 and 2. + ``--main-lcore 1`` selects the thread remapped to lcore ID 1, which runs on physical CPU 32. * ``-S, --service-corelist <service core list>`` - List of cores to be used as service cores. + List of lcore IDs to be used as service cores. + The list format is the same as for ``-l``/``--lcores``: + a comma-separated set of lcore IDs or ranges (e.g. ``2,3`` or ``2-5``). + Each specified lcore ID must be present in the enabled lcore set. + + The values are lcore IDs, not physical CPU IDs. + In the simple case, without any explicit lcore-to-CPU mapping, the two are equal so the distinction does not matter. + When using ``-R``/``--remap-lcore-ids`` or the ``@`` mapping syntax in ``--lcores``, lcore IDs and physical CPU IDs differ, + and the lcore IDs must be used here. + + Example using ``--lcores`` explicit mapping: + ``--lcores=1@31,2@32,3@33 -S 2,3`` assigns the threads with + lcore IDs 2 and 3 (running on physical CPUs 32 and 33) as service cores. + + Example using ``-R`` remapping: + ``-l 31-33 -R -S 1,2`` starts three threads on physical CPUs 31, 32 and 33, remapped to lcore IDs 0, 1 and 2. + ``-S 1,2`` assigns the threads with lcore IDs 1 and 2 (running on physical CPUs 32 and 33) as service cores. Device-related options
lib/eal/common/eal_option_list.h +3 -3
@@ -47,7 +47,7 @@ BOOL_ARG("--legacy-mem", NULL, "Enable legacy memory behavior", legacy_mem) OPT_STR_ARG("--log-color", NULL, "Enable/disable color in log output", log_color) LIST_ARG("--log-level", NULL, "Log level for loggers; use log-level=help for list of log types and levels", log_level) OPT_STR_ARG("--log-timestamp", NULL, "Enable/disable timestamp in log output", log_timestamp) -STR_ARG("--main-lcore", NULL, "Select which core to use for the main thread", main_lcore) +STR_ARG("--main-lcore", NULL, "Lcore ID to use for the main thread", main_lcore) STR_ARG("--mbuf-pool-ops-name", NULL, "User defined mbuf default pool ops name", mbuf_pool_ops_name) STR_ARG("--memory-channels", "-n", "Number of memory channels per socket", memory_channels)STR_ARG ("--memory-ranks" ,"-r" ,"Force number of memory ranks (don't detect)" , memory_ranks)
@@ -61,8 +61,8 @@ BOOL_ARG("--no-telemetry", NULL, "Disable telemetry", no_telemetry) LIST_ARG("--pagesz-mem", NULL, "Memory allocation per hugepage size (format: <pagesz>:<limit>, e.g. 2M:32G). Repeat option for multiple page sizes.", pagesz_mem) STR_ARG("--proc-type", NULL, "Type of process (primary|secondary|auto)", proc_type) OPT_STR_ARG("--remap-lcore-ids", "-R", "Remap lcore IDs to be contiguous starting from 0, or supplied value", remap_lcore_ids) -STR_ARG("--service-corelist", "-S", "List of cores to use for service threads", service_corelist) -STR_ARG("--service-coremask", "-s", "[Deprecated] Bitmask of cores to use for service threads", service_coremask) +STR_ARG("--service-corelist", "-S", "List of lcore IDs to use for service threads", service_corelist) +STR_ARG("--service-coremask", "-s", "[Deprecated] Bitmask of lcore IDs to use for service threads", service_coremask) BOOL_ARG("--single-file-segments", NULL, "Store all pages within single files (per-page-size, per-node)", single_file_segments) BOOL_ARG("--telemetry", NULL, "Enable telemetry", telemetry)LIST_ARG ("--vdev" ,NULL ,"Add a virtual device to the system; format=<driver><id>[,key=val,...]" , vdev)
Signature · 1 line
2.53.0
PATCH v2 33/39 eal: remove internal config reset function
In reply to Bruce RichardsonRather than having a single function which attempts to reset multiple internal config structures, just init each structure in the function which configures it. Use structure assignment for initialization rather than a series of assignment statements.
--- lib/eal/common/eal_common_config.c | 8 ++- lib/eal/common/eal_common_options.c | 92 ++++++----------------------- lib/eal/common/eal_internal_cfg.h | 1 - lib/eal/freebsd/eal.c | 2 - lib/eal/linux/eal.c | 2 - 5 files changed, 26 insertions(+), 79 deletions(-)
lib/eal/common/eal_common_config.c +7 -1
@@ -27,7 +27,13 @@ static char runtime_dir[UNIX_PATH_MAX];static struct eal_user_cfg eal_user_cfg;/* platform-discovered and runtime EAL state */ -static struct eal_platform_info eal_platform_info; +static struct eal_platform_info eal_platform_info = { + .hugepage_info = { + [0 ] = {.lock_descriptor =-1 }, + [1 ] = {.lock_descriptor =-1 }, + [2 ] = {.lock_descriptor =-1 } + } +};/* internal runtime configuration */ static struct eal_runtime_state eal_runtime_state = {
lib/eal/common/eal_common_options.c +19 -73
116 lines not on this page · raw message
lib/eal/common/eal_internal_cfg.h +0 -1
@@ -223,6 +223,5 @@ struct eal_runtime_state {struct eal_user_cfg *eal_get_user_configuration (void );struct eal_platform_info *eal_get_platform_info (void );struct eal_runtime_state *eal_get_runtime_state (void ); -void eal_reset_internal_config (void );#endif /* EAL_INTERNAL_CFG_H */
lib/eal/freebsd/eal.c +0 -2
@@ -444,8 +444,6 @@ rte_eal_init(int argc, char **argv) goto err_out; } -eal_reset_internal_config (); -if (rte_eal_cpu_init () <0 ) {rte_eal_init_alert ("Cannot detect lcores." ); rte_errno =ENOTSUP ;
lib/eal/linux/eal.c +0 -2
@@ -606,8 +606,6 @@ rte_eal_init(int argc, char **argv) goto err_out; } -eal_reset_internal_config (); -if (rte_eal_cpu_init () <0 ) {rte_eal_init_alert ("Cannot detect lcores." ); rte_errno =ENOTSUP ;
Signature · 1 line
2.53.0
PATCH v2 34/39 eal: move functions setting runtime state
In reply to Bruce RichardsonThe functions to configure some of the runtime state based on the user-provided options no longer belong in eal_common_options.c, which should instead be more focused on processing the user-provided options. Move the functions to eal_common_config instead, and explicitly have the runtime state setup function called from eal_init directly, rather than hidden as a last step in arg parsing.
--- lib/eal/common/eal_common_config.c | 170 +++++++++++++++++++++++++++- lib/eal/common/eal_common_options.c | 167 +-------------------------- lib/eal/common/eal_options.h | 3 - lib/eal/common/eal_private.h | 33 ++++++ lib/eal/freebsd/eal.c | 6 + lib/eal/linux/eal.c | 6 + lib/eal/windows/eal.c | 6 + 7 files changed, 221 insertions(+), 170 deletions(-)
lib/eal/common/eal_common_config.c +169 -1
@@ -2,8 +2,10 @@* Copyright(c) 2020 Mellanox Technologies, Ltd */ -#include <rte_string_fns.h> +#include <pthread.h> +#include <rte_string_fns.h> +#include <rte_thread.h> #include <eal_export.h> #include "eal_internal_cfg.h" #include "eal_private.h"
@@ -133,3 +135,169 @@ rte_eal_has_pci(void) {return !eal_user_cfg.no_pci; } + +static void +compute_ctrl_threads_cpuset (void ) +{ +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +rte_cpuset_t *cpuset = &runtime_state->ctrl_cpuset; +rte_cpuset_t default_set; +unsigned int lcore_id; + +CPU_ZERO (cpuset); +for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { +if (rte_lcore_has_role (lcore_id,ROLE_OFF )) +continue ; +RTE_CPU_OR (cpuset, cpuset, &runtime_state->lcore_cfg[lcore_id].cpuset); + } +RTE_CPU_NOT (cpuset, cpuset); + +if (rte_thread_get_affinity_by_id (rte_thread_self (), &default_set) !=0 ) +CPU_ZERO (&default_set); + +RTE_CPU_AND (cpuset, cpuset, &default_set); + +/* if no remaining cpu, use main lcore cpu affinity */ +if (!CPU_COUNT (cpuset)) { +memcpy (cpuset, &runtime_state->lcore_cfg[rte_get_main_lcore ()].cpuset, +sizeof (*cpuset)); + } + +/* log the computed control thread cpuset for debugging */ +char *cpuset_str =eal_cpuset_to_str (cpuset); +if (cpuset_str !=NULL ) { +EAL_LOG (DEBUG ,"Control threads will use cores: %s" , cpuset_str); +free (cpuset_str); + } +} + +static int +eal_apply_lcore_config (void ) +{ +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); + +/* lcore_cpusets[] is always populated at parse time for all input forms */ +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +unsigned int i; +unsigned int count =0 ; + +rte_bitset_clear_all (runtime_state->core_indices,RTE_MAX_LCORE ); +for (i =0 ; i <RTE_MAX_LCORE ; i++) { +if (user_cfg->lcore_cpusets[i] ==NULL ) { + runtime_state->lcore_cfg[i].role =ROLE_OFF ; + runtime_state->lcore_cfg[i].core_index =-1 ; +CPU_ZERO (&runtime_state->lcore_cfg[i].cpuset); + runtime_state->lcore_cfg[i].first_cpu =UINT16_MAX ; +continue ; + } +rte_bitset_set (runtime_state->core_indices, count); + runtime_state->lcore_cfg[i].role =ROLE_RTE ; + runtime_state->lcore_cfg[i].core_index = count++; +memcpy (&runtime_state->lcore_cfg[i].cpuset, + user_cfg->lcore_cpusets[i],sizeof (rte_cpuset_t)); + runtime_state->lcore_cfg[i].first_cpu = + (uint16_t )(RTE_CPU_FFS (&runtime_state->lcore_cfg[i].cpuset) -1 ); + } +if (count ==0 ) { +EAL_LOG (ERR ,"No valid lcores in core list" ); +return -1 ; + } + runtime_state->lcore_count = count; +return 0 ; +} + +int +eal_apply_runtime_state (void ) +{ +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); + +if (eal_apply_lcore_config () <0 ) +return -1 ; + +/* Apply service core roles: service_cpuset bits are lcore IDs */ +if (CPU_COUNT (&user_cfg->service_cpuset) >0 ) { +unsigned int i; +char *cpuset_str; + +for (i =0 ; i <RTE_MAX_LCORE ; i++) { +if (!CPU_ISSET (i, &user_cfg->service_cpuset)) +continue ; +if (eal_cpu_detected (i) ==0 ) { +EAL_LOG (ERR ,"Requested service lcore %u unavailable" , i); +return -1 ; + } +if (runtime_state->lcore_cfg[i].role !=ROLE_RTE ) { +EAL_LOG (WARNING , +"service lcore %u is not in the enabled lcore set; please ensure -c or -l includes service cores" , + i); + } + runtime_state->lcore_cfg[i].role =ROLE_SERVICE ; + } + cpuset_str =eal_cpuset_to_str (&user_cfg->service_cpuset); +if (cpuset_str !=NULL ) { +EAL_LOG (DEBUG ,"Service cores configured: %s" , cpuset_str); +free (cpuset_str); + } + } + +/* 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 ; + } + } + +#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 + + 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 ; +} + +int +eal_apply_hugepage_mem_sz_limits (void ) +{ +const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); +const struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +unsigned int i; + +for (i =0 ; i < platform_info->num_hugepage_sizes; i++) { +unsigned int j; +const uint64_t pagesz = platform_info->hugepage_info[i].hugepage_sz; +uint64_t limit; + +/* assign default limits */ + limit =RTE_MIN ((uint64_t )RTE_MAX_MEM_MB_PER_TYPE <<20 , + (uint64_t )RTE_MAX_MEMSEG_PER_TYPE * pagesz); + +/* override with user value for matching page size */ +for (j =0 ; j < user_cfg->num_pagesz_mem_overrides; j++) { +if (user_cfg->pagesz_mem_overrides[j].pagesz == pagesz) + limit = user_cfg->pagesz_mem_overrides[j].limit; + } + + runtime_state->hugepage_mem_sz_limits[i] = limit; + } + +return 0 ; +}
lib/eal/common/eal_common_options.c +1 -166
179 lines not on this page · raw message
lib/eal/common/eal_options.h +0 -3
@@ -13,10 +13,7 @@ struct eal_user_cfg;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_apply_runtime_state (void );int eal_cleanup_config (void ); -enum rte_proc_type_t eal_proc_type_detect (void );int eal_plugins_init (void );int eal_save_args (int argc,char **argv);void eal_clean_saved_args (void );
lib/eal/common/eal_private.h +33 -0
@@ -28,6 +28,39 @@*/ int eal_collate_args (int argc,char **argv); +/** +* Apply user configuration to runtime state. +* +* Translates the populated eal_user_cfg into the eal_runtime_state, +* including lcore roles, main lcore, service cores, process type +* detection, and the runtime directory. +* +* @return +* 0 on success, negative on error +*/ +int eal_apply_runtime_state (void ); + +/** +* Detect the process type. +* +* Used to detect process type when the user requests process type auto-detection, +* rather than manually specifying primary or secondary. +* @return +* The detected process type. +*/ +enum rte_proc_type_t eal_proc_type_detect (void ); + +/** +* Apply user-provided hugepage memory size overrides to the runtime state. +* +* Computes the per-hugepage-size memory limits, applying any user-supplied +* overrides on top of the default limits. +* +* @return +* 0 on success, negative on error +*/ +int eal_apply_hugepage_mem_sz_limits (void ); +/** * Convert an rte_cpuset_t to string form suitable for parsing by argparse. *
lib/eal/freebsd/eal.c +6 -0
@@ -463,6 +463,12 @@ rte_eal_init(int argc, char **argv) user_cfg->in_memory = false; } +if (eal_apply_runtime_state () <0 ) { +rte_eal_init_alert ("Cannot apply runtime state." ); + rte_errno =EINVAL ; + goto err_out; + } +if (eal_plugins_init () <0 ) {rte_eal_init_alert ("Cannot init plugins" ); rte_errno =EINVAL ;
lib/eal/linux/eal.c +6 -0
@@ -618,6 +618,12 @@ rte_eal_init(int argc, char **argv) goto err_out; } +if (eal_apply_runtime_state () <0 ) { +rte_eal_init_alert ("Cannot apply runtime state." ); + rte_errno =EINVAL ; + goto err_out; + } +if (eal_plugins_init () <0 ) {rte_eal_init_alert ("Cannot init plugins" ); rte_errno =EINVAL ;
lib/eal/windows/eal.c +6 -0
@@ -217,6 +217,12 @@ rte_eal_init(int argc, char **argv) user_cfg->no_shconf = true; } +if (eal_apply_runtime_state () <0 ) { +rte_eal_init_alert ("Cannot apply runtime state." ); + rte_errno =EINVAL ; + goto err_out; + } +if (!user_cfg->no_hugetlbfs && (eal_hugepage_info_init () <0 )) {rte_eal_init_alert ("Cannot get hugepage information" ); rte_errno =EACCES ;
Signature · 1 line
2.53.0
PATCH v2 35/39 eal: initialize platform info on first use
In reply to Bruce RichardsonThe platform information should be made available as early in the init process as possible, since it should be fixed and not depend on any application or user provided data. Therefore, rework the hugepage info so that the basic HP info only is stored in the platform info struct, and things like lock fd's are found in the runtime state struct.
Then start enhancing the get_platform_info structure so that it is initialized on first use, rather than having it initialized as part of the normal flow of rte_eal_init(). The objective is to have the platform info, both cpu and memory, fully available when processing the user configuration parameters, in order to properly validate them. Note that this may defer some error conditions to later, because hugepage scanning failures, for example, need not be an error when scanning the platform info, if we later discover the app is being run with --no-huge flag.
--- lib/eal/common/eal_common_config.c | 50 +++++++++--- lib/eal/common/eal_common_dynmem.c | 27 ++++--- lib/eal/common/eal_common_lcore.c | 13 +++- lib/eal/common/eal_hugepages.h | 8 ++ lib/eal/common/eal_internal_cfg.h | 15 +++- lib/eal/common/eal_private.h | 18 ++++- lib/eal/freebsd/eal.c | 23 ++++-- lib/eal/freebsd/eal_hugepage_info.c | 60 ++++++++++---- lib/eal/freebsd/eal_memory.c | 15 ++-- lib/eal/linux/eal.c | 28 ++++--- lib/eal/linux/eal_hugepage_info.c | 117 ++++++++++++++++++++++++---- lib/eal/linux/eal_memalloc.c | 24 +++--- lib/eal/linux/eal_memory.c | 59 +++++++------- lib/eal/windows/eal.c | 24 +++--- lib/eal/windows/eal_hugepages.c | 35 ++++++++- lib/eal/windows/eal_memalloc.c | 11 +-- lib/eal/windows/eal_windows.h | 8 -- 17 files changed, 377 insertions(+), 158 deletions(-)
lib/eal/common/eal_common_config.c +39 -11
@@ -10,6 +10,7 @@#include "eal_internal_cfg.h" #include "eal_private.h" #include "eal_filesystem.h" +#include "eal_hugepages.h" #include "eal_memcfg.h" /* early configuration structure, when memory config is not mmapped */
@@ -28,15 +29,6 @@ static char runtime_dir[UNIX_PATH_MAX];/* user-provided EAL configuration */ static struct eal_user_cfg eal_user_cfg; -/* platform-discovered and runtime EAL state */ -static struct eal_platform_info eal_platform_info = { - .hugepage_info = { - [0 ] = {.lock_descriptor =-1 }, - [1 ] = {.lock_descriptor =-1 }, - [2 ] = {.lock_descriptor =-1 } - } -}; -/* internal runtime configuration */ static struct eal_runtime_state eal_runtime_state = { .mem_config = &early_mem_config,
@@ -76,9 +68,42 @@ eal_get_user_configuration(void) }/* Return a pointer to the platform state structure */ -struct eal_platform_info * +const struct eal_platform_info *eal_get_platform_info (void ) { +/* platform-discovered and runtime EAL state */ +static struct eal_platform_info eal_platform_info; +static rte_spinlock_t init_lock =RTE_SPINLOCK_INITIALIZER ; +static RTE_ATOMIC (bool ) initialized; + +if (unlikely (!rte_atomic_load_explicit (&initialized, rte_memory_order_acquire))) { +struct eal_platform_info discovered_info = {0 }; + +rte_spinlock_lock (&init_lock); +if (rte_atomic_load_explicit (&initialized, rte_memory_order_relaxed)) { +rte_spinlock_unlock (&init_lock); +return &eal_platform_info; + } +if (rte_eal_cpu_init (&discovered_info) <0 ) { +EAL_LOG (ERR ,"Failed to initialise CPU information" ); + goto fail; + } +if (eal_get_platform_hp_info (&discovered_info) <0 ) { +EAL_LOG (ERR ,"Failed to get platform hugepage information" ); + goto fail; + } + eal_platform_info = discovered_info; +rte_atomic_store_explicit (&initialized, true, rte_memory_order_release); +rte_spinlock_unlock (&init_lock); +return &eal_platform_info; + +fail: +free (discovered_info.cpu_info); +free (discovered_info.numa_nodes); +rte_spinlock_unlock (&init_lock); +return NULL ; + } +return &eal_platform_info; }
@@ -212,6 +237,9 @@ eal_apply_runtime_state(void)const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +for (unsigned int i =0 ; i <MAX_HUGEPAGE_SIZES ; i++) + runtime_state->hugepage_info[i].lock_descriptor =-1 ; +if (eal_apply_lcore_config () <0 )return -1 ;
@@ -283,7 +311,7 @@ eal_apply_hugepage_mem_sz_limits(void)for (i =0 ; i < platform_info->num_hugepage_sizes; i++) {unsigned int j; -const uint64_t pagesz = platform_info->hugepage_info[i].hugepage_sz; +const uint64_t pagesz = platform_info->hugepage_sizes[i].size;uint64_t limit;/* assign default limits */
lib/eal/common/eal_common_dynmem.c +13 -14
@@ -34,7 +34,6 @@ eal_dynmem_memseg_lists_init(void)size_t mem_va_len, mem_va_page_sz;unsigned int n_memtypes, cur_type;void *mem_va_addr =NULL ; -struct eal_platform_info *platform_info =eal_get_platform_info ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();
@@ -58,7 +57,7 @@ eal_dynmem_memseg_lists_init(void)*/ /* maximum number of memtypes we're ever going to get */ - n_memtypes = platform_info->num_hugepage_sizes *rte_socket_count (); + n_memtypes = runtime_state->num_hugepage_sizes *rte_socket_count ();/* can we fit all memtypes into the memseg lists? */ if (n_memtypes >RTE_MAX_MEMSEG_LISTS ) {
@@ -69,12 +68,12 @@ eal_dynmem_memseg_lists_init(void)/* populate mem types */ cur_type =0 ; -for (hpi_idx =0 ; hpi_idx < (int ) platform_info->num_hugepage_sizes; +for (hpi_idx =0 ; hpi_idx < (int ) runtime_state->num_hugepage_sizes; hpi_idx++) { -struct hugepage_info *hpi; +const struct hugepage_info *hpi;uint64_t hugepage_sz; - hpi = &platform_info->hugepage_info[hpi_idx]; + hpi = &runtime_state->hugepage_info[hpi_idx]; hugepage_sz = hpi->hugepage_sz;for (i =0 ; i < (int )rte_socket_count (); i++, cur_type++) {
@@ -211,13 +210,13 @@ eal_dynmem_hugepage_init(void)struct hugepage_info used_hp[MAX_HUGEPAGE_SIZES ];uint64_t memory[RTE_MAX_NUMA_NODES ];int hp_sz_idx, socket_id; -struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();memset (used_hp,0 ,sizeof (used_hp));for (hp_sz_idx =0 ; - hp_sz_idx < (int ) platform_info->num_hugepage_sizes; + hp_sz_idx < (int ) runtime_state->num_hugepage_sizes; hp_sz_idx++) {#ifndef RTE_ARCH_64 struct hugepage_info dummy;
@@ -225,7 +224,7 @@ eal_dynmem_hugepage_init(void)#endif /* also initialize used_hp hugepage sizes in used_hp */ struct hugepage_info *hpi; - hpi = &platform_info->hugepage_info[hp_sz_idx]; + hpi = &runtime_state->hugepage_info[hp_sz_idx]; used_hp[hp_sz_idx].hugepage_sz = hpi->hugepage_sz;#ifndef RTE_ARCH_64
@@ -253,12 +252,12 @@ eal_dynmem_hugepage_init(void)/* calculate final number of pages */ if (eal_dynmem_calc_num_pages_per_socket (memory, - platform_info->hugepage_info, used_hp, - platform_info->num_hugepage_sizes) <0 ) + runtime_state->hugepage_info, used_hp, + runtime_state->num_hugepage_sizes) <0 )return -1 ;for (hp_sz_idx =0 ; - hp_sz_idx < (int )platform_info->num_hugepage_sizes; + hp_sz_idx < (int )runtime_state->num_hugepage_sizes; hp_sz_idx++) {for (socket_id =0 ; socket_id <RTE_MAX_NUMA_NODES ; socket_id++) {
@@ -337,10 +336,10 @@ get_socket_mem_size(int socket) {uint64_t size =0 ;unsigned int i; -struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); -for (i =0 ; i < platform_info->num_hugepage_sizes; i++) { -struct hugepage_info *hpi = &platform_info->hugepage_info[i]; +for (i =0 ; i < runtime_state->num_hugepage_sizes; i++) { +struct hugepage_info *hpi = &runtime_state->hugepage_info[i]; size += hpi->hugepage_sz * hpi->num_pages[socket]; }
lib/eal/common/eal_common_lcore.c +10 -3
@@ -164,12 +164,16 @@ socket_id_cmp(const void *a, const void *b)* structure. */ int -rte_eal_cpu_init (void ) +rte_eal_cpu_init (struct eal_platform_info *platform_info) { -struct eal_platform_info *platform_info =eal_get_platform_info ();int *lcore_to_socket_id;size_t nb_detected_cpus =0 ; +if (eal_create_cpu_map () <0 ) { +EAL_LOG (ERR ,"Failed to create CPU map" ); +return -1 ; + } +/* allocate cpu_info for all CPUs visible to the OS */ platform_info->cpu_count =eal_cpu_max (); platform_info->cpu_info = calloc(platform_info->cpu_count,
@@ -182,6 +186,7 @@ rte_eal_cpu_init(void)if (lcore_to_socket_id ==NULL ) {EAL_LOG (ERR ,"Cannot allocate lcore_to_socket_id array" );free (platform_info->cpu_info); + platform_info->cpu_info =NULL ;return -1 ; }
@@ -203,8 +208,9 @@ rte_eal_cpu_init(void)if (nb_detected_cpus ==0 ) {EAL_LOG (ERR ,"No CPUs detected for platform topology" ); -free (platform_info->cpu_info);free (lcore_to_socket_id); +free (platform_info->cpu_info); + platform_info->cpu_info =NULL ;return -1 ; }
@@ -219,6 +225,7 @@ rte_eal_cpu_init(void)EAL_LOG (ERR ,"Cannot allocate numa_nodes array" );free (lcore_to_socket_id);free (platform_info->cpu_info); + platform_info->cpu_info =NULL ;return -1 ; }
lib/eal/common/eal_hugepages.h +8 -0
@@ -11,6 +11,8 @@#define MAX_HUGEPAGE_PATH PATH_MAX +struct eal_platform_info ; +/** * Structure used to store information about hugepages that we mapped * through the files in hugetlbfs.
@@ -25,6 +27,12 @@ struct hugepage_file {char filepath[MAX_HUGEPAGE_PATH ];/**< path to backing file on filesystem */ }; +/** +* Discover hugepage sizes and mounts available on this platform and populate +* the hugepage_sizes[] fields of the provided platform_info struct. +*/ +int eal_get_platform_hp_info (struct eal_platform_info *platform_info); +/** * Read the information on what hugepages are available for the EAL to use, * clearing out any unused ones.
lib/eal/common/eal_internal_cfg.h +13 -2
@@ -158,6 +158,14 @@ struct eal_cpu_info {unsigned int core_id;/**< physical core number on its NUMA node */ }; +struct hp_sizes { +uint64_t size;/**< hugepage size in bytes */ +char dir[PATH_MAX ];/**< dir where hugetlbfs is mounted for this size */ +uint32_t total_pages;/**< total hugepages of this size across all NUMA nodes */ +uint32_t max_pages[RTE_MAX_NUMA_NODES ]; +/**< maximum hugepages of this size available on each NUMA node */ +}; +/** * Discovered information about the system hardware. * Immutable after discovery.
@@ -168,7 +176,7 @@ struct eal_platform_info {uint32_t numa_node_count;/**< number of detected NUMA nodes */ uint32_t *numa_nodes;/**< sorted list of detected NUMA node IDs */ uint8_t num_hugepage_sizes;/**< how many sizes on this system */ -struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES ]; +struct hp_sizes hugepage_sizes[MAX_HUGEPAGE_SIZES ]; };/**
@@ -216,12 +224,15 @@ struct eal_runtime_state {uint32_t lcore_count;/**< Number of active lcore IDs (role != ROLE_OFF). */ struct lcore_cfg lcore_cfg[RTE_MAX_LCORE ];RTE_BITSET_DECLARE (core_indices,RTE_MAX_LCORE );/**< currently allocated core_indices */ + +uint32_t num_hugepage_sizes;/**< how many sizes stored in hugepage_info[] */ +struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES ];struct rte_mem_config *mem_config;/**< pointer to memory config (in shared memory) */ struct eal_solib_list loaded_plugins; /**< all plugins loaded by eal_plugins_init() */ }; +const struct eal_platform_info *eal_get_platform_info (void );struct eal_user_cfg *eal_get_user_configuration (void ); -struct eal_platform_info *eal_get_platform_info (void );struct eal_runtime_state *eal_get_runtime_state (void );#endif /* EAL_INTERNAL_CFG_H */
lib/eal/common/eal_private.h +17 -1
@@ -95,10 +95,12 @@ int rte_eal_memzone_init(void);* Parse /proc/cpuinfo to get the number of physical and logical * processors on the machine. * +* @param platform_info +* Platform info struct to populate with CPU topology. * @return * 0 on success, negative on error */ -int rte_eal_cpu_init (void ); +int rte_eal_cpu_init (struct eal_platform_info *platform_info);/** * Check for architecture supported MMU.
@@ -762,6 +764,20 @@ int eal_asprintf(char **buffer, const char *format, ...); eal_asprintf(buffer, format, ##__VA_ARGS__)#endif +/** +* Create a map of processors and cores on the system. +* +* @return +* 0 on success, (-1) on failure and rte_errno is set. +*/ +#ifdef RTE_EXEC_ENV_WINDOWS +int eal_create_cpu_map (void ); +#else +/* non-Windows platforms do not require CPU map creation, define stub fn */ +static inline int +eal_create_cpu_map (void ) {return 0 ; } +#endif +#define EAL_LOG (level, ...) \ RTE_LOG_LINE(level, EAL, "" __VA_ARGS__)
lib/eal/freebsd/eal.c +15 -8
@@ -322,10 +322,11 @@ eal_get_hugepage_mem_size(void) {uint64_t size =0 ;unsigned i, j; -struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();for (i =0 ; i < platform_info->num_hugepage_sizes; i++) { -struct hugepage_info *hpi = &platform_info->hugepage_info[i]; +struct hugepage_info *hpi = &runtime_state->hugepage_info[i];if (strnlen (hpi->hugedir,sizeof (hpi->hugedir)) !=0 ) {for (j =0 ; j <RTE_MAX_NUMA_NODES ; j++) { size += hpi->hugepage_sz * hpi->num_pages[j];
@@ -403,6 +404,18 @@ rte_eal_init(int argc, char **argv)bool has_phys_addr;enum rte_iova_mode iova_mode; +/* +* platform_info is lazily initialized on first use, and that +* initialization can fail (CPU/NUMA/hugepage detection). Almost +* everything below depends on a valid platform_info, so confirm it +* is available before doing anything else. +*/ +if (eal_get_platform_info () ==NULL ) { +rte_eal_init_alert ("Cannot get platform information." ); + rte_errno =ENOTSUP ; +return -1 ; + } +/* first check if we have been run before */ if (!rte_atomic_compare_exchange_strong_explicit (&run_once, &has_run,1 , rte_memory_order_relaxed, rte_memory_order_relaxed)) {
@@ -444,12 +457,6 @@ rte_eal_init(int argc, char **argv) goto err_out; } -if (rte_eal_cpu_init () <0 ) { -rte_eal_init_alert ("Cannot detect lcores." ); - rte_errno =ENOTSUP ; - goto err_out; - } -if (eal_parse_args () <0 ) {rte_eal_init_alert ("Error parsing command-line arguments." ); rte_errno =EINVAL ;
lib/eal/freebsd/eal_hugepage_info.c +46 -14
120 lines not on this page · raw message
lib/eal/freebsd/eal_memory.c +9 -6
@@ -72,7 +72,8 @@ rte_eal_hugepage_init(void)void *addr;unsigned int i, j, seg_idx =0 ;const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* get pointer to global configuration */ mcfg =eal_get_mcfg ();
@@ -118,7 +119,7 @@ rte_eal_hugepage_init(void)uint64_t page_sz, mem_needed;unsigned int n_pages, max_pages; - hpi = &platform_info->hugepage_info[i]; + hpi = &runtime_state->hugepage_info[i]; page_sz = hpi->hugepage_sz; max_pages = hpi->num_pages[0 ]; mem_needed = RTE_ALIGN_CEIL(user_cfg->memory - total_mem,
@@ -284,12 +285,13 @@ attach_segment(const struct rte_memseg_list *msl, const struct rte_memseg *ms,int rte_eal_hugepage_attach (void ) { -struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct hugepage_info *hpi;int fd_hugepage =-1 ;unsigned int i; - hpi = &platform_info->hugepage_info[0 ]; + hpi = &runtime_state->hugepage_info[0 ];for (i =0 ; i < platform_info->num_hugepage_sizes; i++) {const struct hugepage_info *cur_hpi = &hpi[i];
@@ -352,7 +354,8 @@ memseg_primary_init(void)int hpi_idx, msl_idx =0 ;struct rte_memseg_list *msl;const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* no-huge does not need this at all */ if (user_cfg->no_hugetlbfs)
@@ -371,7 +374,7 @@ memseg_primary_init(void)uint64_t hugepage_sz;unsigned int n_segs; - hpi = &platform_info->hugepage_info[hpi_idx]; + hpi = &runtime_state->hugepage_info[hpi_idx]; hugepage_sz = hpi->hugepage_sz;/* no NUMA support on FreeBSD */
lib/eal/linux/eal.c +17 -11
@@ -406,18 +406,18 @@ eal_mem_config_init(void)static void eal_hugedirs_unlock (void ) { -struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();int i;for (i =0 ; i <MAX_HUGEPAGE_SIZES ; i++) {/* skip uninitialized */ -if (platform_info->hugepage_info[i].lock_descriptor <0 ) +if (runtime_state->hugepage_info[i].lock_descriptor <0 )continue ;/* unlock hugepage file */ -flock (platform_info->hugepage_info[i].lock_descriptor,LOCK_UN ); -close (platform_info->hugepage_info[i].lock_descriptor); +flock (runtime_state->hugepage_info[i].lock_descriptor,LOCK_UN ); +close (runtime_state->hugepage_info[i].lock_descriptor);/* reset the field */ - platform_info->hugepage_info[i].lock_descriptor =-1 ; + runtime_state->hugepage_info[i].lock_descriptor =-1 ; } }
@@ -565,6 +565,18 @@ rte_eal_init(int argc, char **argv)struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_runtime_state *runtime_state =eal_get_runtime_state (); +/* +* platform_info is lazily initialized on first use, and that +* initialization can fail (CPU/NUMA/hugepage detection). Almost +* everything below depends on a valid platform_info, so confirm it +* is available before doing anything else. +*/ +if (eal_get_platform_info () ==NULL ) { +rte_eal_init_alert ("Cannot get platform information." ); + rte_errno =ENOTSUP ; +return -1 ; + } +/* first check if we have been run before */ if (!rte_atomic_compare_exchange_strong_explicit (&run_once, &has_run,1 , rte_memory_order_relaxed, rte_memory_order_relaxed)) {
@@ -606,12 +618,6 @@ rte_eal_init(int argc, char **argv) goto err_out; } -if (rte_eal_cpu_init () <0 ) { -rte_eal_init_alert ("Cannot detect lcores." ); - rte_errno =ENOTSUP ; - goto err_out; - } -if (eal_parse_args () <0 ) {rte_eal_init_alert ("Error parsing command line arguments." ); rte_errno =EINVAL ;
lib/eal/linux/eal_hugepage_info.c +100 -17
192 lines not on this page · raw message
lib/eal/linux/eal_memalloc.c +12 -12
@@ -967,7 +967,7 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, size_t page_sz,struct alloc_walk_param wa;struct hugepage_info *hi =NULL ;const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();memset (&wa,0 ,sizeof (wa));
@@ -975,10 +975,10 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, size_t page_sz,if (user_cfg->legacy_mem)return -1 ; -for (i =0 ; i < (int )RTE_DIM (platform_info->hugepage_info); i++) { +for (i =0 ; i < (int )RTE_DIM (runtime_state->hugepage_info); i++) {if (page_sz == - platform_info->hugepage_info[i].hugepage_sz) { - hi = &platform_info->hugepage_info[i]; + runtime_state->hugepage_info[i].hugepage_sz) { + hi = &runtime_state->hugepage_info[i];break ; } }
@@ -1036,7 +1036,7 @@ eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs) {int seg, ret =0 ;const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* dynamic free not supported in legacy mode */ if (user_cfg->legacy_mem)
@@ -1057,13 +1057,13 @@ eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs)memset (&wa,0 ,sizeof (wa)); -for (i =0 ; i < (int )RTE_DIM (platform_info->hugepage_info); +for (i =0 ; i < (int )RTE_DIM (runtime_state->hugepage_info); i++) { - hi = &platform_info->hugepage_info[i]; + hi = &runtime_state->hugepage_info[i];if (cur->hugepage_sz == hi->hugepage_sz)break ; } -if (i == (int )RTE_DIM (platform_info->hugepage_info)) { +if (i == (int )RTE_DIM (runtime_state->hugepage_info)) {EAL_LOG (ERR ,"Can't find relevant hugepage_info entry" ); ret =-1 ;continue ;
@@ -1327,7 +1327,7 @@ sync_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) {struct rte_mem_config *mcfg =eal_get_mcfg ();struct rte_memseg_list *primary_msl, *local_msl; -struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct hugepage_info *hi =NULL ;unsigned int i;int msl_idx;
@@ -1339,12 +1339,12 @@ sync_walk(const struct rte_memseg_list *msl, void *arg __rte_unused) primary_msl = &mcfg->memsegs[msl_idx]; local_msl = &local_memsegs[msl_idx]; -for (i =0 ; i <RTE_DIM (platform_info->hugepage_info); i++) { +for (i =0 ; i <RTE_DIM (runtime_state->hugepage_info); i++) {uint64_t cur_sz = - platform_info->hugepage_info[i].hugepage_sz; + runtime_state->hugepage_info[i].hugepage_sz;uint64_t msl_sz = primary_msl->page_sz;if (msl_sz == cur_sz) { - hi = &platform_info->hugepage_info[i]; + hi = &runtime_state->hugepage_info[i];break ; } }
lib/eal/linux/eal_memory.c +29 -30
185 lines not on this page · raw message
lib/eal/windows/eal.c +12 -12
@@ -160,6 +160,18 @@ rte_eal_init(int argc, char **argv)char cpuset[RTE_CPU_AFFINITY_STR_LEN ];char thread_name[RTE_THREAD_NAME_SIZE ]; +/* +* platform_info is lazily initialized on first use, and that +* initialization can fail (CPU/NUMA/hugepage detection). Almost +* everything below depends on a valid platform_info, so confirm it +* is available before doing anything else. +*/ +if (eal_get_platform_info () ==NULL ) { +rte_eal_init_alert ("Cannot get platform information." ); + rte_errno =ENOTSUP ; +return -1 ; + } +/* clone argv to report out later in telemetry */ eal_save_args (argc, argv);
@@ -179,12 +191,6 @@ rte_eal_init(int argc, char **argv)eal_log_init (NULL ); -if (eal_create_cpu_map () <0 ) { -rte_eal_init_alert ("Cannot discover CPU and NUMA." ); -/* rte_errno is set */ - goto err_out; - } -/* verify if DPDK supported on architecture MMU */ if (!eal_mmu_supported ()) {rte_eal_init_alert ("Unsupported MMU type." );
@@ -192,12 +198,6 @@ rte_eal_init(int argc, char **argv) goto err_out; } -if (rte_eal_cpu_init () <0 ) { -rte_eal_init_alert ("Cannot detect lcores." ); - rte_errno =ENOTSUP ; - goto err_out; - } -if (eal_parse_args () <0 ) {rte_eal_init_alert ("Invalid command line arguments." ); rte_errno =EINVAL ;
lib/eal/windows/eal_hugepages.c +31 -4
@@ -62,11 +62,9 @@ hugepage_info_init(void)struct hugepage_info *hpi;unsigned int socket_id;int ret =0 ; -struct eal_platform_info *platform_info =eal_get_platform_info (); +struct eal_runtime_state *runtime_state =eal_get_runtime_state (); -/* Only one hugepage size available on Windows. */ - platform_info->num_hugepage_sizes =1 ; - hpi = &platform_info->hugepage_info[0 ]; + hpi = &runtime_state->hugepage_info[0 ]; hpi->hugepage_sz =GetLargePageMinimum ();if (hpi->hugepage_sz ==0 )
@@ -96,10 +94,39 @@ hugepage_info_init(void)/* No hugepage filesystem on Windows. */ hpi->lock_descriptor =-1 ;memset (hpi->hugedir,0 ,sizeof (hpi->hugedir)); + runtime_state->num_hugepage_sizes =1 ;return ret; } +int +eal_get_platform_hp_info (struct eal_platform_info *platform_info) +{ +size_t hp_sz; +unsigned int socket_id; + + hp_sz =GetLargePageMinimum (); +if (hp_sz ==0 ) +return -ENOTSUP ; + +for (socket_id =0 ; socket_id < platform_info->numa_node_count; socket_id++) { +ULONGLONG bytes; +unsigned int numa_node; + + numa_node =eal_socket_numa_node (socket_id); +if (GetNumaAvailableMemoryNodeEx (numa_node, &bytes)) { + platform_info->hugepage_sizes[0 ].max_pages[socket_id] = bytes / hp_sz; + platform_info->hugepage_sizes[0 ].total_pages += bytes / hp_sz; + } + } + + platform_info->num_hugepage_sizes =1 ; + platform_info->hugepage_sizes[0 ].size = hp_sz; + platform_info->hugepage_sizes[0 ].dir[0 ] ='\0' ;/* no hugetlbfs on Windows */ + +return 0 ; +} +int eal_hugepage_info_init (void ) {
lib/eal/windows/eal_memalloc.c +6 -5
@@ -315,6 +315,7 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs,struct alloc_walk_param wa;const struct hugepage_info *hi =NULL ;const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (user_cfg->legacy_mem) {
@@ -323,7 +324,7 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs, }for (i =0 ; i < platform_info->num_hugepage_sizes; i++) { -const struct hugepage_info *hpi = &platform_info->hugepage_info[i]; +const struct hugepage_info *hpi = &runtime_state->hugepage_info[i];if (page_sz == hpi->hugepage_sz) { hi = hpi;break ;
@@ -367,7 +368,7 @@ int eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs) { int seg, ret = 0; -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();/* dynamic free not supported in legacy mode */
@@ -390,12 +391,12 @@ eal_memalloc_free_seg_bulk(struct rte_memseg **ms, int n_segs)memset (&wa,0 ,sizeof (wa)); -for (i =0 ; i <RTE_DIM (platform_info->hugepage_info); i++) { - hi = &platform_info->hugepage_info[i]; +for (i =0 ; i <RTE_DIM (runtime_state->hugepage_info); i++) { + hi = &runtime_state->hugepage_info[i];if (cur->hugepage_sz == hi->hugepage_sz)break ; } -if (i ==RTE_DIM (platform_info->hugepage_info)) { +if (i ==RTE_DIM (runtime_state->hugepage_info)) {EAL_LOG (ERR ,"Can't find relevant hugepage_info entry" ); ret =-1 ;continue ;
lib/eal/windows/eal_windows.h +0 -8
@@ -29,14 +29,6 @@#define EAL_LOG_STUB () \ EAL_LOG(DEBUG, "Windows: %s() is a stub", __func__) -/** -* Create a map of processors and cores on the system. -* -* @return -* 0 on success, (-1) on failure and rte_errno is set. -*/ -int eal_create_cpu_map (void ); -/** * Get system NUMA node number for a socket ID. *
Signature · 1 line
2.53.0
PATCH v2 36/39 eal: remove duplicated scan of sysfs for hugepage details
In reply to Bruce RichardsonSince the platform_info struct does the hugepage scanning, we can reuse those details in the hugepage init functions rather than rescanning sysfs.
--- lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/freebsd/eal_hugepage_info.c | 29 ++------ lib/eal/linux/eal_hugepage_info.c | 103 ++++++++++------------------ lib/eal/windows/eal_hugepages.c | 26 ++----- 4 files changed, 51 insertions(+), 108 deletions(-)
lib/eal/common/eal_internal_cfg.h +1 -0
@@ -161,6 +161,7 @@ struct eal_cpu_info {struct hp_sizes {uint64_t size;/**< hugepage size in bytes */ char dir[PATH_MAX ];/**< dir where hugetlbfs is mounted for this size */ +char subdir[32 ];/**< sysfs subdir name for this size, e.g. "hugepages-2048kB" */ uint32_t total_pages;/**< total hugepages of this size across all NUMA nodes */ uint32_t max_pages[RTE_MAX_NUMA_NODES ];/**< maximum hugepages of this size available on each NUMA node */
lib/eal/freebsd/eal_hugepage_info.c +7 -22
@@ -87,9 +87,9 @@ eal_get_platform_hp_info(struct eal_platform_info *platform_info)int eal_hugepage_info_init (void ) { -size_t sysctl_size; -int num_buffers, fd, error; -int64_t buffer_size =0 ; +const struct eal_platform_info *platform_info =eal_get_platform_info (); +int num_buffers, fd; +int64_t buffer_size;struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* re-use the linux "internal config" structure for our memory data */
@@ -98,28 +98,13 @@ eal_hugepage_info_init(void)struct hugepage_info *tmp_hpi;unsigned int i; - sysctl_size =sizeof (num_buffers); - error =sysctlbyname ("hw.contigmem.num_buffers" , &num_buffers, - &sysctl_size,NULL ,0 ); - -if (error !=0 ) { -EAL_LOG (ERR ,"could not read sysctl hw.contigmem.num_buffers" ); +if (platform_info->num_hugepage_sizes ==0 ) { +EAL_LOG (ERR ,"could not read hugepage info from platform" );return -1 ; } - sysctl_size =sizeof (buffer_size); - error =sysctlbyname ("hw.contigmem.buffer_size" , &buffer_size, - &sysctl_size,NULL ,0 ); - -if (error !=0 ) { - error =sysctlbyname ("hw.contigmem.buffer_size_MB" , &buffer_size, - &sysctl_size,NULL ,0 ); - buffer_size *=1024 *1024 ;/* convert to bytes, harmless to multiple on error*/ - } -if (error !=0 ) { -EAL_LOG (ERR ,"could not read sysctl hw.contigmem.buffer_size" ); -return -1 ; - } + buffer_size = (int64_t )platform_info->hugepage_sizes[0 ].size; + num_buffers = (int )platform_info->hugepage_sizes[0 ].max_pages[0 ]; fd =open (CONTIGMEM_DEV ,O_RDWR );if (fd <0 ) {
lib/eal/linux/eal_hugepage_info.c +36 -67
198 lines not on this page · raw message
lib/eal/windows/eal_hugepages.c +7 -19
@@ -59,33 +59,21 @@ hugepage_claim_privilege(void)static int hugepage_info_init (void ) { +const struct eal_platform_info *platform_info =eal_get_platform_info ();struct hugepage_info *hpi;unsigned int socket_id;int ret =0 ;struct eal_runtime_state *runtime_state =eal_get_runtime_state (); - hpi = &runtime_state->hugepage_info[0 ]; - - hpi->hugepage_sz =GetLargePageMinimum (); -if (hpi->hugepage_sz ==0 ) +if (platform_info->num_hugepage_sizes ==0 )return -ENOTSUP ; -/* Assume all memory on each NUMA node available for hugepages, -* because Windows neither advertises additional limits, -* nor provides an API to query them. -*/ -for (socket_id =0 ; socket_id <rte_socket_count (); socket_id++) { -ULONGLONG bytes; -unsigned int numa_node; - - numa_node =eal_socket_numa_node (socket_id); -if (!GetNumaAvailableMemoryNodeEx (numa_node, &bytes)) { -RTE_LOG_WIN32_ERR ("GetNumaAvailableMemoryNodeEx(%u)" , - numa_node); -continue ; - } + hpi = &runtime_state->hugepage_info[0 ]; + hpi->hugepage_sz = platform_info->hugepage_sizes[0 ].size; - hpi->num_pages[socket_id] = bytes / hpi->hugepage_sz; +for (socket_id =0 ; socket_id <rte_socket_count (); socket_id++) { + hpi->num_pages[socket_id] = + platform_info->hugepage_sizes[0 ].max_pages[socket_id];EAL_LOG (DEBUG ,"Found %u hugepages of %zu bytes on socket %u" , hpi->num_pages[socket_id], hpi->hugepage_sz, socket_id);
Signature · 1 line
2.53.0
PATCH v2 37/39 eal: add utilities for working with user config struct
In reply to Bruce RichardsonSince the user-config struct has tailqs elements, string elements and variable length arrays it cannot be initialized via a simple "= {0}" and copy and cleanup requires looping through the various non-basic elements. Add functions below the struct definitions to handle these tasks correctly, adding a comment on the struct to remind any future editors to also adjust the functions if necessary.
--- lib/eal/common/eal_common_options.c | 12 +-- lib/eal/common/eal_internal_cfg.h | 152 ++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 11 deletions(-)
lib/eal/common/eal_common_options.c +1 -11
@@ -1911,17 +1911,7 @@ eal_parse_args(void)* false or NULL, which is the correct default (RTE_PROC_PRIMARY, * RTE_INTR_MODE_NONE, RTE_IOVA_DC, etc. are all defined as 0). */ - *user_cfg = (struct eal_user_cfg ){ - .devopt_list =TAILQ_HEAD_INITIALIZER (user_cfg->devopt_list), - .plugin_list =TAILQ_HEAD_INITIALIZER (user_cfg->plugin_list), - .trace_patterns =STAILQ_HEAD_INITIALIZER (user_cfg->trace_patterns), - .hugepage_file.unlink_existing = true, - .main_lcore =-1 , -#ifndef RTE_LIBEAL_USE_HPET - .no_hpet = true, -#endif - .max_simd_bitwidth.bitwidth =RTE_VECT_DEFAULT_SIMD_BITWIDTH , - }; + *user_cfg =EAL_USER_CFG_INITIALIZER (*user_cfg);bool remap_lcores = (args.remap_lcore_ids !=NULL );struct arg_list_elem *arg;
lib/eal/common/eal_internal_cfg.h +152 -0
176 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 38/39 eal: split EAL init into two stages
In reply to Bruce RichardsonSplit the rte_eal_init function into two parts, where the first part is handling the argument parsing and then calling the second part which does the actual subsystem initialization.
--- lib/eal/common/eal_common_options.c | 69 +++++++++-------------------- lib/eal/common/eal_options.h | 2 +- lib/eal/freebsd/eal.c | 56 +++++++++++++++++------ lib/eal/linux/eal.c | 54 +++++++++++++++++----- lib/eal/windows/eal.c | 55 +++++++++++++++++------ 5 files changed, 149 insertions(+), 87 deletions(-)
lib/eal/common/eal_common_options.c +21 -48
@@ -426,9 +426,8 @@ eal_clean_saved_args(void)#endif /* !RTE_EXEC_ENV_WINDOWS */ static int -eal_option_device_add (enum rte_devtype type,const char *arg) +eal_option_device_add (struct eal_user_cfg *user_cfg,enum rte_devtype type,const char *arg) { -struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct device_option *devopt;size_t arglen;int ret;
@@ -483,9 +482,8 @@ eal_get_hugefile_prefix(void) }static int -eal_plugin_path_add (const char *path) +eal_plugin_path_add (struct eal_user_cfg *user_cfg,const char *path) { -struct eal_user_cfg *user_cfg =eal_get_user_configuration ();struct eal_plugin_path *p; p =malloc (sizeof (*p));
@@ -1021,11 +1019,10 @@ rte_eal_parse_coremask(const char *coremask, rte_cpuset_t *cpuset, bool limit_ra/* Changes the lcore id of the main thread */ static int -eal_parse_main_lcore (const char *arg) +eal_parse_main_lcore (struct eal_user_cfg *user_cfg,const char *arg) {char *parsing_end;long main_lcore; -struct eal_user_cfg *user_cfg =eal_get_user_configuration (); errno =0 ; main_lcore =strtol (arg, &parsing_end,0 );
@@ -1459,10 +1456,9 @@ eal_parse_proc_type(const char *arg) }static int -eal_parse_iova_mode (const char *name) +eal_parse_iova_mode (struct eal_user_cfg *user_cfg,const char *name) {int mode; -struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (name ==NULL )return -1 ;
@@ -1506,11 +1502,10 @@ eal_parse_simd_bitwidth(const char *arg) }static int -eal_parse_base_virtaddr (const char *arg) +eal_parse_base_virtaddr (struct eal_user_cfg *user_cfg,const char *arg) {char *end;uint64_t addr; -struct eal_user_cfg *user_cfg =eal_get_user_configuration (); errno =0 ; addr =strtoull (arg, &end,16 );
@@ -1823,9 +1818,8 @@ eal_parse_pagesz_mem(char *strval, struct eal_user_cfg *user_cfg) }static int -eal_parse_vfio_intr (const char *mode) +eal_parse_vfio_intr (struct eal_user_cfg *user_cfg,const char *mode) { -struct eal_user_cfg *user_cfg =eal_get_user_configuration (); static struct { const char *name; enum rte_intr_mode value;
@@ -1845,9 +1839,8 @@ eal_parse_vfio_intr(const char *mode) }static int -eal_parse_vfio_vf_token (const char *vf_token) +eal_parse_vfio_vf_token (struct eal_user_cfg *user_cfg,const char *vf_token) { -struct eal_user_cfg *user_cfg =eal_get_user_configuration ();rte_uuid_t uuid;if (!rte_uuid_parse (vf_token, uuid)) {
@@ -1859,13 +1852,13 @@ eal_parse_vfio_vf_token(const char *vf_token) }static int -eal_parse_huge_worker_stack (const char *arg) +eal_parse_huge_worker_stack (struct eal_user_cfg *user_cfg,const char *arg) {#ifdef RTE_EXEC_ENV_WINDOWS EAL_LOG (WARNING ,"Cannot set worker stack size on Windows, parameter ignored" ); +RTE_SET_USED (user_cfg);RTE_SET_USED (arg);#else -struct eal_user_cfg *user_cfg =eal_get_user_configuration ();if (arg ==NULL || arg[0 ] =='\0' ) {pthread_attr_t attr;
@@ -1902,10 +1895,8 @@ eal_parse_huge_worker_stack(const char *arg)/* Parse the arguments given in the command line of the application */ int -eal_parse_args (void ) +eal_parse_args (struct eal_user_cfg *user_cfg) { -struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -/* * Initialise user_cfg to defaults. Fields not listed here are zero, * false or NULL, which is the correct default (RTE_PROC_PRIMARY,
@@ -1939,17 +1930,17 @@ eal_parse_args(void)/* device -a/-b/-vdev options*/ TAILQ_FOREACH(arg, &args.allow, next) -if (eal_option_device_add (RTE_DEVTYPE_ALLOWED , arg->arg) <0 ) +if (eal_option_device_add (user_cfg,RTE_DEVTYPE_ALLOWED , arg->arg) <0 )return -1 ; TAILQ_FOREACH(arg, &args.block, next) -if (eal_option_device_add (RTE_DEVTYPE_BLOCKED , arg->arg) <0 ) +if (eal_option_device_add (user_cfg,RTE_DEVTYPE_BLOCKED , arg->arg) <0 )return -1 ; TAILQ_FOREACH(arg, &args.vdev, next) -if (eal_option_device_add (RTE_DEVTYPE_VIRTUAL , arg->arg) <0 ) +if (eal_option_device_add (user_cfg,RTE_DEVTYPE_VIRTUAL , arg->arg) <0 )return -1 ;/* driver loading options */ TAILQ_FOREACH(arg, &args.driver_path, next) -if (eal_plugin_path_add (arg->arg) <0 ) +if (eal_plugin_path_add (user_cfg, arg->arg) <0 )return -1 ;if (remap_lcores && args.remap_lcore_ids != (void *)1 ) {
@@ -2039,7 +2030,7 @@ eal_parse_args(void)return -1 ; } } -if (args.main_lcore !=NULL &&eal_parse_main_lcore (args.main_lcore) <0 ) +if (args.main_lcore !=NULL &&eal_parse_main_lcore (user_cfg, args.main_lcore) <0 )return -1 ;/* memory options */
@@ -2242,13 +2233,13 @@ eal_parse_args(void)/* other misc settings */ if (args.iova_mode !=NULL ) { -if (eal_parse_iova_mode (args.iova_mode) <0 ) { +if (eal_parse_iova_mode (user_cfg, args.iova_mode) <0 ) {EAL_LOG (ERR ,"invalid iova mode parameter '%s'" , args.iova_mode);return -1 ; } };if (args.base_virtaddr !=NULL ) { -if (eal_parse_base_virtaddr (args.base_virtaddr) <0 ) { +if (eal_parse_base_virtaddr (user_cfg, args.base_virtaddr) <0 ) {EAL_LOG (ERR ,"invalid base virtaddr '%s'" , args.base_virtaddr);return -1 ; }
@@ -2261,13 +2252,13 @@ eal_parse_args(void) } }if (args.vfio_intr !=NULL ) { -if (eal_parse_vfio_intr (args.vfio_intr) <0 ) { +if (eal_parse_vfio_intr (user_cfg, args.vfio_intr) <0 ) {EAL_LOG (ERR ,"invalid vfio interrupt parameter: '%s'" , args.vfio_intr);return -1 ; } }if (args.vfio_vf_token !=NULL ) { -if (eal_parse_vfio_vf_token (args.vfio_vf_token) <0 ) { +if (eal_parse_vfio_vf_token (user_cfg, args.vfio_vf_token) <0 ) {EAL_LOG (ERR ,"invalid vfio vf token parameter: '%s'" , args.vfio_vf_token);return -1 ; }
@@ -2276,7 +2267,7 @@ eal_parse_args(void)if (args.huge_worker_stack !=NULL ) {if (args.huge_worker_stack == (void *)1 ) args.huge_worker_stack =NULL ; -if (eal_parse_huge_worker_stack (args.huge_worker_stack) <0 ) { +if (eal_parse_huge_worker_stack (user_cfg, args.huge_worker_stack) <0 ) {EAL_LOG (ERR ,"invalid huge worker stack parameter" );return -1 ; }
@@ -2304,25 +2295,7 @@ eal_parse_args(void)int eal_cleanup_config (void ) { -struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -struct eal_trace_arg *ta; - -/* free trace patterns list */ -while (!STAILQ_EMPTY (&user_cfg->trace_patterns)) { - ta =STAILQ_FIRST (&user_cfg->trace_patterns); -STAILQ_REMOVE_HEAD (&user_cfg->trace_patterns, next); -free (ta->val); -free (ta); - } -free (user_cfg->trace_dir); -free (user_cfg->hugefile_prefix); -free (user_cfg->hugepage_dir); -free (user_cfg->user_mbuf_pool_ops_name); -for (unsigned int i =0 ; i <RTE_MAX_LCORE ; i++) { -free (user_cfg->lcore_cpusets[i]); - user_cfg->lcore_cpusets[i] =NULL ; - } - +eal_user_cfg_cleanup (eal_get_user_configuration ());return 0 ; }
lib/eal/common/eal_options.h +1 -1
@@ -11,7 +11,7 @@ struct rte_tel_data;struct eal_user_cfg ;int eal_parse_log_options (void ); -int eal_parse_args (void ); +int eal_parse_args (struct eal_user_cfg *user_cfg);int eal_option_device_parse (void );int eal_cleanup_config (void );int eal_plugins_init (void );
lib/eal/freebsd/eal.c +43 -13
95 lines not on this page · raw message
lib/eal/linux/eal.c +42 -12
94 lines not on this page · raw message
lib/eal/windows/eal.c +42 -13
92 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 39/39 eal: provide hooks for init with externally supplied config
In reply to Bruce RichardsonNow that we have a split EAL init, where most work is done on a configured eal_user_cfg structure, add in hooks to allow other libraries to init EAL by passing in that structure pre-configured.
We export an internal function that wraps the second stage init, while taking care of the run_once flag, before calling the main initialization function with a prepopulated config.
Also, export internally the platform info function so that any callers of this new function can do any necessary validation of parameters as part of their setup.
--- lib/eal/common/eal_common_config.c | 5 ++- lib/eal/common/eal_common_lcore.c | 6 +-- lib/eal/common/eal_common_thread.c | 2 +- lib/eal/common/eal_internal_cfg.h | 8 +++- lib/eal/freebsd/eal.c | 57 ++++++++++++++++++++++++--- lib/eal/freebsd/eal_hugepage_info.c | 2 +- lib/eal/freebsd/eal_memory.c | 6 +-- lib/eal/linux/eal.c | 55 ++++++++++++++++++++++++-- lib/eal/linux/eal_hugepage_info.c | 2 +- lib/eal/windows/eal.c | 60 ++++++++++++++++++++++++++++- lib/eal/windows/eal_hugepages.c | 2 +- lib/eal/windows/eal_memalloc.c | 2 +- 12 files changed, 183 insertions(+), 24 deletions(-)
lib/eal/common/eal_common_config.c +3 -2
@@ -68,8 +68,9 @@ eal_get_user_configuration(void) }/* Return a pointer to the platform state structure */ +RTE_EXPORT_INTERNAL_SYMBOL (rte_eal_get_platform_info) const struct eal_platform_info * -eal_get_platform_info (void ) +rte_eal_get_platform_info (void ) {/* platform-discovered and runtime EAL state */ static struct eal_platform_info eal_platform_info;
@@ -305,7 +306,7 @@ inteal_apply_hugepage_mem_sz_limits (void) {const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();unsigned int i;
lib/eal/common/eal_common_lcore.c +3 -3
@@ -54,7 +54,7 @@ RTE_EXPORT_SYMBOL(rte_lcore_to_cpu_id)int rte_lcore_to_cpu_id (int lcore_id) {const struct eal_runtime_state *runtime_state =eal_get_runtime_state (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();unsigned int cpu;if (unlikely (lcore_id >=RTE_MAX_LCORE ))
@@ -267,7 +267,7 @@ RTE_EXPORT_SYMBOL(rte_socket_count)unsigned int rte_socket_count (void ) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();return platform_info->numa_node_count; }
@@ -275,7 +275,7 @@ RTE_EXPORT_SYMBOL(rte_socket_id_by_idx)int rte_socket_id_by_idx (unsigned int idx) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();if (idx >= platform_info->numa_node_count) { rte_errno =EINVAL ;return -1 ;
lib/eal/common/eal_common_thread.c +1 -1
@@ -40,7 +40,7 @@ unsigned rte_socket_id(void)int eal_cpuset_socket_id (const rte_cpuset_t *cpusetp) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();int socket_id =SOCKET_ID_ANY ;if (cpusetp ==NULL )
lib/eal/common/eal_internal_cfg.h +7 -1
@@ -25,6 +25,7 @@#include <rte_bitset.h> #include <rte_stdatomic.h> #include "eal_thread.h" +#include "rte_compat.h" /* Forward declaration — full definition is in eal_memcfg.h */ struct rte_mem_config ;
@@ -384,8 +385,13 @@ struct eal_runtime_state {struct eal_solib_list loaded_plugins;/**< all plugins loaded by eal_plugins_init() */ }; -const struct eal_platform_info *eal_get_platform_info (void ); +__rte_internal +const struct eal_platform_info *rte_eal_get_platform_info(void);struct eal_user_cfg *eal_get_user_configuration (void );struct eal_runtime_state *eal_get_runtime_state (void ); +__rte_internal +int +rte_eal_runtime_init (const char *progname,const struct eal_user_cfg *user_provided_cfg); +#endif /* EAL_INTERNAL_CFG_H */
lib/eal/freebsd/eal.c +52 -5
99 lines not on this page · raw message
lib/eal/freebsd/eal_hugepage_info.c +1 -1
@@ -87,7 +87,7 @@ eal_get_platform_hp_info(struct eal_platform_info *platform_info)int eal_hugepage_info_init (void ) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();int num_buffers, fd;int64_t buffer_size;struct eal_runtime_state *runtime_state =eal_get_runtime_state ();
lib/eal/freebsd/eal_memory.c +3 -3
@@ -72,7 +72,7 @@ rte_eal_hugepage_init(void)void *addr;unsigned int i, j, seg_idx =0 ;const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* get pointer to global configuration */
@@ -285,7 +285,7 @@ attach_segment(const struct rte_memseg_list *msl, const struct rte_memseg *ms,int rte_eal_hugepage_attach (void ) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();struct hugepage_info *hpi;int fd_hugepage =-1 ;
@@ -354,7 +354,7 @@ memseg_primary_init(void)int hpi_idx, msl_idx =0 ;struct rte_memseg_list *msl;const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct eal_runtime_state *runtime_state =eal_get_runtime_state ();/* no-huge does not need this at all */
lib/eal/linux/eal.c +51 -4
91 lines not on this page · raw message
lib/eal/linux/eal_hugepage_info.c +1 -1
@@ -518,7 +518,7 @@ hugepage_info_init(void)unsigned int reusable_pages;struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration (); -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();int failed =0 ;/* platform_info->hugepage_sizes[] is already sorted largest to smallest */
lib/eal/windows/eal.c +59 -1
95 lines not on this page · raw message
lib/eal/windows/eal_hugepages.c +1 -1
@@ -59,7 +59,7 @@ hugepage_claim_privilege(void)static int hugepage_info_init (void ) { -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();struct hugepage_info *hpi;unsigned int socket_id;int ret =0 ;
lib/eal/windows/eal_memalloc.c +1 -1
@@ -314,7 +314,7 @@ eal_memalloc_alloc_seg_bulk(struct rte_memseg **ms, int n_segs,int ret =-1 ;struct alloc_walk_param wa;const struct hugepage_info *hi =NULL ; -const struct eal_platform_info *platform_info =eal_get_platform_info (); +const struct eal_platform_info *platform_info =rte_eal_get_platform_info ();const struct eal_runtime_state *runtime_state =eal_get_runtime_state ();const struct eal_user_cfg *user_cfg =eal_get_user_configuration ();
Signature · 1 line
2.53.0