Re: [PATCH] mm/damon/core: reject zero sample_interval

SJ Park <[email protected]> Wed, 22 Jul 2026 07:01:13 -0700
Newsgroups dev.linux.lists.damon
Message-ID <[email protected]>
Hello liyouhong,


Thank you for sharing this patch!

On Wed, 22 Jul 2026 17:43:04 +0800 [email protected] wrote:

> From: liyouhong <[email protected]>
> 
> damon_set_attrs() allows sample_interval == 0.  Sysfs likewise accepts
> sample_us=0.  kdamond_fn() then calls kdamond_usleep(0) every loop
> iteration, so kdamond busy-spins and can peg a CPU.
> 
> With a zero sampling interval the access-rate accounting also diverges:
> nr_accesses_bp no longer matches nr_accesses * 10000, and
> kdamond_reset_aggregated() hits:
> 
>   WARNING: invalid nr_accesses_bp at reset: ...

The warning has removed by nr_accesses_bp optimization patch series, which is
currently queued for 7.3-rc1.  So the warning will not be triggered on near
future mainline.
> 
> Reject sample_interval == 0 in damon_set_attrs(), which covers sysfs
> commit and other callers.  damon_lru_sort already refused a zero
> sample_interval; align the core validation with that.

This is a sort of behavioral change.  I also feel this adds another corner case
that makes my head complicated.  There are a few logic written under the
assumption of zero intervals.  Having inconsistencies between allowed input and
handling logic will make it difficult to maintain in long term.  Can't we keep
supporting zero sample interval and fix the warning or the real bug instead?

[1] https://lore.kernel.org/[email protected]


Thanks,
SJ

[...]