Re: [PATCH v2 26/35] mm/rmap: don't fail unmapping hugetlb folios from private VMAs

From: Jose A. Perez de Azpillaga

Date: Fri Dec 04 2026 - 06:32:32 EST


On 12/3/26 12:37 PM, David Hildenbrand (Arm) wrote:
> Before unmapping a hugetlb page cache folio, try_to_migrate_one() and
> try_to_unmap_poisoned_hugetlb_one() try to unshare the PMD table, which
> requires the hugetlb VMA lock in write mode.
>
> As we already hold the i_mmap_rwsem, we can only trylock it, and give up
> if that fails.
>
> Since private hugetlb VMAs have a VMA lock as well, the trylock can also
> fail on private VMAs, for example while another thread is faulting in
> that VMA. PMD table sharing does not apply in private VMAs, so there is
> nothing to unshare and we fail for no reason: migration fails more
> often, and memory failure might leave a poisoned folio mapped.
>
> Let's fix it by only taking the VMA lock and trying to unshare if PMD
> tables can be shared.
>
> Fortunately, we can drop the anon folio checks now.
>
> This has low urgency, as it requires racing with, for example, a page
> fault in the private VMA, and migration is usually retried.
>
> Fixes: bf4916922c60 ("hugetlbfs: extend hugetlb_vma_lock to private VMAs")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

LGTM:

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

--
cheers,
jose a. p-a