[PATCH v2 4/7] memseg: init once
okaya at kernel.org
okaya at kernel.org
Tue Aug 15 05:13:04 CEST 2023
From: Sinan Kaya <okaya at kernel.org>
Initialize memory segments just once and bail out if called
multiple times.
Signed-off-by: Sinan Kaya <okaya at kernel.org>
---
lib/eal/linux/eal_memory.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c
index 60fc8cc6ca..b998b366d2 100644
--- a/lib/eal/linux/eal_memory.c
+++ b/lib/eal/linux/eal_memory.c
@@ -57,6 +57,7 @@
*/
static int phys_addrs_available = -1;
+static bool memseg_initialized;
#define RANDOMIZE_VA_SPACE_FILE "/proc/sys/kernel/randomize_va_space"
@@ -1902,6 +1903,10 @@ rte_eal_memseg_init(void)
{
/* increase rlimit to maximum */
struct rlimit lim;
+ int ret;
+
+ if (memseg_initialized)
+ return 0;
#ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES
const struct internal_config *internal_conf =
@@ -1930,11 +1935,16 @@ rte_eal_memseg_init(void)
}
#endif
- return rte_eal_process_type() == RTE_PROC_PRIMARY ?
+ ret = rte_eal_process_type() == RTE_PROC_PRIMARY ?
#ifndef RTE_ARCH_64
memseg_primary_init_32() :
#else
memseg_primary_init() :
#endif
memseg_secondary_init();
+
+ if (!ret)
+ memseg_initialized = true;
+
+ return ret;
}
--
2.25.1
More information about the dev
mailing list