Re: [PATCH v2 07/35] mm/hugetlb: always mark new page cache folios migratable

From: Jose A. Perez de Azpillaga

Date: Fri Dec 04 2026 - 05:38:08 EST


On 12/3/26 12:37 PM, 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
> Reviewed-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>
> Acked-by: Oscar Salvador (SUSE) <osalvador@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

LGTM:

Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>

--
cheers,
jose a. p-a