From: Anatoly Burakov Date: Fri, 20 Jun 2014 15:42:17 +0000 (+0100) Subject: eal: use --base-virtaddr for mapping rte_config as well X-Git-Tag: spdx-start~10489 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=fa02c869f13f31bfd4af6f8ac02ce6598f8d512b;p=dpdk.git 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 --- 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){