Re: [PATCH v4 2/3] mm: gup: allow long-term pins of CMA-allocated HugeTLB folios

From: Qi Zheng

Date: Thu Nov 12 2026 - 01:13:48 EST




On 11/11/26 3:42 PM, Muchun Song wrote:


On Nov 11, 2026, at 14:46, Qi Zheng <qi.zheng@xxxxxxxxx> wrote:

From: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>

Long-term pinning treats explicitly CMA-allocated HugeTLB folios as
unpinnable, causing unnecessary migration or pinning failures.

These folios already own their CMA bitmap ranges, and memory blocks

Commit message needs updating to bitmap as well.

Will do.


overlapping CMA areas cannot be offlined. Allow HugeTLB folios with
HPG_cma to be pinned directly, including in ZONE_MOVABLE.

Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma")
Cc: stable@xxxxxxxxxxxxxxx
Suggested-by: Muchun Song <muchun.song@xxxxxxxxx>
Signed-off-by: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
Acked-by: Muchun Song <muchun.song@xxxxxxxxx>
Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
---
include/linux/mm.h | 29 +----------------------------
mm/gup.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index b0da9be413098..47d1d96bfc7fd 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2954,35 +2954,8 @@ static inline bool is_zero_folio(const struct folio *folio)
return is_zero_page(&folio->page);
}

-/* MIGRATE_CMA and ZONE_MOVABLE do not allow pin folios */
#ifdef CONFIG_MIGRATION
-static inline bool folio_is_longterm_pinnable(struct folio *folio)

I think David prefer to move this function first, then fix it in a separate patch,
right?

Hi David, is this what you mean? If so, I will split it into two patches
for the v5.

Thanks,
Qi