From f15addb79ebc4f192c4025aab1729bbd8fd7bc7b Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Fri, 13 Jun 2014 15:52:50 +0100 Subject: [PATCH] mem: make --no-huge use mmap instead of malloc This makes it possible to run DPDK without hugepage memory when VFIO is used, as VFIO uses virtual addresses to set up DMA mappings. Technically, malloc is just fine, but we want to guarantee that memory will be page-aligned, so using mmap to be safe. Signed-off-by: Anatoly Burakov Acked-by: Thomas Monjalon --- lib/librte_eal/linuxapp/eal/eal_memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index d9cfb0967b..ae43f9eadb 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1031,7 +1031,13 @@ rte_eal_hugepage_init(void) /* hugetlbfs can be disabled */ if (internal_config.no_hugetlbfs) { - addr = malloc(internal_config.memory); + addr = mmap(NULL, internal_config.memory, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); + if (addr == MAP_FAILED) { + RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__, + strerror(errno)); + return -1; + } mcfg->memseg[0].phys_addr = (phys_addr_t)(uintptr_t)addr; mcfg->memseg[0].addr = addr; mcfg->memseg[0].len = internal_config.memory; -- 2.20.1