From: Sinan Kaya <ok...@kernel.org> Initialize heap area just once.
Signed-off-by: Sinan Kaya <ok...@kernel.org> --- lib/eal/common/eal_common_memory.c | 6 ++++++ lib/eal/common/malloc_heap.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c index d9433db623..1ba2007f76 100644 --- a/lib/eal/common/eal_common_memory.c +++ b/lib/eal/common/eal_common_memory.c @@ -1083,6 +1083,10 @@ rte_eal_memory_init(void) const struct internal_config *internal_conf = eal_get_internal_configuration(); int retval; + static bool run_once; + + if (run_once) + return 0; RTE_LOG(DEBUG, EAL, "Setting up physically contiguous memory...\n"); @@ -1101,6 +1105,8 @@ rte_eal_memory_init(void) if (internal_conf->no_shconf == 0 && rte_eal_memdevice_init() < 0) goto fail; + run_once = true; + return 0; fail: return -1; diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 6b6cf9174c..5f01735520 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -31,6 +31,7 @@ #define CONST_MAX(a, b) (a > b ? a : b) /* RTE_MAX is not a constant */ #define EXTERNAL_HEAP_MIN_SOCKET_ID (CONST_MAX((1 << 8), RTE_MAX_NUMA_NODES)) + static unsigned check_hugepage_sz(unsigned flags, uint64_t hugepage_sz) { @@ -1409,6 +1410,10 @@ rte_eal_malloc_heap_init(void) unsigned int i; const struct internal_config *internal_conf = eal_get_internal_configuration(); + static bool run_once; + + if (run_once) + return 0; if (internal_conf->match_allocations) RTE_LOG(DEBUG, EAL, "Hugepages will be freed exactly as allocated.\n"); @@ -1435,6 +1440,8 @@ rte_eal_malloc_heap_init(void) return -1; } + run_once = true; + return 0; } -- 2.25.1