Re: [PATCH 09/21] mm/hugetlb: don't zap non-present entries when unmapping a folio
From: Muchun Song
Date: Wed Nov 25 2026 - 21:08:14 EST
> On Nov 26, 2026, at 06:33, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> From: Chris Mason <mason@xxxxxxxxxx>
>
> When the owner of a private hugetlb mapping fails to allocate a folio
> for COW, unmap_ref_private() unmaps the old folio from the forked
> children, and marks them with HPAGE_RESV_UNMAPPED, so they get a SIGBUS
> on their next access.
>
> hugetlb_unmap_range() is supposed to only unmap that folio, but it
> clears non-present page table entries unconditionally.
>
> A child can silently lose its COWed folio while it is getting migrated,
> or a hwpoison entry or uffd poison marker, without HPAGE_RESV_UNMAPPED
> getting set. Consequently, it would not SIGBUS on the next access.
>
> Let's fix it by ignoring non-present entries when unmapping a folio. As
> the folio is locked, migration entries of that folio do not apply.
>
> This has low urgency, as it requires a failing COW allocation in the
> owner racing with migration or memory failure in the child. Let's not CC
> stable.
>
> Fixes: 8c4894c6bc79 ("hwpoison, hugetlbfs: fix "bad pmd" warning in unmapping hwpoisoned hugepage")
> Signed-off-by: Chris Mason <mason@xxxxxxxxxx>
> [ david: adjust comment and description ]
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Reviewed-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>