powerpc/mm: Update default hugetlb size early
Subsystems (2)
PATCH 1/1 powerpc/mm: Update default hugetlb size early
We use the default hugetlb page size to calculate pageblock order. set_pageblock_order happens early in the boot and we need to make sure we set the default hugetlb page size before that to compute the right pageblock_order value.
arch_initcalls get called later in the boot as shown below
[c000000007383b10] [c000000001289328] hugetlbpage_init+0x2b8/0x2f8 [c000000007383bc0] [c0000000012749e4] do_one_initcall+0x14c/0x320 [c000000007383c90] [c00000000127505c] kernel_init_freeable+0x410/0x4e8 [c000000007383da0] [c000000000012664] kernel_init+0x30/0x15c [c000000007383e10] [c00000000000cf14] ret_from_kernel_thread+0x5c/0x64
and we do the pageblock_order initialization early during the boot.
[c0000000018bfc80] [c0000000012ae120] set_pageblock_order+0x50/0x64 [c0000000018bfca0] [c0000000012b3d94] sparse_init+0x188/0x268 [c0000000018bfd60] [c000000001288bfc] initmem_init+0x28c/0x328 [c0000000018bfe50] [c00000000127b370] setup_arch+0x410/0x480 [c0000000018bfed0] [c00000000127401c] start_kernel+0xb8/0x934 [c0000000018bff90] [c00000000000d984] start_here_common+0x1c/0x98
IIUC we always had this issue. But it was not a problem for hash because MAX_ORDER - 1 was the same as HUGETLB_PAGE_ORDER (8) in the case of hash (16MB). With radix, HUGETLB_PAGE_ORDER will be 5 (2M size) and hence we would want pageblock_order to be 5 instead of 8.
--- arch/powerpc/include/asm/hugetlb.h | 5 ++++- arch/powerpc/mm/book3s64/hugetlbpage.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 5 +---- arch/powerpc/mm/init_64.c | 4 ++++ 4 files changed, 10 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/hugetlb.h +4 -1
@@ -15,7 +15,7 @@extern bool hugetlb_disabled; -void __init hugetlbpage_init_default (void ); +void __init hugetlbpage_init_defaultsize (void );int slice_is_hugepage_only_range (struct mm_struct *mm,unsigned long addr,unsigned long len);
@@ -76,6 +76,9 @@ static inline void __init gigantic_hugetlb_cma_reserve(void) { } +static inline void __init hugetlbpage_init_defaultsize (void ) +{ +}#endif /* CONFIG_HUGETLB_PAGE */ #endif /* _ASM_POWERPC_HUGETLB_H */
arch/powerpc/mm/book3s64/hugetlbpage.c +1 -1
@@ -150,7 +150,7 @@ void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addrset_huge_pte_at (vma->vm_mm, addr, ptep, pte); } -void __init hugetlbpage_init_default (void ) +void __init hugetlbpage_init_defaultsize (void ) {/* Set default large page size. Currently, we pick 16M or 1M * depending on what is available
arch/powerpc/mm/hugetlbpage.c +1 -4
@@ -664,10 +664,7 @@ static int __init hugetlbpage_init(void) configured = true; } -if (configured) { -if (IS_ENABLED (CONFIG_HUGETLB_PAGE_SIZE_VARIABLE )) -hugetlbpage_init_default (); - }else +if (!configured)pr_info ("Failed to initialize. Disabling HugeTLB" );return 0 ;
arch/powerpc/mm/init_64.c +4 -0
@@ -59,6 +59,7 @@#include <asm/sections.h> #include <asm/iommu.h> #include <asm/vdso.h> +#include <asm/hugetlb.h> #include <mm/mmu_decl.h>
@@ -513,6 +514,9 @@ void __init mmu_early_init_devtree(void) }else hash__early_init_devtree (); +if (IS_ENABLED (CONFIG_HUGETLB_PAGE_SIZE_VARIABLE )) +hugetlbpage_init_defaultsize (); +if (!(cur_cpu_spec->mmu_features &MMU_FTR_HPTE_TABLE ) && !(cur_cpu_spec->mmu_features &MMU_FTR_TYPE_RADIX ))panic ("kernel does not support any MMU type offered by platform" );
Signature · 1 line
2.34.1