damos_apply_scheme() update stats for regions that were unable to apply the scheme due to the quota. Those are counted as tried and failed. It doesn't update stats for regions that were rejected by DAMOS core filters. Those are counted as not tried at all. However, the DAMOS quota-driven failure is handled before DAMOS core filters. Regions that would be rejected by the core filter can, hence, be accounted as tried and failed. As a result, users could show confusing stat changes. Fix by handling core filters before quotas. The user impact is not critical. No crash or leak happens. Only the DAMOS stat could occasionally move in an unexpected way. Fixes: ab9bda001b68 ("mm/damon/core: introduce address range type damos filter") Cc: # 6.6.x Closes: https://sashiko.dev/#/bug/linux-9c51890e-a25c-4534-afab-ef33f22a9557 Signed-off-by: SJ Park --- Changes from RFC - RFC: https://lore.kernel.org/20261127203938.94339-1-sj@kernel.org - Update 'sz' in damos_apply_scheme() after the core filter handling. - Rebase to latest mm-hotfixes-unstable. mm/damon/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 0e6b361f97ea..38444a9f0500 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -2785,6 +2785,9 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, } if (c->ops.apply_scheme) { + if (damos_core_filter_out(c, t, r, s)) + return; + sz = damon_sz_region(r); if (damos_quota_is_set(quota) && quota->charged_sz + sz > quota->esz) { sz = ALIGN_DOWN(quota->esz - quota->charged_sz, @@ -2794,8 +2797,6 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, if (damon_split_region_at(t, r, sz)) goto update_stat; } - if (damos_core_filter_out(c, t, r, s)) - return; sz = damon_sz_region(r); ktime_get_coarse_ts64(&begin); trace_damos_before_apply(cidx, sidx, tidx, r, nr_accesses, base-commit: ba13b07abc534725a32302825071f2c6bd26b033 -- 2.47.3