[PATCH v2 2/3] mm/madvise: skip zone device folios in cold/pageout PMD range
From: Gregory Price
Date: Mon Aug 17 2026 - 18:11:41 EST
madvise_cold_or_pageout_pte_range() resolves the folio backing a PMD
via pmd_folio() and ages or reclaims it without checking for zone
device memory.
The surrounding guards do not cover every zone device case:
- can_madv_lru_vma() excludes VM_PFNMAP and VM_HUGETLB VMAs
(so device DAX is filtered)
- !pmd_present() branch above rejects device-private and
migration entries, which are non-present.
- A present zone device PMD - e.g. a device-coherent THP - is
not filtered by any of these, nor by pmd_folio() (unlike
vm_normal_page_pmd(), it performs no special/pfnmap check),
and would be aged or paged out here.
Skip ZONE_DEVICE folios explicitly during MADV_COLD/PAGEOUT.
Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
---
mm/madvise.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/madvise.c b/mm/madvise.c
index c179938097bf0..2151bb9468594 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -396,6 +396,9 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
folio = pmd_folio(orig_pmd);
+ if (folio_is_zone_device(folio))
+ goto huge_unlock;
+
/* Do not interfere with other mappings of this folio */
if (folio_maybe_mapped_shared(folio))
goto huge_unlock;
--
2.53.0-Meta