[PATCH 24/60] mm/madvise: restrict reclaim advice to common memory
From: Gregory Price via B4 Relay
Date: Fri Nov 20 2026 - 13:15:02 EST
From: "Gregory Price (Meta)" <gourry@xxxxxxxxxx>
MADV_COLD and MADV_PAGEOUT age or reclaim the folios a caller names,
and MADV_FREE marks them lazyfree, whatever node they are on.
Restrict them to common memory: convert their ZONE_DEVICE checks,
including the one in madvise_free_huge_pmd(), to
folio_is_common_memory().
Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
---
mm/huge_memory.c | 2 +-
mm/madvise.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 75e8641bf9ff..cae28513b121 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2452,7 +2452,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
folio = pmd_folio(orig_pmd);
- if (folio_is_zone_device(folio))
+ if (!folio_is_common_memory(folio))
goto out;
/*
diff --git a/mm/madvise.c b/mm/madvise.c
index 2d54cb9863ea..0f1648526f15 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -404,7 +404,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
if (!folio)
goto huge_unlock;
- if (folio_is_zone_device(folio))
+ if (!folio_is_common_memory(folio))
goto huge_unlock;
/* Do not interfere with other mappings of this folio */
@@ -485,7 +485,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
continue;
folio = vm_normal_folio(vma, addr, ptent);
- if (!folio || folio_is_zone_device(folio))
+ if (!folio || !folio_is_common_memory(folio))
continue;
/*
@@ -715,7 +715,7 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
}
folio = vm_normal_folio(vma, addr, ptent);
- if (!folio || folio_is_zone_device(folio))
+ if (!folio || !folio_is_common_memory(folio))
continue;
/*
--
2.56.1