[v1,5/7] eal_memory: skip initialization
Checks
Commit Message
From: Sinan Kaya <okaya@kernel.org>
Initialize heap area just once.
Signed-off-by: Sinan Kaya <okaya@kernel.org>
---
lib/eal/common/eal_common_memory.c | 5 +++++
lib/eal/common/malloc_heap.c | 6 ++++++
2 files changed, 11 insertions(+)
@@ -1084,10 +1084,14 @@ rte_eal_memory_init(void)
int retval;
RTE_LOG(DEBUG, EAL, "Setting up physically contiguous memory...\n");
+ static int initialized = 0;
if (!mcfg)
return -1;
+ if (initialized)
+ return 0;
+
/* lock mem hotplug here, to prevent races while we init */
rte_mcfg_mem_read_lock();
@@ -1106,6 +1110,7 @@ rte_eal_memory_init(void)
if (internal_conf->no_shconf == 0 && rte_eal_memdevice_init() < 0)
goto fail;
+ initialized = true;
return 0;
fail:
rte_mcfg_mem_read_unlock();
@@ -1405,6 +1405,10 @@ rte_eal_malloc_heap_init(void)
unsigned int i;
const struct internal_config *internal_conf =
eal_get_internal_configuration();
+ static int initialized = 0;
+
+ if (initialized)
+ return 0;
if (internal_conf->match_allocations)
RTE_LOG(DEBUG, EAL, "Hugepages will be freed exactly as allocated.\n");
@@ -1443,6 +1447,8 @@ rte_eal_malloc_heap_init(void)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
+ initialized = true;
+
/* add all IOVA-contiguous areas to the heap */
return rte_memseg_contig_walk(malloc_add_seg, NULL);
}