Re: [PATCH v5 08/17] mm/huge_memory: move unmap and remap into the split helpers

From: David Hildenbrand (Arm)

Date: Fri Sep 18 2026 - 16:48:41 EST


On 9/14/26 19:14, Kairui Song via B4 Relay wrote:
> From: Kairui Song <kasong@xxxxxxxxxxx>
>
> To prepare for further cleanup, move the unmap/remap handling from
> __folio_split() into the split helpers. Only anon folios need to
> be remapped, so remap_page() is now only called for anon splits and
> the anon check in remap_page() is redundant and can be removed.
>
> 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 | 36 ++++++++++++++++++++++--------------
> 1 file changed, 22 insertions(+), 14 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 5ba3bcdfc42d..1749905ade6a 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -3641,9 +3641,6 @@ static void remap_page(struct folio *folio, unsigned long nr, int flags)
> {
> int i = 0;
>
> - /* If unmap_folio() uses try_to_migrate() on file, remove this check */
> - if (!folio_test_anon(folio))
> - return;
> for (;;) {
> remove_migration_ptes(folio, folio, TTU_RMAP_LOCKED | flags);
> i += folio_nr_pages(folio);
> @@ -4017,15 +4014,23 @@ static int __folio_freeze_split_anon(struct folio *folio,
> {
> struct folio *end_folio = folio_next(folio);
> struct swap_cluster_info *ci = NULL;
> + int old_order = folio_order(folio);

const

> struct folio *new_folio, *next;
> + enum ttu_flags ttu_flags = 0;
> struct lruvec *lruvec;
> + bool need_remap = false;
> int ret = 0;
>

[...]

>
> return ret;
> }
> @@ -4106,6 +4117,8 @@ static int __folio_freeze_split_file(struct folio *folio,
> if (shmem_mapping(mapping))
> end = shmem_fallocend(mapping->host, end);
>
> + unmap_folio(folio);
> +
> xas_lock_irq(xas);
>
> /*
> @@ -4190,8 +4203,11 @@ static int __folio_freeze_split_file(struct folio *folio,
>
> if (do_lru)
> lruvec_unlock(lruvec);
> -
> fail:
> + /*
> + * If we want to use try_to_migrate() on file in unmap_folio,
> + * remember to add remap_page() and adapt it.

Again, remove that entirely.

> + */
> xas_unlock_irq(xas);
> if (nr_shmem_dropped)
> shmem_uncharge(mapping->host, nr_shmem_dropped);

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David