[PATCH 1/5] mm/damon/core: fix wrong end address assignment on walk_system_ram()

SeongJae Park
2026-03-11T05:29:31Z

'struct damon_addr_range' and 'struct resource' represent different
types of address ranges. 'damon_addr_range' is for end-open ranges
([start, end)). 'resource' is for fully-closed ranges ([start, end]).
But walk_system_ram() is assigning resource->end to
damon_addr_range->end without the inclusiveness adjustment. As a
result, the function returns an address range that is missing the last
one byte.

The function is being used to find and set the biggest system ram as the
default monitoring target for DAMON_RECLAIM and DAMON_LRU_SORT. Missing
the last byte of the big range shouldn't be a real problem for the real
use cases. That said, the loss is definitely an unintended behavior.
Do the correct adjustment.

Fixes: 43b0536cb471 ("mm/damon: introduce DAMON-based Reclamation (DAMON_RECLAIM)")
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 2e36024d99506..3925720a172a6 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3060,7 +3060,7 @@ static int walk_system_ram(struct resource *res, void *arg)

if (a->end - a->start < resource_size(res)) {
a->start = res->start;
- a->end = res->end;
+ a->end = res->end + 1;
}
return 0;
}
--
2.47.3