lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250510220932.47722-1-sj@kernel.org>
Date: Sat, 10 May 2025 15:09:32 -0700
From: SeongJae Park <sj@...nel.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: SeongJae Park <sj@...nel.org>,
	damon@...ts.linux.dev,
	kernel-team@...a.com,
	linux-kernel@...r.kernel.org,
	linux-mm@...ck.org
Subject: [PATCH mm-unstable] samples/damon/mtier: fix wrong DAMON attrs setting

When intervals auto-tuning is enabled, DAMON monitoring attributes
should be set with damon_set_attrs().  Because damon_set_attrs() is the
only place that sets attrs->aggr_samples, not calling damon_set_attrs()
can result in divide-by-zero from damon_get_intervals_score().

mtier, which is a DAMON's sample module that merged in mm-unstable as of
this writing, is not calling the function while enabling the
auto-tuning.  Fix the problem by properly calling damon_set_attrs().

Fixes: 3a1fff3fe05b ("samples/damon: implement a DAMON module for memory tiering") # mm-unstable
Signed-off-by: SeongJae Park <sj@...nel.org>
---
 samples/damon/mtier.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c
index 3390b7d30c26..36d2cd933f5a 100644
--- a/samples/damon/mtier.c
+++ b/samples/damon/mtier.c
@@ -41,6 +41,7 @@ static struct damon_ctx *ctxs[2];
 static struct damon_ctx *damon_sample_mtier_build_ctx(bool promote)
 {
 	struct damon_ctx *ctx;
+	struct damon_attrs attrs;
 	struct damon_target *target;
 	struct damon_region *region;
 	struct damos *scheme;
@@ -50,14 +51,24 @@ static struct damon_ctx *damon_sample_mtier_build_ctx(bool promote)
 	ctx = damon_new_ctx();
 	if (!ctx)
 		return NULL;
+	attrs = (struct damon_attrs) {
+		.sample_interval = 5 * USEC_PER_MSEC,
+		.aggr_interval = 100 * USEC_PER_MSEC,
+		.ops_update_interval = 60 * USEC_PER_MSEC * MSEC_PER_SEC,
+		.min_nr_regions = 10,
+		.max_nr_regions = 1000,
+	};
+
 	/*
 	 * auto-tune sampling and aggregation interval aiming 4% DAMON-observed
 	 * accesses ratio, keeping sampling interval in [5ms, 10s] range.
 	 */
-	ctx->attrs.intervals_goal = (struct damon_intervals_goal) {
+	attrs.intervals_goal = (struct damon_intervals_goal) {
 		.access_bp = 400, .aggrs = 3,
 		.min_sample_us = 5000, .max_sample_us = 10000000,
 	};
+	if (damon_set_attrs(ctx, &attrs))
+		goto free_out;
 	if (damon_select_ops(ctx, DAMON_OPS_PADDR))
 		goto free_out;
 

base-commit: 882bfccd259e3961b81219834715a70a23f9ea71
-- 
2.39.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ