On 27 Aug 2025, at 18:01, David Hildenbrand wrote:
Let's check that no hstate that corresponds to an unreasonable folio size is registered by an architecture. If we were to succeed registering, we could later try allocating an unsupported gigantic folio size.
Further, let's add a BUILD_BUG_ON() for checking that HUGETLB_PAGE_ORDER is sane at build time. As HUGETLB_PAGE_ORDER is dynamic on powerpc, we have to use a BUILD_BUG_ON_INVALID() to make it compile.
No existing kernel configuration should be able to trigger this check: either SPARSEMEM without SPARSEMEM_VMEMMAP cannot be configured or gigantic folios will not exceed a memory section (the case on sparse).
Signed-off-by: David Hildenbrand david@redhat.com
mm/hugetlb.c | 2 ++ 1 file changed, 2 insertions(+)
LGTM. Reviewed-by: Zi Yan ziy@nvidia.com
-- Best Regards, Yan, Zi