Re: [RFC PATCH v1.1 3/9] mm/damon/paddr: respect folio end for DAMOS_STAT

[email protected] Sun, 02 Aug 2026 16:34:57 +0000
Newsgroups dev.linux.lists.damon
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(=
s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch provid=
es an incomplete fix for an address advancement logic bug. While it correct=
s the `addr +=3D folio_size(folio)` issue in `damon_pa_stat()` to correctly=
 align the next address to the end of the large folio, it fails to apply th=
e exact same fix to `damon_pa_pageout()`, `damon_pa_de_activate()`, and `da=
mon_pa_migrate()`.
--

--- Patch [3]: [RFC PATCH v1.1 3/9] mm/damon/paddr: respect folio end for D=
AMOS_STAT ---
commit 99e0c032eda9c903df8d327aa77b989129d9b193
Author: SJ Park <[email protected]>

mm/damon/paddr: respect folio end for DAMOS_STAT

This commit fixes the address advancement in damon_pa_stat(). When a region
starts in the middle of a large folio, it now properly aligns to the start =
of
the next folio instead of simply adding the folio size and overshooting.

> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
> --- a/mm/damon/paddr.c
> +++ b/mm/damon/paddr.c
> @@ -379,7 +379,7 @@ static unsigned long damon_pa_stat(struct damon_regio=
n *r,
> =20
>  		if (!damos_pa_filter_out(s, folio))
>  			*sz_filter_passed +=3D folio_size(folio) / addr_unit;
> -		addr +=3D folio_size(folio);
> +		addr =3D PFN_PHYS(folio_pfn(folio)) + folio_size(folio);

[Severity: High]
This isn't a bug introduced by this patch, but does the same address
advancement logic regression still exist in other DAMON actions?

While you fixed the overshoot behavior here in damon_pa_stat(), it looks li=
ke
damon_pa_pageout(), damon_pa_de_activate(), and damon_pa_migrate() in
mm/damon/paddr.c might still be using the flawed logic.

For example, in damon_pa_pageout():

    put_folio:
		addr +=3D folio_size(folio);
		folio_put(folio);

Could this cause DAMON actions to silently skip sections of valid memory
if a region starts in the middle of a large folio?

>  		folio_put(folio);
>  	}
>  	s->last_applied =3D folio;

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260802162631.9030=
[email protected]?part=3D3