From: Quanmin Yan <yanquanmin1@huawei.com>
To: <sj@kernel.org>
Cc: <akpm@linux-foundation.org>, <damon@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
<yanquanmin1@huawei.com>, <wangkefeng.wang@huawei.com>,
<zuoze1@huawei.com>
Subject: [PATCH 2/2] mm/damon/reclaim: avoid divide-by-zero in damon_reclaim_apply_parameters()
Date: Wed, 27 Aug 2025 19:58:58 +0800 [thread overview]
Message-ID: <20250827115858.1186261-3-yanquanmin1@huawei.com> (raw)
In-Reply-To: <20250827115858.1186261-1-yanquanmin1@huawei.com>
When creating a new scheme of DAMON_RECLAIM, the calculation
of 'min_age_region' uses 'aggr_interval' as the divisor, which
may lead to division-by-zero errors. Fix it by directly returning
-EINVAL when such a case occurs.
Fixes: f5a79d7c0c87 ("mm/damon: introduce struct damos_access_pattern")
Cc: <stable@vger.kernel.org> # 6.1.x
Signed-off-by: Quanmin Yan <yanquanmin1@huawei.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
---
mm/damon/reclaim.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
index 3c71b4596676..fb7c982a0018 100644
--- a/mm/damon/reclaim.c
+++ b/mm/damon/reclaim.c
@@ -194,6 +194,11 @@ static int damon_reclaim_apply_parameters(void)
if (err)
return err;
+ if (!damon_reclaim_mon_attrs.aggr_interval) {
+ err = -EINVAL;
+ goto out;
+ }
+
err = damon_set_attrs(param_ctx, &damon_reclaim_mon_attrs);
if (err)
goto out;
--
2.43.0
next prev parent reply other threads:[~2025-08-27 11:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 11:58 [PATCH 0/2] mm/damon: void divide-by-zero in DAMON module's parameters application Quanmin Yan
2025-08-27 11:58 ` [PATCH 1/2] mm/damon/lru_sort: avoid divide-by-zero in damon_lru_sort_apply_parameters() Quanmin Yan
2025-08-27 11:58 ` Quanmin Yan [this message]
2025-08-27 17:28 ` [PATCH 0/2] mm/damon: void divide-by-zero in DAMON module's parameters application 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=20250827115858.1186261-3-yanquanmin1@huawei.com \
--to=yanquanmin1@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sj@kernel.org \
--cc=wangkefeng.wang@huawei.com \
--cc=zuoze1@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).