[Zesty][PATCH 4/6] mm/hugetlb: Allow arch to override and call the weak function

Victor Aoqui victora at linux.vnet.ibm.com
Tue Oct 17 10:52:51 UTC 2017

From: "Aneesh Kumar K.V" <aneesh.kumar at linux.vnet.ibm.com>

BugLink: http://bugs.launchpad.net/bugs/1724120

When running in guest mode ppc64 supports a different mechanism for hugetlb
allocation/reservation. The LPAR management application called HMC can
be used to reserve a set of hugepages and we pass the details of
reserved pages via device tree to the guest. (more details in
htab_dt_scan_hugepage_blocks()) . We do the memblock_reserve of the range
and later in the boot sequence, we add the reserved range to huge_boot_pages.

But to enable 16G hugetlb on baremetal config (when we are not running as guest)
we want to do memblock reservation during boot. Generic code already does this

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
(cherry picked from commit e24a1307ba1f99fc62a0bd61d5e87fcfb6d5503d)
Signed-off-by: Victor Aoqui <victora at linux.vnet.ibm.com>
 include/linux/hugetlb.h | 1 +
 mm/hugetlb.c            | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 48c76d612d40..09f97f69ace6 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -336,6 +336,7 @@ int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
 			pgoff_t idx);
 /* arch callback */
+int __init __alloc_bootmem_huge_page(struct hstate *h);
 int __init alloc_bootmem_huge_page(struct hstate *h);
 void __init hugetlb_bad_size(void);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 8c272f350970..b2a7e6c369ba 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2100,7 +2100,9 @@ struct page *alloc_huge_page_noerr(struct vm_area_struct *vma,
 	return page;
-int __weak alloc_bootmem_huge_page(struct hstate *h)
+int alloc_bootmem_huge_page(struct hstate *h)
+	__attribute__ ((weak, alias("__alloc_bootmem_huge_page")));
+int __alloc_bootmem_huge_page(struct hstate *h)
 	struct huge_bootmem_page *m;
 	int nr_nodes, node;

More information about the kernel-team mailing list