Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [RFC PATCH mm-hotfixes-unstable] mm/damon/core: do not update stat for core filter rejecting region
@ 2026-11-27 20:39 SJ Park
  0 siblings, 0 replies; only message in thread
From: SJ Park @ 2026-11-27 20:39 UTC (permalink / raw)
  Cc: SJ Park, stable, Andrew Morton, damon, linux-mm

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: <stable@vger.kernel.org> # 6.6.x
closes: https://sashiko.dev/#/bug/linux-9c51890e-a25c-4534-afab-ef33f22a9557
Signed-off-by: SJ Park <sj@kernel.org>
---
 mm/damon/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 0e6b361f97ea..e0ea93de100d 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2785,6 +2785,8 @@ 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;
 		if (damos_quota_is_set(quota) &&
 				quota->charged_sz + sz > quota->esz) {
 			sz = ALIGN_DOWN(quota->esz - quota->charged_sz,
@@ -2794,8 +2796,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: daba53bdc1a54c453c2f4ced54a1cd52416c3f87
-- 
2.47.3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-27 20:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 20:39 [RFC PATCH mm-hotfixes-unstable] mm/damon/core: do not update stat for core filter rejecting region SJ Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox