Re: [PATCH] mm/damon/ops-common: ignore migration request to invalid nodes

From: SeongJae Park
Date: Mon Jul 21 2025 - 12:30:49 EST


On Mon, 21 Jul 2025 08:28:26 -0700 Joshua Hahn <joshua.hahnjy@xxxxxxxxx> wrote:

> On Sun, 20 Jul 2025 11:58:22 -0700 SeongJae Park <sj@xxxxxxxxxx> wrote:
>
> > damon_migrate_pages() try migration even if the target node is invalid.
> > If users mistakenly make such invalid requests via
> > DAMOS_MIGRATE_{HOT,COLD} action, below kernel BUG can happen.
[...]
> > Add a target node validity check in damon_migrate_pages(). The validity
> > check is stolen from that of do_pages_move(), which is being used for
> > move_pages() system call.
> >
> > Fixes: b51820ebea65 ("mm/damon/paddr: introduce DAMOS_MIGRATE_COLD action for demotion") # 6.11.x
> > Cc: stable@xxxxxxxxxxxxxxx
> > Cc: Honggyu Kim <honggyu.kim@xxxxxx>
> > Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
> > ---
>
> LGTM, thank you SJ!
>
> On a side note... This seems like it would be a common check. However, doing a
> (quick) search seems to return no function that checks whether a node is valid.
> Perhaps it would make sense to look deeper and see how many other functions
> make this check, and export this as a function? I can try spinning something
> if it makes sense to you : -)

My humble impression was that this check is short enough to be ok to be
open-coded, but please don't be blocked on my opinion :)

>
> Reviewed-by: Joshua Hahn <joshua.hahnjy@xxxxxxxxx>

Thank you!

>
> Sent using hkml (https://github.com/sjp38/hackermail)

Thanks,
SJ