eal: use --base-virtaddr for mapping rte_config as well
authorAnatoly Burakov <anatoly.burakov@intel.com>
Fri, 20 Jun 2014 15:42:17 +0000 (16:42 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 22 Jul 2014 15:48:49 +0000 (17:48 +0200)
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 <anatoly.burakov@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
lib/librte_eal/linuxapp/eal/eal.c

index 5d2adb9..ad43914 100644 (file)
@@ -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){