From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH v1.3 15/19] mm/damon/core: implement damon_has_probe_weight()
Date: Fri, 10 Jul 2026 00:46:50 +0000 [thread overview]
Message-ID: <20260710004650.B09281F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710002349.111414-16-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] When probe weights are enabled, `damos_apply_target()` aggressively merges adjacent regions regardless of their `probe_hits`, permanently losing monitoring data.
- [High] Setting probe weights on unsupported operations backends (like DAMON_OPS_VADDR) silently disables all memory monitoring, breaking the DAMON core logic.
Pre-existing issues:
- [High] Calling `damon_call()` on an inactive DAMON context leads to an indefinite hang in `wait_for_completion()`, allowing a local DoS via sysfs.
--
--- Patch [15]: [RFC PATCH v1.3 15/19] mm/damon/core: implement damon_has_probe_weight() ---
commit 55c8b58c370f614fee60cf04b8ed7e90eb167302
Author: SJ Park <sj@kernel.org>
mm/damon/core: implement damon_has_probe_weight()
damon monitors only data attributes when probe weights are set.
However, the function for detecting it is intentionally returning false
always. Complete the mode detection function so that the mode can really
start working.
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 91964336ce31e..806a67d02a6e9 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -211,6 +211,12 @@ static struct damon_probe *damon_nth_probe(int n, struct damon_ctx *ctx)
>
> static bool damon_has_probe_weights(struct damon_ctx *c)
> {
> + struct damon_probe *p;
> +
> + damon_for_each_probe(p, c) {
> + if (p->weight)
> + return true;
[Severity: High]
Does returning true here cause adjacent regions to be aggressively merged in
damos_apply_target(), resulting in the loss of monitoring data?
When access_check_disabled becomes true, nr_accesses remains 0. In
damos_apply_target(), regions with identical nr_accesses and age are merged
to repair quota-induced splits:
mm/damon/core.c:damos_apply_target() {
...
prev_r->ar.end = r->ar.end;
damon_destroy_region(r, t);
...
}
Since damos_apply_target() unconditionally merges these regions without
combining the probe_hits arrays, does this permanently destroy the
fine-grained probe_hits data?
[Severity: High]
Can returning true here also silently disable memory monitoring if the
operations backend does not support probes?
If a backend like vaddr or fvaddr is used, damon_valid_probe_params() does
not verify if ctx->ops.apply_probes is implemented before allowing probe
weights.
When this function returns true, standard access checks are bypassed:
mm/damon/core.c:kdamond_fn() {
bool access_check_disabled = damon_has_probe_weights(ctx);
...
if (!access_check_disabled && ctx->ops.prepare_access_checks)
ctx->ops.prepare_access_checks(ctx);
}
Because ctx->ops.apply_probes is null, neither standard accesses nor probe
accesses are evaluated. Will the kdamond worker thread spin without
recording any memory activity?
> + }
> return false;
> }
[Severity: High]
This is a pre-existing issue, but is there a risk of an indefinite hang when
calling damon_call() from sysfs?
Looking at the sysfs store functions for reclaim and lru_sort, they invoke
damon_call() without verifying if the kdamond thread is actively running:
mm/damon/reclaim.c:damon_reclaim_commit_inputs_store() {
...
if (!ctx)
return -EINVAL;
err = damon_call(ctx, &control);
...
}
If commit_inputs is written to while the module is disabled, damon_call()
will enqueue the request and block indefinitely on wait_for_completion()
because there is no kdamond thread to process the queue. Could we check
damon_is_running() before calling damon_call()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260710002349.111414-1-sj@kernel.org?part=15
next prev parent reply other threads:[~2026-07-10 0:46 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 0:23 [RFC PATCH v1.3 00/19] mm/damon: introduce data attributes only monitoring SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 01/19] mm/damon/core: introduce damon_probe->weight SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 02/19] mm/damon/core: ask apply_probes() ops callback to set sampling address SJ Park
2026-07-10 0:33 ` sashiko-bot
2026-07-10 1:01 ` SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 03/19] mm/damon/paddr: set samples in apply_probes() if requested SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 04/19] mm/damon/core: ask apply_probe() to return max probe hits weighted sum SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 05/19] mm/damon/core: implement damon_probe_hits_wsum() SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 06/19] mm/damon/paddr: respect return_max_wsum SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 07/19] mm/damon/core: use abs_diff() instead of abs() SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 08/19] mm/damon/core: extend merge function to work with probe hits SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 09/19] mm/damon/core: disallow probe_hits overflow on attrs only monitoring SJ Park
2026-07-10 0:42 ` sashiko-bot
2026-07-10 1:02 ` SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 10/19] mm/damon/core: validate params for probe hits weighted sum overflow SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 11/19] mm/damon/core: disable access monitoring when probe weights are set SJ Park
2026-07-10 0:43 ` sashiko-bot
2026-07-10 1:08 ` SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 12/19] mm/damon/core: set samples in apply_probes() if " SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 13/19] mm/damon/core: s/max_nr_accesses/max_merge_score/ in kdamond_fn() SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 14/19] mm/damon/core: get merge threshold from probe hits when weights are set SJ Park
2026-07-10 0:38 ` sashiko-bot
2026-07-10 1:10 ` SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 15/19] mm/damon/core: implement damon_has_probe_weight() SJ Park
2026-07-10 0:46 ` sashiko-bot [this message]
2026-07-10 1:18 ` SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 16/19] mm/damon/sysfs: implement probe/weight file SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 17/19] Docs/mm/damon/design: document attrs-only monitoring SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 18/19] Docs/admin-guide/mm/damon/usage: document weight sysfs file SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 19/19] Docs/ABI/damon: document probe weight file 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=20260710004650.B09281F000E9@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