Re: [PATCH v2 14/47] mm/huge_memory: fix zapping migration entries for device-private THPs

From: Gregory Price (Meta)

Date: Thu Oct 29 2026 - 18:33:51 EST


On 2026-10-29 21:33 +0100, David Hildenbrand (Arm) wrote:
> From: Chris Mason <mason@xxxxxxxxxx>
>
> A PMD migration entry can refer to a device-private folio.
> zap_huge_pmd_folio() checks the folio type instead of the entry type,
> so it treats such a migration entry as a device-private entry.
>
> Installing the migration entry already removed the reverse mapping and
> dropped the mapping reference. Zapping it must not repeat those
> operations. Concurrent MADV_DONTNEED during migration back to system
> memory can trigger this.
>
> Check the PMD entry type using pmd_is_device_private_entry().
>
> Fix generated by an LLM and sent by Chris Mason in private.
>
> Fixes: 368076f52ebe ("mm/huge_memory: add device-private THP support to PMD operations")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Chris Mason <mason@xxxxxxxxxx>
> [ david: simplify description ]
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

One note below, but it's not a holdup.

Reviewed-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>

> + const bool is_device_private = !is_present && pmd_is_device_private_entry(pmdval);

pmd_is_device_private_entry() already returns false for a present
pmdval - so !is_present is redundant. If there was a reason to open
code this, then keep it, but otherwise you could drop it.

--
~Gregory