Re: [PATCH 23/60] mm/damon: restrict DAMON-native folio operations to common memory
From: Yury Norov
Date: Sun Nov 22 2026 - 11:48:02 EST
On Fri, Nov 20, 2026 at 01:09:14PM -0500, Gregory Price via B4 Relay wrote:
> From: "Gregory Price (Meta)" <gourry@xxxxxxxxxx>
>
> DAMON acquires folios to age them, check their accesses, and apply LRU
> operations and migration. Treat these as general-purpose MM services
> and restrict them to N_MEMORY_COMMON.
>
> Memory outside N_MEMORY_COMMON can still hold ordinary LRU folios, so
> it would pass the checks that keep ZONE_DEVICE memory out of these
> operations.
>
> Treat these folios like ZONE_DEVICE memory.
>
> DAMON cannot acquire such a folio, so it never ages one and virtual
> address monitoring reports it as accessed, and DAMOS cannot isolate
> one for migration.
>
> Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
> ---
> mm/damon/ops-common.c | 5 +++--
> mm/damon/vaddr.c | 2 +-
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
> index 15cabc79613b..57201a0c5e3a 100644
> --- a/mm/damon/ops-common.c
> +++ b/mm/damon/ops-common.c
> @@ -17,8 +17,9 @@
>
> static bool damon_folio_acceptable(struct folio *folio, bool monitor)
> {
> - return folio_test_lru(folio) ||
> - (monitor && folio_test_hugetlb(folio));
> + return folio_is_common_memory(folio) &&
> + (folio_test_lru(folio) ||
> + (monitor && folio_test_hugetlb(folio)));
Can you minimize the diff? That would also improve on readability IMO:
if (!folio_is_common_memory())
return false;
return folio_test_lru(folio) ||
(monitor && folio_test_hugetlb(folio));
> }
>
> /*
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index 1e65e7651cd9..338876559140 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -830,7 +830,7 @@ static void damos_va_migrate_dests_add(struct folio *folio,
> if (folio_nid(folio) == nid)
> return;
>
> - if (!folio_isolate_lru(folio))
> + if (!folio_is_common_memory(folio) || !folio_isolate_lru(folio))
> return;
> node_stat_add_folio(folio, NR_ISOLATED_ANON +
> folio_is_file_lru(folio));
>
> --
> 2.56.1
>