From: SJ Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: SJ Park <sj@kernel.org>,
stable@vger.kernel.org, damon@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] mm/damon/ops-common: use nr_accesses moving sum for quota score
Date: Sun, 19 Jul 2026 09:11:33 -0700 [thread overview]
Message-ID: <20260719161136.90191-1-sj@kernel.org> (raw)
Since commit 42f994b71404 ("mm/damon/core: implement scheme-specific
apply interval"), DAMOS scheme can be applied at any time. At that
time, nr_accesses may not be fully aggregated. But the quota
prioritization score is calculated using the not fully aggregated count.
As a result, the performance of DAMOS could be degraded. Fix by using
damon_nr_accesses_mvsum() instead.
The user impact of the issue is suboptimum DAMOS performance under
certain setups. Nonetheless, the bug was there from the beginning of
the setup availability. In other words, the suboptimum performance is
the baseline of the setup and hence it didn't cause regression. Also
the extent of the suboptimality was not big enough to be found from
users and testers. Still, this is a clear bug that is better to be
fixed, and can be easily fixed.
Fixes: 42f994b71404 ("mm/damon/core: implement scheme-specific apply interval")
Cc: <stable@vger.kernel.org> # 6.7.x
Signed-off-by: SJ Park <sj@kernel.org>
---
Given the user impact, this is not an urgent hotfix in my opinion. But
this is still a clear bug fix that is better to eventually be merged
into stable kernels. Hence Cc-ing stable@.
Changes from RFC:
- RFC: https://lore.kernel.org/20260718180121.94759-1-sj@kernel.org
- Drop RFC tag.
- Rebase to the latest mm-new.
mm/damon/ops-common.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
index e59f5268d503c..d7d7f100389b0 100644
--- a/mm/damon/ops-common.c
+++ b/mm/damon/ops-common.c
@@ -111,8 +111,9 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r,
unsigned int age_weight = s->quota.weight_age;
int hotness;
- freq_subscore = r->nr_accesses * DAMON_MAX_SUBSCORE /
- damon_nr_samples_per_aggr(&c->attrs);
+ freq_subscore = mult_frac(damon_nr_accesses_mvsum(r, c),
+ DAMON_MAX_SUBSCORE,
+ damon_nr_samples_per_aggr(&c->attrs));
age_in_sec = (unsigned long)r->age * c->attrs.aggr_interval / 1000000;
if (age_in_sec)
base-commit: cd3ddd04256381e4874c14e644c9d263e323e777
--
2.47.3
reply other threads:[~2026-07-19 16:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260719161136.90191-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox