Re: [PATCH] mm/mm_init: don't subtract managed CMA pages twice

From: Mike Rapoport

Date: Thu Nov 19 2026 - 06:40:33 EST


On Thu, Nov 19, 2026 at 12:19:06PM +0100, David Hildenbrand (Arm) wrote:
> From: Chris Mason <mason@xxxxxxxxxx>
>
> With hugetlb_cma_only, the "reserved" value in the "Memory:" boot message
> can be wrong (small or underflowed).
>
> When mem_init_print_info() calculates the reserved memory, it assumes that
> no CMA pages are managed yet. However, some CMA pages from hugetlb might
> already be managed at that point,

How about I change it to

However, hugetlb may have already initialized its bootmem CMA areas,

when applying?

> so we end up subtracting them twice.
>
> Fix it by only subtracting CMA pages that are not managed yet.
>
> This has very low urgency, as it only affects a boot message.

Agree :)

> Fixes: b1b7c045e808 ("mm/hugetlb: initialize gigantic bootmem hugepage struct pages earlier")
> Signed-off-by: Chris Mason <mason@xxxxxxxxxx>
> [ david: improve description and comment ]
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> ---
> This should go through the memblock tree.
> ---
> mm/mm_init.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)

--
Sincerely yours,
Mike.