linux/arch/powerpc/platforms
David Hildenbrand (Red Hat) 39231e8d6b mm: fix MAX_FOLIO_ORDER on powerpc configs with hugetlb
In the past, CONFIG_ARCH_HAS_GIGANTIC_PAGE indicated that we support
runtime allocation of gigantic hugetlb folios.  In the meantime it evolved
into a generic way for the architecture to state that it supports gigantic
hugetlb folios.

In commit fae7d834c4 ("mm: add __dump_folio()") we started using
CONFIG_ARCH_HAS_GIGANTIC_PAGE to decide MAX_FOLIO_ORDER: whether we could
have folios larger than what the buddy can handle.  In the context of that
commit, we started using MAX_FOLIO_ORDER to detect page corruptions when
dumping tail pages of folios.  Before that commit, we assumed that we
cannot have folios larger than the highest buddy order, which was
obviously wrong.

In commit 7b4f21f5e0 ("mm/hugetlb: check for unreasonable folio sizes
when registering hstate"), we used MAX_FOLIO_ORDER to detect
inconsistencies, and in fact, we found some now.

Powerpc allows for configs that can allocate gigantic folio during boot
(not at runtime), that do not set CONFIG_ARCH_HAS_GIGANTIC_PAGE and can
exceed PUD_ORDER.

To fix it, let's make powerpc select CONFIG_ARCH_HAS_GIGANTIC_PAGE with
hugetlb on powerpc, and increase the maximum folio size with hugetlb to 16
GiB on 64bit (possible on arm64 and powerpc) and 1 GiB on 32 bit
(powerpc).  Note that on some powerpc configurations, whether we actually
have gigantic pages depends on the setting of CONFIG_ARCH_FORCE_MAX_ORDER,
but there is nothing really problematic about setting it unconditionally:
we just try to keep the value small so we can better detect problems in
__dump_folio() and inconsistencies around the expected largest folio in
the system.

Ideally, we'd have a better way to obtain the maximum hugetlb folio size
and detect ourselves whether we really end up with gigantic folios.  Let's
defer bigger changes and fix the warnings first.

While at it, handle gigantic DAX folios more clearly: DAX can only end up
creating gigantic folios with HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD.

Add a new Kconfig option HAVE_GIGANTIC_FOLIOS to make both cases clearer. 
In particular, worry about ARCH_HAS_GIGANTIC_PAGE only with HUGETLB_PAGE.

Note: with enabling CONFIG_ARCH_HAS_GIGANTIC_PAGE on powerpc, we will now
also allow for runtime allocations of folios in some more powerpc configs.
I don't think this is a problem, but if it is we could handle it through
__HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED.

While __dump_page()/__dump_folio was also problematic (not handling
dumping of tail pages of such gigantic folios correctly), it doesn't seem
critical enough to mark it as a fix.

Link: https://lkml.kernel.org/r/20251114214920.2550676-1-david@kernel.org
Fixes: 7b4f21f5e0 ("mm/hugetlb: check for unreasonable folio sizes when registering hstate")
Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Closes: https://lore.kernel.org/r/3e043453-3f27-48ad-b987-cc39f523060a@csgroup.eu/
Reported-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Closes: https://lore.kernel.org/r/94377f5c-d4f0-4c0f-b0f6-5bf1cd7305b1@linux.ibm.com/
Signed-off-by: David Hildenbrand (Red Hat) <david@kernel.org>
Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Donet Tom <donettom@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-11-15 10:52:00 -08:00
..
8xx powerpc/cpm2: Drop legacy-of-mm-gpiochip.h header 2025-09-06 16:05:26 +05:30
44x powerpc/44x: Drop legacy-of-mm-gpiochip.h header 2025-09-06 16:07:11 +05:30
52xx treewide: rename GPIO set callbacks back to their original names 2025-08-07 10:07:06 +02:00
82xx powerpc-km82xx.c: replace of_node_put() with __free 2024-11-15 10:35:58 +11:00
83xx treewide: rename GPIO set callbacks back to their original names 2025-08-07 10:07:06 +02:00
85xx powerpc: Switch to irq_find_mapping() 2025-05-16 21:06:12 +02:00
86xx asm-generic: introduce text-patching.h 2024-11-07 14:25:15 -08:00
512x (powerpc/512) Fix possible dma_unmap_single() on uninitialized pointer 2025-07-09 09:15:10 +05:30
amigaone irqdomain: Rename irq_set_default_host() to irq_set_default_domain() 2025-04-04 16:39:10 +02:00
book3s powerpc: book3s: vas: use lock guard for mutex 2025-06-23 09:57:11 +05:30
cell vfs-6.18-rc1.async 2025-09-29 11:55:15 -07:00
chrp irqdomain: Rename irq_set_default_host() to irq_set_default_domain() 2025-04-04 16:39:10 +02:00
embedded6xx powerpc: Switch to irq_find_mapping() 2025-05-16 21:06:12 +02:00
microwatt powerpc/microwatt: Add SMP support 2025-02-26 21:16:48 +05:30
pasemi irqdomain: Rename irq_set_default_host() to irq_set_default_domain() 2025-04-04 16:39:10 +02:00
powermac powerpc/powermac: remove unneeded tty includes 2025-06-17 13:42:33 +02:00
powernv powerpc, ocxl: Fix extraction of struct xive_irq_data 2025-10-13 09:40:55 +05:30
ps3 A set of cleanups for the generic interrupt subsystem: 2025-05-27 08:07:32 -07:00
pseries powerpc/pseries/msi: Fix NULL pointer dereference at irq domain teardown 2025-10-13 09:39:02 +05:30
fsl_uli1575.c powerpc/fsl_uli1575: Mark uli_exclude_device() as static 2023-04-20 10:20:50 +10:00
Kconfig soc: driver updates for 6.18 2025-10-01 17:32:51 -07:00
Kconfig.cputype mm: fix MAX_FOLIO_ORDER on powerpc configs with hugetlb 2025-11-15 10:52:00 -08:00
Makefile powerpc/64: Remove maple platform 2024-10-29 23:01:52 +11:00