All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Liew Rui Yan" <aethernet65535@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH v2 1/3] docs/mm/damon/design: accurate semantics of nr_snapshots
Date: Wed, 12 Aug 2026 10:47:19 +0000	[thread overview]
Message-ID: <20260812104719.D72F81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812104002.15225-2-aethernet65535@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The commit updates documentation to match buggy code behavior rather than fixing the underlying logical flaws in the `nr_snapshots` counter. `nr_snapshots` incorrectly increments per target instead of per snapshot, and skips entirely when quotas are full.
--

--- Patch [1]: [PATCH v2 1/3] docs/mm/damon/design: accurate semantics of nr_snapshots ---
commit 11b4a9c760b881c063ff5e1eec0248b087d6a31f
Author: Liew Rui Yan <aethernet65535@gmail.com>

docs/mm/damon/design: accurate semantics of nr_snapshots

This commit updates the DAMON design documentation and header comments
to align the description of nr_snapshots with the current behavior
implemented in the code.

> diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
> index aed6cb1cf4831..1739aeec6eb95 100644
> --- a/Documentation/mm/damon/design.rst
> +++ b/Documentation/mm/damon/design.rst
> @@ -846,8 +846,8 @@ scheme's execution.
[ ... ]
>  - ``qt_exceeds``: Total number of times the quota of the scheme has exceeded.
> -- ``nr_snapshots``: Total number of DAMON snapshots that the scheme is tried to
> -  be applied.
> +- ``nr_snapshots``: Total number of DAMON snapshots that the scheme is
> +  completely tried to be applied.
>  - ``max_nr_snapshots``: Upper limit of ``nr_snapshots``.

[Severity: High]
This is a pre-existing issue, but does updating the documentation to match
the code behavior paper over an underlying logical flaw in the nr_snapshots
counter?

Looking at damon_do_apply_schemes() in mm/damon/core.c, the counter updates
like this:

mm/damon/core.c:damon_do_apply_schemes() {
    ...
        /* Check the quota */
        if (damos_quota_is_full(quota, c->min_region_sz))
            continue;
    ...
        if (damon_is_last_region(r, t))
            s->stat.nr_snapshots++;
    ...
}

Because this increments at the last region of a target, if multiple targets
are present, does the counter incorrectly increment per target instead of
per snapshot?

Additionally, if a restrictive quota fills up before the last region of a
target is processed, the early continue skips the counter increment entirely.
This could mean a scheme configured with a max_nr_snapshots limit might
never reach its limit.

Should the underlying code be fixed to increment once per snapshot regardless
of quotas and targets, rather than updating the documentation to reflect this
behavior?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812104002.15225-1-aethernet65535@gmail.com?part=1

  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 [this message]
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
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=20260812104719.D72F81F000E9@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 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.