Re: [PATCH 2/4] mm/huge_memory: skip zone device folios in madvise_free_huge_pmd()

From: David Hildenbrand (Arm)

Date: Thu Aug 06 2026 - 09:38:14 EST


On 7/28/26 21:47, Gregory Price wrote:
> madvise_free_huge_pmd() resolves the folio backing a PMD via pmd_folio()
> and marks it lazyfree without checking for zone device memory.
>
> The surrounding guards do not cover every zone device case:
> - MADV_FREE only operates on anonymous VMAs (DAX mappings are excluded)
>
> - !pmd_present() branch rejects device-private and migration entries
>
> - present zone device PMD (device coherent THP) is not filtered.
> Unlike vm_normal_page_pmd(), it performs no special/pfnmap check,
> and would be marked lazyfree here.
>
> Bail out when the folio is a zone device folio.
>
> Fixes: 368076f52ebe ("mm/huge_memory: add device-private THP support to PMD operations")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
> ---

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David