[PATCH v4 05/17] mm/huge_memory: rename __split_unmapped_folio() to __split_frozen_folio()
From: Kairui Song via B4 Relay
Date: Mon Sep 07 2026 - 14:12:45 EST
From: Kairui Song <kasong@xxxxxxxxxxx>
The helper splits a folio whose refcount is frozen: the frozen refcount
is the state it relies on, while unmapping is arranged by the caller
beforehand. The old name caused confusion and people may try to call the
helper on non-frozen folios.
Also add a VM_WARN_ON_ONCE_FOLIO(folio_mapped(folio)) to self document
that frozen implies unmapped.
Suggested-by: Zi Yan <ziy@xxxxxxxxxx>
Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
Reviewed-by: Yeoreum Yun <yeoreum.yun@xxxxxxx>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
---
mm/huge_memory.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 0e28a3e66b67..80291fac78e2 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3806,8 +3806,8 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
}
/**
- * __split_unmapped_folio() - splits an unmapped @folio to lower order folios in
- * two ways: uniform split or non-uniform split.
+ * __split_frozen_folio() - splits a frozen @folio to lower order folios
+ * in two ways: uniform split or non-uniform split.
* @folio: the to-be-split folio
* @new_order: the smallest order of the after split folios (since buddy
* allocator like split generates folios with orders from @folio's
@@ -3846,7 +3846,7 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
* Return: 0 - successful, <0 - failed (if -ENOMEM is returned, @folio might be
* split but not to @new_order, the caller needs to check)
*/
-static int __split_unmapped_folio(struct folio *folio, int new_order,
+static int __split_frozen_folio(struct folio *folio, int new_order,
struct page *split_at, struct xa_state *xas,
struct address_space *mapping, enum split_type split_type)
{
@@ -3856,6 +3856,9 @@ static int __split_unmapped_folio(struct folio *folio, int new_order,
struct folio *old_folio = folio;
int split_order;
+ /* Frozen implies unmapped, callers unmap before splitting. */
+ VM_WARN_ON_ONCE_FOLIO(folio_mapped(folio), folio);
+
/*
* split to new_order one order at a time. For uniform split,
* folio is split to new_order directly.
@@ -4019,8 +4022,8 @@ static int __folio_freeze_split_anon(struct folio *folio,
if (do_lru)
lruvec = folio_lruvec_lock(folio);
- ret = __split_unmapped_folio(folio, new_order, split_at, NULL,
- NULL, split_type);
+ ret = __split_frozen_folio(folio, new_order, split_at, NULL,
+ NULL, split_type);
/*
* Unfreeze the after-split folios and put them back to the right
@@ -4086,8 +4089,8 @@ static int __folio_freeze_split_file(struct folio *folio,
if (do_lru)
lruvec = folio_lruvec_lock(folio);
- ret = __split_unmapped_folio(folio, new_order, split_at, xas,
- mapping, split_type);
+ ret = __split_frozen_folio(folio, new_order, split_at, xas,
+ mapping, split_type);
/*
* Unfreeze after-split folios and put them back to the right
@@ -4151,9 +4154,9 @@ static int __folio_freeze_split_file(struct folio *folio,
* @list: after-split folios will be put on it if non NULL
* @split_type: perform uniform split or not (non-uniform split)
*
- * It calls __split_unmapped_folio() to perform uniform and non-uniform split.
+ * It calls __split_frozen_folio() to perform uniform and non-uniform split.
* It is in charge of checking whether the split is supported or not and
- * preparing @folio for __split_unmapped_folio().
+ * preparing @folio for __split_frozen_folio().
*
* After splitting, the after-split folio containing @lock_at remains locked
* and others are unlocked:
@@ -4256,7 +4259,7 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
i_mmap_lock_read(mapping);
/*
- *__split_unmapped_folio() may need to trim off pages beyond
+ * __split_frozen_folio() may need to trim off pages beyond
* EOF: but on 32-bit, i_size_read() takes an irq-unsafe
* seqlock, which cannot be nested inside the page tree lock.
* So note end now: i_size itself may be changed at any moment,
--
2.55.0