From: sashiko-bot@kernel.org
To: "SeongJae Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 1/2] mm/damon/reclaim: add autotune_monitoring_intervals parameter
Date: Fri, 01 May 2026 01:30:43 +0000 [thread overview]
Message-ID: <20260501013044.7DC96C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260501011740.81988-2-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Validation check on `damon_reclaim_mon_attrs.aggr_interval` prematurely rejects configurations when autotuning is enabled, and exposes a TOCTOU divide-by-zero panic.
--
commit 34f815f9177f234892c1b9608e13d2fc0957697e
Author: SeongJae Park <sj@kernel.org>
mm/damon/reclaim: add autotune_monitoring_intervals parameter
This commit adds a module parameter for utilizing DAMON's auto-tuning
feature with suggested default setups. When enabled, this feature
overrides manually entered monitoring intervals to capture a meaningful
amount of access events per snapshot.
> diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
> index a60ee800d63e9..7126d47fb8b2f 100644
> --- a/mm/damon/reclaim.c
> +++ b/mm/damon/reclaim.c
[ ... ]
> @@ -201,12 +215,21 @@ static int damon_reclaim_apply_parameters(void)
> goto out;
> }
>
> - err = damon_set_attrs(param_ctx, &damon_reclaim_mon_attrs);
> + attrs = damon_reclaim_mon_attrs;
> + if (autotune_monitoring_intervals) {
> + attrs.sample_interval = 5000;
> + attrs.aggr_interval = 100000;
> + attrs.intervals_goal.access_bp = 40;
> + attrs.intervals_goal.aggrs = 3;
> + attrs.intervals_goal.min_sample_us = 5000;
> + attrs.intervals_goal.max_sample_us = 10 * 1000 * 1000;
> + }
In the existing code just above this diff, there is a validation check:
if (!damon_reclaim_mon_attrs.aggr_interval) {
err = -EINVAL;
goto out;
}
If autotune_monitoring_intervals is enabled, could this check prematurely
reject the configuration if damon_reclaim_mon_attrs.aggr_interval is 0?
The auto-tuning override happens right below the check.
Additionally, because this check evaluates the global module parameter
directly instead of a local copy, could a concurrent sysfs write cause a
divide-by-zero panic?
If a user sets the global interval to 0 right after this check passes:
if (!damon_reclaim_mon_attrs.aggr_interval) {
// passes
}
// concurrent sysfs write sets damon_reclaim_mon_attrs.aggr_interval = 0
attrs = damon_reclaim_mon_attrs;
If autotune_monitoring_intervals is false, attrs.aggr_interval becomes 0
and is passed to damon_reclaim_new_scheme(), which performs:
.min_age_region = min_age / aggr_interval,
Would moving this check to evaluate the local attrs.aggr_interval after
the auto-tuning block prevent both of these scenarios?
> + err = damon_set_attrs(param_ctx, &attrs);
> if (err)
> goto out;
>
> err = -ENOMEM;
> - scheme = damon_reclaim_new_scheme();
> + scheme = damon_reclaim_new_scheme(attrs.aggr_interval);
> if (!scheme)
> goto out;
> damon_set_schemes(param_ctx, &scheme, 1);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260501011740.81988-1-sj@kernel.org?part=1
next prev parent reply other threads:[~2026-05-01 1:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 1:17 [PATCH 0/2] mm/damon/reclaim: support monitoring intervals auto-tuning SeongJae Park
2026-05-01 1:17 ` [PATCH 1/2] mm/damon/reclaim: add autotune_monitoring_intervals parameter SeongJae Park
2026-05-01 1:30 ` sashiko-bot [this message]
2026-05-01 1:50 ` SeongJae Park
2026-05-01 1:17 ` [PATCH 2/2] Docs/admin-guide/mm/damon/reclaim: update for autotune_monitoring_intervals SeongJae 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=20260501013044.7DC96C2BCB3@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko@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