Re: [PATCH] mm/damon/stat: avoid iterating targets in damon_stat_sort_regions()

From: SJ Park

Date: Fri Aug 14 2026 - 20:48:13 EST


On Fri, 14 Aug 2026 22:54:09 +0800 Enze Li <lienze@xxxxxxxxxx> wrote:

> damon/stat module creates only one target in damon_stat_build_ctx(), and
> the comment in damon_stat_sort_regions() already says so. But the code
> still iterates adaptive_targets with damon_for_each_target(), which is
> needlessly verbose and adds an extra indentation level.
>
> Just use list_first_entry() to grab the single target, with a
> list_empty() check to be safe.

damon_ctx->adaptive_targetes is a private field. DAMON API callers should
access the field using only public API that exposed on damon.h. Let's not do
this.

If the verboseness and the indentation are problems, let's split out the code
to a function.


Thanks,
SJ

[...]