mm/hugetlb: copy the CMA flag when demoting
authorFrank van der Linden <fvdl@google.com>
Thu, 1 May 2025 04:43:24 +0000 (04:43 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 8 May 2025 06:39:42 +0000 (23:39 -0700)
commitdac2a4f663c4bcd75add07aedf9d30c9f8e5ead5
tree8c14e8b07eff937c40c949a539a2f628a8815c1b
parent9a9794a81a8a1be8670aa673ec0f0fbfbddeccae
mm/hugetlb: copy the CMA flag when demoting

Since commit d2d786714080 ("mm/hugetlb: enable bootmem allocation from CMA
areas"), a flag is used to mark hugetlb folios as allocated from CMA.
This flag is also used to decide if it should be freed to CMA.

However, the flag isn't copied to the smaller folios when a hugetlb folio
is broken up for demotion, which would cause it to be freed incorrectly.

Fix this by copying the flag to the smaller order hugetlb pages created
from the original one.

Link: https://lkml.kernel.org/r/20250501044325.20365-1-fvdl@google.com
Fixes: d2d786714080 ("mm/hugetlb: enable bootmem allocation from CMA areas")
Signed-off-by: Frank van der Linden <fvdl@google.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Jane Chu <Jane.Chu@oracle.com>
Cc: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb.c