[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87a50j30z6.ritesh.list@gmail.com>
Date: Tue, 18 Nov 2025 19:19:01 +0530
From: Ritesh Harjani (IBM) <ritesh.list@...il.com>
To: "David Hildenbrand (Red Hat)" <david@...nel.org>, linux-kernel@...r.kernel.org
Cc: linux-mm@...ck.org, linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>, "David Hildenbrand (Red Hat)" <david@...nel.org>, Christophe Leroy <christophe.leroy@...roup.eu>, Sourabh Jain <sourabhjain@...ux.ibm.com>, Andrew Morton <akpm@...ux-foundation.org>, Madhavan Srinivasan <maddy@...ux.ibm.com>, Donet Tom <donettom@...ux.ibm.com>, Michael Ellerman <mpe@...erman.id.au>, Nicholas Piggin <npiggin@...il.com>, Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, "Liam R. Howlett" <Liam.Howlett@...cle.com>, Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>, Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>, Nathan Chancellor <nathan@...nel.org>
Subject: Re: [PATCH v2] mm: fix MAX_FOLIO_ORDER on powerpc configs with hugetlb
"David Hildenbrand (Red Hat)" <david@...nel.org> writes:
> 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 fae7d834c43c ("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 7b4f21f5e038 ("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.
So, book3s64 anyways always default to Radix which by default always select
CONFIG_ARCH_HAS_GIGANTIC_PAGE. So even if during runtime Hash mmu gets
selected, we anyways by default had this config enabled on book3s64.
> I don't think this is a problem, but if it is we could handle it through
> __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED.
Exactly, I see we already have the above config knob at most places where
this could be needed to prevent runtime gigantic pages.
>
> 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.
>
> Fixes: 7b4f21f5e038 ("mm/hugetlb: check for unreasonable folio sizes when registering hstate")
> Reported-by: Christophe Leroy <christophe.leroy@...roup.eu>
> Closes: https://lore.kernel.org/r/3e043453-3f27-48ad-b987-cc39f523060a@csgroup.eu/
> Reported-by: Sourabh Jain <sourabhjain@...ux.ibm.com>
> Closes: https://lore.kernel.org/r/94377f5c-d4f0-4c0f-b0f6-5bf1cd7305b1@linux.ibm.com/
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Ritesh Harjani (IBM) <ritesh.list@...il.com>
> Cc: Madhavan Srinivasan <maddy@...ux.ibm.com>
> Cc: Donet Tom <donettom@...ux.ibm.com>
> Cc: Michael Ellerman <mpe@...erman.id.au>
> Cc: Nicholas Piggin <npiggin@...il.com>
> Cc: Christophe Leroy <christophe.leroy@...roup.eu>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
> Cc: "Liam R. Howlett" <Liam.Howlett@...cle.com>
> Cc: Vlastimil Babka <vbabka@...e.cz>
> Cc: Mike Rapoport <rppt@...nel.org>
> Cc: Suren Baghdasaryan <surenb@...gle.com>
> Cc: Michal Hocko <mhocko@...e.com>
> Cc: Nathan Chancellor <nathan@...nel.org>
> Signed-off-by: David Hildenbrand (Red Hat) <david@...nel.org>
> ---
>
> v1 -> v2:
Sorry, this got delayed a bit as I wanted to run mm selftests and then
update.
As I had updated in previous version, this patch also fixes the warning
during boot when RADIX MMU config is kept disabled at build time (that
means only Hash is selected) on book3s64.
No new tests failures were reported on running mm selftests with Hash
mmu on book3s64. Also verified boot tests on few other ppc configs.
So even though I know this patch is already taken in rc6, but still -
Reviewed-and-tested-by: Ritesh Harjani (IBM) <ritesh.list@...il.com>
Thanks again for providing a quick fix!
-ritesh
Powered by blists - more mailing lists