[PATCH 1/2] mm/damon/core: use list_{next,prev}_entry() in damon_{next,prev}_region()

From: SJ Park

Date: Mon Nov 09 2026 - 20:06:27 EST


From: Enze Li <lienze@xxxxxxxxxx>

damon_next_region() and damon_prev_region() manually do container_of()
type casting to fetch the next and previous region from the linked
list. Use the dedicated list.h helpers, list_next_entry() and
list_prev_entry(), as damon_first_region() and damon_last_region() do.

Signed-off-by: Enze Li <lienze@xxxxxxxxxx>
Reviewed-by: SJ Park <sj@xxxxxxxxxx>
Signed-off-by: SJ Park <sj@xxxxxxxxxx>
---
Changes from v1
- v1: https://lore.kernel.org/20261103100714.70742-1-lienze@xxxxxxxxxx
- Collect R-b: from SJ.
- Rebase to the latest mm-new.

include/linux/damon.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 1302ffb6f0bcb..c32ef79c3acea 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -992,12 +992,12 @@ static inline unsigned long damon_rand(struct damon_ctx *ctx,

static inline struct damon_region *damon_next_region(struct damon_region *r)
{
- return container_of(r->list.next, struct damon_region, list);
+ return list_next_entry(r, list);
}

static inline struct damon_region *damon_prev_region(struct damon_region *r)
{
- return container_of(r->list.prev, struct damon_region, list);
+ return list_prev_entry(r, list);
}

static inline struct damon_region *damon_last_region(struct damon_target *t)
--
2.47.3