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>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250806164316.5728-1-bijan311@gmail.com>
Date: Wed,  6 Aug 2025 11:43:16 -0500
From: Bijan Tabatabai <bijan311@...il.com>
To: damon@...ts.linux.dev,
	linux-mm@...ck.org,
	linux-kernel@...r.kernel.org
Cc: sj@...nel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Bijan Tabatabai <bijantabatab@...ron.com>,
	Bijan Tabatabai <bijan311@...il.com>
Subject: [PATCH] mm/damon/core: skip needless update of next_{aggregation,ops_update}_sis

From: Bijan Tabatabai <bijantabatab@...ron.com>

In damon_set_attrs(), ctx->next_{aggregation,ops_update}_sis would be
reset, even if the sample interval, aggregation interval, or ops update
interval were not changed. If damon_set_attrs() is called relatively
frequently, such as by frequent "commit" operations, aggregation and ops
update operations could be needlessly delayed.

This patch avoids this by only updating next_{aggregation,ops_update}_sis
if the relevant intervals were changed.

Cc: Bijan Tabatabai <bijan311@...il.com>
Signed-off-by: Bijan Tabatabai <bijantabatab@...ron.com>
---
This patch came from discussions in [1].

[1] https://lore.kernel.org/all/20250805162022.4920-1-bijan311@gmail.com/
---
 mm/damon/core.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 6a2fe1f2c952..1c3d8b92257c 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -693,6 +693,12 @@ int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs)
 	unsigned long sample_interval = attrs->sample_interval ?
 		attrs->sample_interval : 1;
 	struct damos *s;
+	bool sample_interval_changed = ctx->attrs.sample_interval !=
+		attrs->sample_interval;
+	bool aggr_interval_changed = ctx->attrs.aggr_interval !=
+		attrs->aggr_interval;
+	bool ops_update_interval_changed = ctx->attrs.ops_update_interval !=
+		attrs->ops_update_interval;
 	bool aggregating = ctx->passed_sample_intervals <
 		ctx->next_aggregation_sis;
 
@@ -710,10 +716,12 @@ int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs)
 	if (!attrs->aggr_samples)
 		attrs->aggr_samples = attrs->aggr_interval / sample_interval;
 
-	ctx->next_aggregation_sis = ctx->passed_sample_intervals +
-		attrs->aggr_interval / sample_interval;
-	ctx->next_ops_update_sis = ctx->passed_sample_intervals +
-		attrs->ops_update_interval / sample_interval;
+	if (sample_interval_changed || aggr_interval_changed)
+		ctx->next_aggregation_sis = ctx->passed_sample_intervals +
+			attrs->aggr_interval / sample_interval;
+	if (sample_interval_changed || ops_update_interval_changed)
+		ctx->next_ops_update_sis = ctx->passed_sample_intervals +
+			attrs->ops_update_interval / sample_interval;
 
 	damon_update_monitoring_results(ctx, attrs, aggregating);
 	ctx->attrs = *attrs;
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ