Re: [PATCH 03/21] mm/hugetlb: always mark new page cache folios migratable
From: Oscar Salvador (SUSE)
Date: Thu Nov 26 2026 - 04:58:35 EST
On Wed, Nov 25, 2026 at 11:33:01PM +0100, David Hildenbrand (Arm) wrote:
> hugetlb_no_page() and hugetlb_mfill_atomic_pte() only set
> hugetlb_migratable for a new folio once they installed the PTE.
>
> If they back out after adding the new folio to the page cache, for
> example because the PTE changed or is no longer empty, the folio will
> stay in the page cache without the migratable flag set.
>
> Later faults will find it as an existing folio and never reset the flag.
> Such a folio can never be isolated for migration, which breaks memory
> offlining, alloc_contig_range(), longterm pinning and memory failure
> handling.
>
> Worse, if the folio is not longterm pinnable, because it resides in
> ZONE_MOVABLE or CMA, memfd_pin_folios() and the longterm GUP path retry
> forever on -EAGAIN. memfd_pin_folios() cannot even be killed, which will
> be fixed independently.
>
> Let's fix it by setting hugetlb folios migratable whenever (1) a new
> anon folio gets mapped; or (2) a new folio was added to the page cache,
> like hugetlbfs_fallocate() already does.
>
> This has low urgency.
>
> Fixes: cb6acd01e2e4 ("hugetlbfs: fix races and page leaks during migration")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Acked-by: Oscar Salvador (SUSE) <osalvador@xxxxxxxxxx>
--
Oscar Salvador
SUSE Labs