From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH v1.1 3/3] mm/damon/sysfs-schemes: set probe hits as pseudo moving sums
Date: Thu, 02 Jul 2026 17:32:07 +0000 [thread overview]
Message-ID: <20260702173207.ADACA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702171714.88278-4-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] damon_probe_hits_mvsum() returns an artificially inflated moving sum when left_window_bp == 10000 after an attribute update.
--
commit aa52db4de056d7c850beaa9ef06ec63a3befcbf2
Author: SJ Park <sj@kernel.org>
mm/damon/sysfs-schemes: set probe hits as pseudo moving sums
This commit updates the DAMON sysfs interface to expose probe hits using
a pseudo moving sum instead of incomplete counters. It uses
damon_probe_hits_mvsum() to calculate the value, similar to the logic
used for nr_accesses.
> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> index dbf2b0515d582..32f495a96b17a 100644
> --- a/mm/damon/sysfs-schemes.c
> +++ b/mm/damon/sysfs-schemes.c
> @@ -110,7 +110,8 @@ static int damos_sysfs_probes_add_dirs(struct damos_sysfs_probes *probes,
> struct damos_sysfs_probe *sys_probe;
> int err;
>
> - sys_probe = damos_sysfs_probe_alloc(region->probe_hits[i]);
> + sys_probe = damos_sysfs_probe_alloc(
> + damon_probe_hits_mvsum(i, region, ctx));
[Severity: Medium]
Can this result in an artificially inflated moving sum being exposed to
userspace?
Looking at damon_probe_hits_mvsum() in mm/damon/core.c:
mm/damon/core.c:damon_probe_hits_mvsum() {
...
return damon_mvsum(r->probe_hits[probe_idx],
r->last_probe_hits[probe_idx], left_window_bp);
}
When left_window_bp == 10000 after an attribute update, this calculates
current + last.
Because r->probe_hits is not cleared during attribute updates, the
un-cleared partial hits might be erroneously added to the previous
interval's hits. This function seems to lack the safeguard for this
condition that is present in damon_nr_accesses_mvsum().
If users query the stats immediately after an update, could this
silently overflow the unsigned char and expose incorrect statistics?
> if (!sys_probe) {
> damos_sysfs_probes_rm_dirs(probes);
> return -ENOMEM;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260702171714.88278-1-sj@kernel.org?part=3
next prev parent reply other threads:[~2026-07-02 17:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 17:17 [RFC PATCH v1.1 0/3] mm/damon: provide pseudo moving sum probe_hits SJ Park
2026-07-02 17:17 ` [RFC PATCH v1.1 1/3] mm/damon: add damon_region->last_probe_hits SJ Park
2026-07-02 17:29 ` sashiko-bot
2026-07-02 20:37 ` SJ Park
2026-07-02 17:17 ` [RFC PATCH v1.1 2/3] mm/damon/core: introduce damon_probe_hits_mvsum() SJ Park
2026-07-02 17:17 ` [RFC PATCH v1.1 3/3] mm/damon/sysfs-schemes: set probe hits as pseudo moving sums SJ Park
2026-07-02 17:32 ` sashiko-bot [this message]
2026-07-02 20:43 ` 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=20260702173207.ADACA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sj@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