From: SJ Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SJ Park <sj@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
damon@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [PATCH 2/2] mm/damon/ops-common: use probe hits weighted sum in damon_hot_score()
Date: Thu, 3 Dec 2026 07:45:08 -0800 [thread overview]
Message-ID: <20261203154509.733967-1-sj@kernel.org> (raw)
In-Reply-To: <sashiko-outbox-248130@kernel.org>
On Thu, 03 Dec 2026 15:37:44 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] mm/damon: 32-bit overflow in mult_frac() inside
> damon_freq_subscore()
> --
>
> commit 3b171ba030ec37fe884a6ae50ff0018c6075df31
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/ops-common: use probe hits weighted sum in damon_hot_score()
>
> This commit adds damon_freq_subscore() so damon_hot_score() uses the
> weighted sum of probe hits instead of nr_accesses when probe weights are
> configured.
>
> > diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
> > index 38720794c9fcf..adbdba6dc6da0 100644
> > --- a/mm/damon/ops-common.c
> > +++ b/mm/damon/ops-common.c
> > @@ -165,6 +165,25 @@ void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
> > #define DAMON_MAX_SUBSCORE (100)
> > #define DAMON_MAX_AGE_IN_LOG (32)
> >
> > +static int damon_freq_subscore(struct damon_ctx *c,
> > + struct damon_region *r)
> > +{
> > + unsigned int num, denom, samples_per_aggr;
> > + struct damon_probe *p;
> > +
> > + samples_per_aggr = damon_nr_samples_per_aggr(&c->attrs);
> > + if (damon_has_probe_weights(c)) {
> > + num = damon_probe_hits_wsum(r, false, true, c);
> > + denom = 0;
> > + damon_for_each_probe(p, c)
> > + denom += samples_per_aggr * p->weight;
> > + } else {
> > + num = damon_nr_accesses_mvsum(r, c);
> > + denom = samples_per_aggr;
> > + }
> > + return mult_frac(num, DAMON_MAX_SUBSCORE, denom);
> > +}
>
> [Severity: Medium]
> As reported by Aveline Noir on RFC v3 [1], can mult_frac() overflow 32-bit
> arithmetic here?
As we discussed on the thread, it is difficult to think this as a real issue.
No blocker in my opinion.
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-12-03 15:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 15:13 [PATCH 0/2] mm/damon: aware attr-only mode in DAMOS quota region selection SJ Park
2026-12-03 15:13 ` [PATCH 1/2] mm/damon/core: expose damon_has_probe_weights() SJ Park
2026-12-03 18:44 ` + mm-damon-core-expose-damon_has_probe_weights.patch added to mm-new branch Andrew Morton
2026-12-03 15:13 ` [PATCH 2/2] mm/damon/ops-common: use probe hits weighted sum in damon_hot_score() SJ Park
2026-12-03 15:37 ` sashiko-bot
2026-12-03 15:45 ` SJ Park [this message]
2026-12-03 18:44 ` + mm-damon-ops-common-use-probe-hits-weighted-sum-in-damon_hot_score.patch added to mm-new branch Andrew Morton
2026-12-03 15:37 ` [PATCH 0/2] mm/damon: aware attr-only mode in DAMOS quota region selection sashiko-bot
2026-12-03 15:46 ` SJ Park
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=20261203154509.733967-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-mm@kvack.org \
--cc=sashiko-bot@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.