Re: [RFC PATCH 1/2] mm/damon/lru_sort: avoid divide-by-zero in damon_lru_sort_apply_parameters()

From: SeongJae Park
Date: Tue Aug 26 2025 - 10:43:50 EST


On Tue, 26 Aug 2025 11:36:52 +0800 Quanmin Yan <yanquanmin1@xxxxxxxxxx> wrote:

> During the calculation of 'hot_thres' and 'cold_thres', either
> 'sample_interval' or 'aggr_interval' is used as the divisor,
> which may lead to division-by-zero errors. Fix it by directly
> returning -EINVAL when such a case occurs. Additionally, since
> 'aggr_interval' is already required to be set no smaller than
> 'sample_interval' in damon_set_attrs(), only the case where
> 'sample_interval' is zero needs to be checked.

Nice catch and fix!

>
> Fixes: 40e983cca927 ("mm/damon: introduce DAMON-based LRU-lists Sorting")

Let's add Cc: stable@

> Signed-off-by: Quanmin Yan <yanquanmin1@xxxxxxxxxx>

Reviewed-by: SeongJae Park <sj@xxxxxxxxxx>


Thanks,
SJ

[...]