[PATCH] mm/hugetlb: bring gigantic page allocation under hugepages_supported()
Sourabh Jain
sourabhjain at linux.ibm.com
Wed Jan 22 02:04:19 AEDT 2025
Despite having kernel arguments to enable gigantic hugepages, this
provides a way for the architecture to disable gigantic hugepages on the
fly, similar to what we do for hugepages.
Components like fadump (PowerPC-specific) need this functionality to
disable gigantic hugepages when the kernel is booted solely to collect
the kernel core dump.
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: Ingo Molnar <mingo at redhat.com>
Cc: Borislav Petkov <bp at alien8.de>
Cc: Heiko Carstens <hca at linux.ibm.com>
Cc: Vasily Gorbik <gor at linux.ibm.com>
Cc: Muchun Song <muchun.song at linux.dev>
Cc: Madhavan Srinivasan <maddy at linux.ibm.com>
Cc: Michael Ellerman <mpe at ellerman.id.au>
Cc: linux-mm at kvack.org
Cc: linux-kernel at vger.kernel.org
Cc: linuxppc-dev at lists.ozlabs.org
Signed-off-by: Sourabh Jain <sourabhjain at linux.ibm.com>
---
To evaluate the impact of this change on architectures other than
PowerPC, I did the following analysis:
For architectures where hugepages_supported() is not redefined, it
depends on HPAGE_SHIFT, which is found to be a constant. It is mostly
initialized to PMD_SHIFT.
Architecture : HPAGE_SHIFT initialized with
ARC: PMD_SHIFT (constant)
ARM: PMD_SHIFT (constant)
ARM64: PMD_SHIFT (constant)
Hexagon: 22 (constant)
LoongArch: (PAGE_SHIFT + PAGE_SHIFT - 3) (appears to be constant)
MIPS: (PAGE_SHIFT + PAGE_SHIFT - 3) (appears to be constant)
PARISC: PMD_SHIFT (appears to be constant)
RISC-V: PMD_SHIFT (constant)
SH: 16 | 18 | 20 | 22 | 26 (constant)
SPARC: 23 (constant)
So seems like this change shouldn't have any impact on above
architectures.
On the S390 and X86 architectures, hugepages_supported() is redefined,
and I am uncertain at what point it is safe to call
hugepages_supported().
---
mm/hugetlb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index cec4b121193f..48b42b8d26b4 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4629,7 +4629,7 @@ static int __init hugepages_setup(char *s)
* But we need to allocate gigantic hstates here early to still
* use the bootmem allocator.
*/
- if (hugetlb_max_hstate && hstate_is_gigantic(parsed_hstate))
+ if (hugetlb_max_hstate && hstate_is_gigantic(parsed_hstate) && hugepages_supported())
hugetlb_hstate_alloc_pages(parsed_hstate);
last_mhp = mhp;
--
2.47.1
More information about the Linuxppc-dev
mailing list