From: Chao Zhu Date: Thu, 6 Apr 2017 10:06:09 +0000 (+0530) Subject: eal/ppc: fix mmap for memory initialization X-Git-Tag: spdx-start~3480 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=284ae3e9ff9a;p=dpdk.git eal/ppc: fix mmap for memory initialization On IBM POWER platform, when mapping /dev/zero file to hugepage memory space, mmap will not respect the requested address hint. This will cause the memory initialization for the second process fails. This patch adds the required mmap flags to make it work. Beside this, users need to set the nr_overcommit_hugepages to expand the VA range. When doing the initialization, users need to set both nr_hugepages and nr_overcommit_hugepages to the same value, like 64, 128, etc. Signed-off-by: Chao Zhu Acked-by: Sergio Gonzalez Monroy Acked-by: John McNamara --- diff --git a/doc/guides/linux_gsg/sys_reqs.rst b/doc/guides/linux_gsg/sys_reqs.rst index 61222c699b..3a28c9e517 100644 --- a/doc/guides/linux_gsg/sys_reqs.rst +++ b/doc/guides/linux_gsg/sys_reqs.rst @@ -200,6 +200,12 @@ On a NUMA machine, pages should be allocated explicitly on separate nodes:: For 1G pages, it is not possible to reserve the hugepage memory after the system has booted. + On IBM POWER system, the nr_overcommit_hugepages should be set to the same value as nr_hugepages. + For example, if the required page number is 128, the following commands are used:: + + echo 128 > /sys/kernel/mm/hugepages/hugepages-16384kB/nr_hugepages + echo 128 > /sys/kernel/mm/hugepages/hugepages-16384kB/nr_overcommit_hugepages + Using Hugepages with the DPDK ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 90cc3224be..618a09b429 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -331,7 +331,13 @@ get_virtual_area(size_t *size, size_t hugepage_sz) } do { addr = mmap(addr, - (*size) + hugepage_sz, PROT_READ, MAP_PRIVATE, fd, 0); + (*size) + hugepage_sz, PROT_READ, +#ifdef RTE_ARCH_PPC_64 + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, +#else + MAP_PRIVATE, +#endif + fd, 0); if (addr == MAP_FAILED) *size -= hugepage_sz; } while (addr == MAP_FAILED && *size > 0); @@ -1359,7 +1365,13 @@ rte_eal_hugepage_attach(void) * use mmap to get identical addresses as the primary process. */ base_addr = mmap(mcfg->memseg[s].addr, mcfg->memseg[s].len, - PROT_READ, MAP_PRIVATE, fd_zero, 0); + PROT_READ, +#ifdef RTE_ARCH_PPC_64 + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, +#else + MAP_PRIVATE, +#endif + fd_zero, 0); if (base_addr == MAP_FAILED || base_addr != mcfg->memseg[s].addr) { max_seg = s;