mm/hugetlb: Allow arch to override and call the weak function
Subsystems (3)
PATCH v3 1/3 mm/hugetlb: Allow arch to override and call the weak function
For ppc64, we want to call this function when we are not running as guest. Also, if we failed to allocate hugepages, let the user know.
--- include/linux/hugetlb.h | 1 + mm/hugetlb.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
include/linux/hugetlb.h +1 -0
@@ -358,6 +358,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 );
mm/hugetlb.c +4 -1
@@ -2083,7 +2083,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;
@@ -2104,6 +2106,7 @@ int __weak alloc_bootmem_huge_page(struct hstate *h) goto found; } } +pr_info ("Failed to allocate hugepage of size %ld\n" ,huge_page_size (h));return 0 ; found:
Signature · 7 lines
2.13.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 2/3 powerpc/mm/hugetlb: Add support for reserving gigantic huge pages via kernel command line
With commit aa888a74977a8 ("hugetlb: support larger than MAX_ORDER") we added support for allocating gigantic hugepages via kernel command line. Switch ppc64 arch specific code to use that.
W.r.t FSL support, we now limit our allocation range using BOOTMEM_ALLOC_ACCESSIBLE.
We use the kernel command line to do reservation of hugetlb pages on powernv platforms. On pseries hash mmu mode the supported gigantic huge page size is 16GB and that can only be allocated with hypervisor assist. For pseries the command line option doesn't do the allocation. Instead pseries does gigantic hugepage allocation based on hypervisor hint that is specified via "ibm,expected#pages" property of the memory node.
--- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 2 +- arch/powerpc/include/asm/hugetlb.h | 14 -- arch/powerpc/kernel/setup-common.c | 7 - arch/powerpc/mm/hash_utils_64.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 177 +++----------------------- arch/powerpc/mm/init_32.c | 2 - 6 files changed, 22 insertions(+), 182 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu-hash.h +1 -1
@@ -468,7 +468,7 @@ extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend, int psize, int ssize);int htab_remove_mapping (unsigned long vstart,unsigned long vend,int psize,int ssize); -extern void add_gpage (u64 addr,u64 page_size,unsigned long number_of_pages); +extern void pseries_add_gpage (u64 addr,u64 page_size,unsigned long number_of_pages);extern void demote_segment_4k (struct mm_struct *mm,unsigned long addr);#ifdef CONFIG_PPC_PSERIES
arch/powerpc/include/asm/hugetlb.h +0 -14
@@ -218,18 +218,4 @@ static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr, }#endif /* CONFIG_HUGETLB_PAGE */ -/* -* FSL Book3E platforms require special gpage handling - the gpages -* are reserved early in the boot process by memblock instead of via -* the .dts as on IBM platforms. -*/ -#if defined(CONFIG_HUGETLB_PAGE ) && (defined(CONFIG_PPC_FSL_BOOK3E ) || \ - defined(CONFIG_PPC_8xx)) -extern void __init reserve_hugetlb_gpages (void ); -#else -static inline void reserve_hugetlb_gpages (void ) -{ -} -#endif -#endif /* _ASM_POWERPC_HUGETLB_H */
arch/powerpc/kernel/setup-common.c +0 -7
@@ -916,13 +916,6 @@ void __init setup_arch(char **cmdline_p)/* Reserve large chunks of memory for use by CMA for KVM. */ kvm_cma_reserve (); -/* -* Reserve any gigantic pages requested on the command line. -* memblock needs to have been initialized by the time this is -* called since this will reserve memory. -*/ -reserve_hugetlb_gpages (); -klp_init_thread_info (&init_thread_info); init_mm.start_code = (unsigned long )_stext;
arch/powerpc/mm/hash_utils_64.c +1 -1
@@ -509,7 +509,7 @@ static int __init htab_dt_scan_hugepage_blocks(unsigned long node, phys_addr, block_size, expected_pages);if (phys_addr + (16 *GB ) <=memblock_end_of_DRAM ()) {memblock_reserve (phys_addr, block_size * expected_pages); -add_gpage (phys_addr, block_size, expected_pages); +pseries_add_gpage (phys_addr, block_size, expected_pages); }return 0 ; }
arch/powerpc/mm/hugetlbpage.c +20 -157
207 lines not on this page · raw message
arch/powerpc/mm/init_32.c +0 -2
@@ -132,8 +132,6 @@ void __init MMU_init(void)* Reserve gigantic pages for hugetlb. This MUST occur before * lowmem_end_addr is initialized below. */ -reserve_hugetlb_gpages (); -if (memblock.memory.cnt >1 ) {#ifndef CONFIG_WII memblock_enforce_memory_limit (memblock.memory.regions[0 ].size);
Signature · 7 lines
2.13.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 3/3 powerpc/mm/hugetlb: Allow runtime allocation of 16G.
In reply to Aneesh Kumar K.VWe now have GIGANTIC_PAGE on powerpc. Currently this is enabled only on radix with 1G as gigantic hugepage size. Enable this with hash translation mode too (ie, with 16G hugepage size). Depending on the total system memory we may be able to allocate 16G hugepage size. This bring parity between radix and hash translation mode. Also reduce the confusion of the user with respect to hugetlbfs usage.
--- arch/powerpc/include/asm/book3s/64/hugetlb.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/powerpc/include/asm/book3s/64/hugetlb.h +1 -3
@@ -54,9 +54,7 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE static inline bool gigantic_page_supported (void ) { -if (radix_enabled ()) -return true; -return false; +return true; }#endif
Signature · 7 lines
2.13.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Aneesh Kumar K.V
For ppc64, we want to call this function when we are not running as guest.
What does this mean?
Quoted 51 lines
Also, if we failed to allocate hugepages, let the user know.
Signed-off-by Aneesh Kumar K.V <[email protected]>--- include/linux/hugetlb.h | 1 + mm/hugetlb.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)include/linux/hugetlb.h +1
-0@@ -358,6 +358,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 );mm/hugetlb.c +4
-1@@ -2083,7 +2083,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;@@ -2104,6 +2106,7 @@ int __weak alloc_bootmem_huge_page(struct hstate *h) goto found; } } +pr_info ("Failed to allocate hugepage of size %ld\n" ,huge_page_size (h));return 0 ; found:Signature · 7 lines
2.13.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · Aneesh Kumar K.V
For ppc64, we want to call this function when we are not running as guest. Also, if we failed to allocate hugepages, let the user know.
[...]
Quoted 16 lines
mm/hugetlb.c +3
-1@@ -2083,7 +2083,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;
mm/hugetlb.c int __weak alloc_bootmem_huge_page(struct hstate *h) · line 2112
Quoted 7 lines
mm/hugetlb.c +1
-0@@ -2104,6 +2106,7 @@ int __weak alloc_bootmem_huge_page(struct hstate *h) goto found; } } +pr_info ("Failed to allocate hugepage of size %ld\n" ,huge_page_size (h));return 0 ; found:
There is already a call to warn the user in the hugetlb_hstate_alloc_pages function. If you look there, you will see that the huge_page_size was translated into a more user friendly format and the count prior to the failure is included. What call path are you trying to cover? Also, you may want your print to be a pr_warn since it is a failure?
Thanks,
Liam
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 27 lines · Liam R. Howlett
Quoted 3 lines · Aneesh Kumar K.V
For ppc64, we want to call this function when we are not running as guest. Also, if we failed to allocate hugepages, let the user know.
[...]
Quoted 22 lines
mm/hugetlb.c +4
-1@@ -2083,7 +2083,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;@@ -2104,6 +2106,7 @@ int __weak alloc_bootmem_huge_page(struct hstate *h) goto found; } } +pr_info ("Failed to allocate hugepage of size %ld\n" ,huge_page_size (h));return 0 ;
Quoted 9 lines
mm/hugetlb.c int __weak alloc_bootmem_huge_page(struct hstate *h) · line 2112
Quoted 1 line
mm/hugetlb.c +0
-0found:There is already a call to warn the user in the
hugetlb_hstate_alloc_pagesfunction. If you look there, you will see that thehuge_page_sizewas translated into a more user friendly format and the count prior to the failure is included. What call path are you trying to cover? Also, you may want your print to be apr_warnsince it is a failure?
Sorry I missed that in the recent kernel. I wrote the above before the mentioned changes was done. I will drop the pr_info from the patch.
Thanks
-aneesh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 5 lines · Michal Hocko
Quoted 1 line · Aneesh Kumar K.V
For ppc64, we want to call this function when we are not running as guest.
What does this mean?
ppc64 guest (aka LPAR) support 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. You can find the details in htab_dt_scan_hugepage_blocks() . We do the memblock_reserve of the range and later in the boot sequence, we just add the reserved range tohuge_boot_pages.
For baremetal config (when we are not running as guest) we want to follow what other architecture does, that is look at the command line and do memblock allocation. Hence the need to call generic function __alloc_bootmem_huge_page() in that case.
I can add all these details in to the commit message if that makes it easy ?
-aneesh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 38 lines · Aneesh Kumar K.V
Quoted 25 lines · Liam R. Howlett
Quoted 3 lines · Aneesh Kumar K.V
For ppc64, we want to call this function when we are not running as guest. Also, if we failed to allocate hugepages, let the user know.
[...]
Quoted 20 lines
mm/hugetlb.c +4
-1@@ -2083,7 +2083,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;@@ -2104,6 +2106,7 @@ int __weak alloc_bootmem_huge_page(struct hstate *h) goto found; } } +pr_info ("Failed to allocate hugepage of size %ld\n" ,huge_page_size (h));return 0 ;Quoted 9 lines
mm/hugetlb.c int __weak alloc_bootmem_huge_page(struct hstate *h) · line 2111
Quoted 1 line
mm/hugetlb.c +0
-0found:There is already a call to warn the user in the
hugetlb_hstate_alloc_pagesfunction. If you look there, you will see that thehuge_page_sizewas translated into a more user friendly format and the count prior to the failure is included. What call path are you trying to cover? Also, you may want your print to be apr_warnsince it is a failure?
Quoted 2 lines
Sorry I missed that in the recent kernel. I wrote the above before the mentioned changes was done. I will drop the
pr_infofrom the patch.
Okay, thanks. I didn't think there was a code path that was missed on boot.
Cheers,
Liam
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 17 lines · Aneesh Kumar K.V
Quoted 5 lines · Michal Hocko
Quoted 1 line · Aneesh Kumar K.V
For ppc64, we want to call this function when we are not running as guest.
What does this mean?
ppc64 guest (aka LPAR) support 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. You can find the details in
htab_dt_scan_hugepage_blocks(). We do thememblock_reserveof the range and later in the boot sequence, we just add the reserved range tohuge_boot_pages.
Quoted 6 lines
For baremetal config (when we are not running as guest) we want to follow what other architecture does, that is look at the command line and do memblock allocation. Hence the need to call generic function
__alloc_bootmem_huge_page()in that case.I can add all these details in to the commit message if that makes it easy ?
It certainly helped me to understand the context much better. Thanks! As you are patching a generic code this would be appropriate IMHO.
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>