|
|
95b418 |
From 284ae3e9ff9a92575c28c858efd2c85c8de6d440 Mon Sep 17 00:00:00 2001
|
|
|
95b418 |
From: Chao Zhu <chaozhu@linux.vnet.ibm.com>
|
|
|
95b418 |
Date: Thu, 6 Apr 2017 15:36:09 +0530
|
|
|
95b418 |
Subject: [PATCH] eal/ppc: fix mmap for memory initialization
|
|
|
95b418 |
|
|
|
95b418 |
On IBM POWER platform, when mapping /dev/zero file to hugepage memory
|
|
|
95b418 |
space, mmap will not respect the requested address hint. This will cause
|
|
|
95b418 |
the memory initialization for the second process fails. This patch adds
|
|
|
95b418 |
the required mmap flags to make it work. Beside this, users need to set
|
|
|
95b418 |
the nr_overcommit_hugepages to expand the VA range. When
|
|
|
95b418 |
doing the initialization, users need to set both nr_hugepages and
|
|
|
95b418 |
nr_overcommit_hugepages to the same value, like 64, 128, etc.
|
|
|
95b418 |
|
|
|
95b418 |
Signed-off-by: Chao Zhu <chaozhu@linux.vnet.ibm.com>
|
|
|
95b418 |
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
|
|
|
95b418 |
Acked-by: John McNamara <john.mcnamara@intel.com>
|
|
|
95b418 |
---
|
|
|
95b418 |
doc/guides/linux_gsg/sys_reqs.rst | 6 ++++++
|
|
|
95b418 |
lib/librte_eal/linuxapp/eal/eal_memory.c | 16 ++++++++++++++--
|
|
|
95b418 |
2 files changed, 20 insertions(+), 2 deletions(-)
|
|
|
95b418 |
|
|
|
95b418 |
diff --git a/doc/guides/linux_gsg/sys_reqs.rst b/doc/guides/linux_gsg/sys_reqs.rst
|
|
|
95b418 |
index 61222c699b7d..3a28c9e51775 100644
|
|
|
95b418 |
--- a/doc/guides/linux_gsg/sys_reqs.rst
|
|
|
95b418 |
+++ b/doc/guides/linux_gsg/sys_reqs.rst
|
|
|
95b418 |
@@ -200,6 +200,12 @@ On a NUMA machine, pages should be allocated explicitly on separate nodes::
|
|
|
95b418 |
|
|
|
95b418 |
For 1G pages, it is not possible to reserve the hugepage memory after the system has booted.
|
|
|
95b418 |
|
|
|
95b418 |
+ On IBM POWER system, the nr_overcommit_hugepages should be set to the same value as nr_hugepages.
|
|
|
95b418 |
+ For example, if the required page number is 128, the following commands are used::
|
|
|
95b418 |
+
|
|
|
95b418 |
+ echo 128 > /sys/kernel/mm/hugepages/hugepages-16384kB/nr_hugepages
|
|
|
95b418 |
+ echo 128 > /sys/kernel/mm/hugepages/hugepages-16384kB/nr_overcommit_hugepages
|
|
|
95b418 |
+
|
|
|
95b418 |
Using Hugepages with the DPDK
|
|
|
95b418 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
95b418 |
|
|
|
95b418 |
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
|
|
|
95b418 |
index 90cc3224be85..618a09b429bc 100644
|
|
|
95b418 |
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
|
|
|
95b418 |
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
|
|
|
95b418 |
@@ -331,7 +331,13 @@ get_virtual_area(size_t *size, size_t hugepage_sz)
|
|
|
95b418 |
}
|
|
|
95b418 |
do {
|
|
|
95b418 |
addr = mmap(addr,
|
|
|
95b418 |
- (*size) + hugepage_sz, PROT_READ, MAP_PRIVATE, fd, 0);
|
|
|
95b418 |
+ (*size) + hugepage_sz, PROT_READ,
|
|
|
95b418 |
+#ifdef RTE_ARCH_PPC_64
|
|
|
95b418 |
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
|
|
|
95b418 |
+#else
|
|
|
95b418 |
+ MAP_PRIVATE,
|
|
|
95b418 |
+#endif
|
|
|
95b418 |
+ fd, 0);
|
|
|
95b418 |
if (addr == MAP_FAILED)
|
|
|
95b418 |
*size -= hugepage_sz;
|
|
|
95b418 |
} while (addr == MAP_FAILED && *size > 0);
|
|
|
95b418 |
@@ -1359,7 +1365,13 @@ rte_eal_hugepage_attach(void)
|
|
|
95b418 |
* use mmap to get identical addresses as the primary process.
|
|
|
95b418 |
*/
|
|
|
95b418 |
base_addr = mmap(mcfg->memseg[s].addr, mcfg->memseg[s].len,
|
|
|
95b418 |
- PROT_READ, MAP_PRIVATE, fd_zero, 0);
|
|
|
95b418 |
+ PROT_READ,
|
|
|
95b418 |
+#ifdef RTE_ARCH_PPC_64
|
|
|
95b418 |
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
|
|
|
95b418 |
+#else
|
|
|
95b418 |
+ MAP_PRIVATE,
|
|
|
95b418 |
+#endif
|
|
|
95b418 |
+ fd_zero, 0);
|
|
|
95b418 |
if (base_addr == MAP_FAILED ||
|
|
|
95b418 |
base_addr != mcfg->memseg[s].addr) {
|
|
|
95b418 |
max_seg = s;
|
|
|
95b418 |
--
|
|
|
95b418 |
2.9.4
|
|
|
95b418 |
|