Re: [PATCH] mm/damon/vaddr: remove redundant RCU lock

From: SJ Park

Date: Tue Jun 30 2026 - 10:54:33 EST


On Tue, 30 Jun 2026 17:25:22 +0300 Igor Putko <igorpetindev@xxxxxxxxx> wrote:

> Hi SJ,
>
> Thanks for the reply and the pointers!

Thank you for quick reply. Nonetheless, from the next time, please reply to a
mail you are replying to, without top-posting [1]. Also, please wrap long
lines for reasonable length of columns (say, 80 columns?)

> Regarding the issue Sashiko AI flagged - I dug into damon/vaddr.c, and I think it's a real bug, but it's isolated to __damon_va_three_regions().
> damon_va_walk_page_range() is fine here, since lock_vma_under_rcu() handles stability on its own. __damon_va_three_regions() is the problematic one: right after mmap_read_lock(mm) is taken in the caller, it sets up a VMA_ITERATOR and runs for_each_vma(). But mmap_read_lock doesn't stop the OOM reaper from running concurrently, setting MMF_UNSTABLE, and leaving empty markers in the maple tree. Walking the tree in that state without a check_stable_address_space(mm) call could lead to a NULL pointer dereference.

Thank you for detailed explanation.

> Since this looks like a separate issue, I'll prepare a dedicated fix and send it as its own patch thread, so it doesn't hold up the current cleanup. Let me know if that approach works for you.

Makes sense!

[1] https://subspace.kernel.org/etiquette.html


Thanks,
SJ

[...]