Re: [PATCH v2 11/35] mm/hugetlb_cma: reset hugetlb_cma_size if the arch doesn't support it
From: Muchun Song
Date: Fri Dec 04 2026 - 01:11:43 EST
> On Dec 3, 2026, at 19:37, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> With hugetlb_cma=, hugetlb_cma_reserve() reserves CMA areas for gigantic
> huge pages. If it ends up not reserving anything, it sets
> hugetlb_cma_size to 0, as it is the signal to the rest of hugetlb that
> the hugetlb CMA area exists.
>
> However, if the architecture does not support hugetlb CMA,
> hugetlb_cma_reserve() only warns and returns, but leaves
> hugetlb_cma_size as set by the command line.
>
> Consequently, we skip the boot-time allocation of gigantic huge pages,
> which matters on architectures where gigantic huge pages are allocated at
> boot, like powerpc with the hash MMU in an LPAR, where the firmware
> provides 16G pages. Further, we disable demotion of small huge pages and
> don't clear hugetlb_cma_only, so gigantic huge pages cannot be allocated
> at all.
>
> This only affects architectures with gigantic huge pages but without
> hugetlb CMA support, such as sparc64, sh, or powerpc with the hash MMU in
> an LPAR.
>
> The fix is trivial, so let's just reset hugetlb_cma_size like we do on
> the other paths that don't reserve anything.
>
> This has low urgency, as it requires passing hugetlb_cma= on one of these
> architectures. No need to CC stable.
>
> Fixes: dbda8feadfa4 ("mm/hugetlb: avoid hardcoding while checking if cma is enabled")
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Acked-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>
Thanks.