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

SJ Park <[email protected]>
Newsgroups dev.linux.lists.damon,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
On Fri, 14 Aug 2026 22:54:09 +0800 Enze Li <[email protected]> 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

[...]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.