From: sashiko-bot@kernel.org
To: "Liew Rui Yan" <aethernet65535@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH v2 2/3] docs/mm/damon/design: difference between watermarks and nr_snapshots
Date: Wed, 12 Aug 2026 10:47:25 +0000 [thread overview]
Message-ID: <20260812104725.A567E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812104002.15225-3-aethernet65535@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but `nr_snapshots` is incorrectly incremented per target instead of per snapshot, and skips incrementing entirely if the scheme bypasses the final region of a target.
--
--- Patch [2]: [PATCH v2 2/3] docs/mm/damon/design: difference between watermarks and nr_snapshots ---
commit af16039fca7bbda3290262311f6015d553f6c65f
Author: Liew Rui Yan <aethernet65535@gmail.com>
docs/mm/damon/design: difference between watermarks and nr_snapshots
Explain the difference between nr_snapshots reaches max_nr_snapshots and
watermarks.
> diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
> index 1739aeec6eb95..e7977f005ac06 100644
> --- a/Documentation/mm/damon/design.rst
> +++ b/Documentation/mm/damon/design.rst
> @@ -872,7 +872,8 @@ the action to the region will fail.
>
> Unlike normal stats, ``max_nr_snapshots`` is set by users. If it is set as
> non-zero and ``nr_snapshots`` be same to or greater than ``nr_snapshots``, the
> -scheme is deactivated.
> +scheme is deactivated. Note that, unlike watermarks, even if a scheme's
> +``nr_snapshots`` reaches ``max_nr_snapshots``, monitoring will not stop.
[Severity: High]
This isn't a bug introduced by this patch, but while documenting the
nr_snapshots behavior, I noticed an issue in how nr_snapshots is incremented
in the core code.
Looking at damon_do_apply_schemes() in mm/damon/core.c, nr_snapshots is
incremented per target instead of per snapshot:
if (damos_quota_is_full(quota, c->min_region_sz))
continue;
if (damos_skip_charged_region(t, r, s, c->min_region_sz))
continue;
...
if (damon_is_last_region(r, t))
s->stat.nr_snapshots++;
Could this cause the scheme to incorrectly increment multiple times per
snapshot if there are multiple monitoring targets?
Also, if damos_quota_is_full() or damos_skip_charged_region() triggers a
continue on the target's last region, does this bypass the increment entirely?
If a scheme frequently exhausts its quota, it seems nr_snapshots might never
increment, causing the scheme to run forever without reaching
max_nr_snapshots.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260812104002.15225-1-aethernet65535@gmail.com?part=2
next prev parent reply other threads:[~2026-08-12 10:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 10:39 [PATCH v2 0/3] docs/mm/damon/design: add explanation of nr_snapshots Liew Rui Yan
2026-08-12 10:40 ` [PATCH v2 1/3] docs/mm/damon/design: accurate semantics " Liew Rui Yan
2026-08-12 10:47 ` sashiko-bot
2026-08-12 13:42 ` SJ Park
2026-08-12 10:40 ` [PATCH v2 2/3] docs/mm/damon/design: difference between watermarks and nr_snapshots Liew Rui Yan
2026-08-12 10:47 ` sashiko-bot [this message]
2026-08-12 13:44 ` SJ Park
2026-08-12 10:40 ` [PATCH v2 3/3] docs/mm/damon/design: fix typo of max_nr_snapshots Liew Rui Yan
2026-08-12 10:42 ` sashiko-bot
2026-08-12 13:37 ` [PATCH v2 0/3] docs/mm/damon/design: add explanation of nr_snapshots 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=20260812104725.A567E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aethernet65535@gmail.com \
--cc=damon@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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