Re: [PATCH 1/4] mm/damon: defensively skip zone device folios in damon_get_folio()

"Lorenzo Stoakes (ARM)" <[email protected]>
Newsgroups dev.linux.lists.damon,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <anSOKjTerc97fCGx@lucifer>
On Tue, Jul 28, 2026 at 03:47:11PM -0400, Gregory Price wrote:
> All DAMON physical- and virtual-address operations obtain their folios
> through damon_get_folio(). That helper already excludes ZONE_DEVICE
> memory implicitly via pfn_to_online_page() and folio_test_lru(), but
> this is inconsistent with other callers in mm/ which test explicitly.
>
> Add an explicit folio_is_zone_device() rejection in damon_get_folio()
> so the guarantee lives in one place and covers every caller uniformly,
> consistent with other mm walkers that reject zone device folios.
>
> Signed-off-by: Gregory Price (Meta) <[email protected]>

Thanks, nice to make it explicit!

Acked-by: Lorenzo Stoakes (ARM) <[email protected]>

> ---
>  mm/damon/ops-common.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
> index d7d7f100389b..d8bca7355b4f 100644
> --- a/mm/damon/ops-common.c
> +++ b/mm/damon/ops-common.c
> @@ -32,7 +32,8 @@ struct folio *damon_get_folio(unsigned long pfn)
>  	folio = page_folio(page);
>  	if (!folio_try_get(folio))
>  		return NULL;
> -	if (unlikely(page_folio(page) != folio) || !folio_test_lru(folio)) {
> +	if (unlikely(page_folio(page) != folio) || !folio_test_lru(folio) ||
> +	    folio_is_zone_device(folio)) {
>  		folio_put(folio);
>  		folio = NULL;
>  	}
> --
> 2.55.0
>

--
Cheers, Lorenzo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.