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

From: SeongJae Park

Date: Thu Mar 05 2026 - 00:39:34 EST


'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 same as the
expected one, but 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@xxxxxxxxxx>
---
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 de38f2356b72b..db388d05cac3f 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3056,7 +3056,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