From: SJ Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SJ Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [RFC PATCH 2/6] mm/damon/core: s/accesses_bp_to_nr_accesses/sample_bp_to_count/
Date: Mon, 6 Jul 2026 22:02:02 -0700 [thread overview]
Message-ID: <20260707050204.102256-1-sj@kernel.org> (raw)
In-Reply-To: <20260707044906.CF30C1F000E9@smtp.kernel.org>
On Tue, 07 Jul 2026 04:49:06 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] 32-bit integer overflow in conversions between basis points (bp) and sample counts due to large number of samples per aggregation interval.
> --
>
> --- Patch [2]: [RFC PATCH 2/6] mm/damon/core: s/accesses_bp_to_nr_accesses/sample_bp_to_count/ ---
> commit 26f76c0115cf94c7177c6588b38ff64dabf63ab2
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/core: s/accesses_bp_to_nr_accesses/sample_bp_to_count/
>
> This commit renames accesses_bp_to_nr_accesses() to
> damon_sample_bp_to_count() to better reflect that it converts a samples ratio
> (in basis points) to a count. It also updates the callsites and comments to
> match the new name.
>
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index e710e2789085e..ca530faaa4f83 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> > @@ -876,11 +876,11 @@ static unsigned int damon_age_for_new_attrs(unsigned int age,
> > return age * old_attrs->aggr_interval / new_attrs->aggr_interval;
> > }
> >
> > -/* convert access ratio in bp (per 10,000) to nr_accesses */
> > -static unsigned int damon_accesses_bp_to_nr_accesses(
> > - unsigned int accesses_bp, struct damon_attrs *attrs)
> > +/* convert sample ratio in bp (per 10,000) to count */
> > +static unsigned int damon_sample_bp_to_count(
> > + unsigned int bp, struct damon_attrs *attrs)
> > {
> > - return accesses_bp * damon_nr_samples_per_aggr(attrs) / 10000;
> > + return bp * damon_nr_samples_per_aggr(attrs) / 10000;
>
> [Severity: High]
> This isn't a bug introduced by this patch, but can the product of bp and
> damon_nr_samples_per_aggr() overflow 32 bits?
>
> Since both bp and the return value of damon_nr_samples_per_aggr() are 32-bit
> unsigned integers, their product can exceed 32 bits if the number of samples
> per aggregation interval is large (greater than ~429,496).
>
> For example, a 1ms sample interval and a 10-minute aggregation interval would
> result in 600,000 samples. If bp is 10,000 (100%), the multiplication
> 10,000 * 600,000 overflows 32 bits to 1,705,032,704, resulting in a truncated
> count of 170,503 instead of 600,000.
>
> A similar overflow can occur in damon_nr_accesses_to_accesses_bp() when
> evaluating (nr_accesses % nr_samples) * 10000 inside mult_frac() for large
> nr_accesses values, falsely marking hot memory as cold.
Known low priority issue.
>
> > }
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260707043828.97900-1-sj@kernel.org?part=2
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-07-07 5:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 4:38 [RFC PATCH 0/6] mm/damon: update probe hits for runtime parameter commits SJ Park
2026-07-07 4:38 ` [RFC PATCH 1/6] mm/damon/core: s/damon_max_nr_accesses()/damon_nr_samples_per_aggr()/ SJ Park
2026-07-07 4:48 ` sashiko-bot
2026-07-07 5:01 ` SJ Park
2026-07-07 4:38 ` [RFC PATCH 2/6] mm/damon/core: s/accesses_bp_to_nr_accesses/sample_bp_to_count/ SJ Park
2026-07-07 4:49 ` sashiko-bot
2026-07-07 5:02 ` SJ Park [this message]
2026-07-07 4:38 ` [RFC PATCH 3/6] mm/damon/core: s/nr_accesses_to_accesses_bp/sample_count_to_bp/ SJ Park
2026-07-07 4:45 ` sashiko-bot
2026-07-07 5:07 ` SJ Park
2026-07-07 4:38 ` [RFC PATCH 4/6] mm/damon/core: s/nr_accesses_for_new_attrs/nr_samples_for_new_attrs/ SJ Park
2026-07-07 4:50 ` sashiko-bot
2026-07-07 5:08 ` SJ Park
2026-07-07 4:38 ` [RFC PATCH 5/6] mm/damon/core: update probe hits for new parameter commit SJ Park
2026-07-07 4:51 ` sashiko-bot
2026-07-07 5:09 ` SJ Park
2026-07-07 4:38 ` [RFC PATCH 6/6] mm/damon/core: handle unreset probe_hits in probe_hits_mvsum() 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=20260707050204.102256-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=damon@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox