From fa02c869f13f31bfd4af6f8ac02ce6598f8d512b Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Fri, 20 Jun 2014 16:42:17 +0100 Subject: [PATCH] eal: use --base-virtaddr for mapping rte_config as well Use --base-virtaddr to set the address of rte_config file along with start address of the hugepages. Since the user would likely expect the hugepages to be starting at the specified address, the specified address will likely be rounded to either 2M or 1G. So, in order to not waste space, we subtract the length of the config (and align it on page boundary) from the base virtual address and map the config just before the hugepages. Signed-off-by: Anatoly Burakov Acked-by: Konstantin Ananyev --- lib/librte_eal/linuxapp/eal/eal.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 5d2adb9b31..ad4391404d 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -213,6 +213,14 @@ rte_eal_config_create(void) if (internal_config.no_shconf) return; + /* map the config before hugepage address so that we don't waste a page */ + if (internal_config.base_virtaddr != 0) + rte_mem_cfg_addr = (void *) + RTE_ALIGN_FLOOR(internal_config.base_virtaddr - + sizeof(struct rte_mem_config), sysconf(_SC_PAGE_SIZE)); + else + rte_mem_cfg_addr = NULL; + if (mem_cfg_fd < 0){ mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660); if (mem_cfg_fd < 0) @@ -232,7 +240,7 @@ rte_eal_config_create(void) "process running?\n", pathname); } - rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config), + rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config), PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0); if (rte_mem_cfg_addr == MAP_FAILED){ -- 2.20.1