mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] mm/damon/core: simplify minimum watermark wait time calculation
@ 2026-11-10  8:51 Adrian Huang (Lenovo)
  0 siblings, 0 replies; only message in thread
From: Adrian Huang (Lenovo) @ 2026-11-10  8:51 UTC (permalink / raw)
  To: SJ Park
  Cc: Andrew Morton, damon, linux-mm, linux-kernel, ahuang12,
	Adrian Huang (Lenovo)

The minimum watermark wait time calculation uses an additional boolean
variable, init_wait_time, to determine whether min_wait_time has been
initialized.

Simplify the logic by using list_is_first() to identify the first
scheme and initialize min_wait_time accordingly. Subsequent schemes
update min_wait_time only when their waiting intervals are shorter.

This removes the unnecessary boolean variable while preserving the
existing behavior, including the case where no schemes are configured.

Signed-off-by: Adrian Huang (Lenovo) <adrianhuang0701@gmail.com>
---
 mm/damon/core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index d36823f4d092..93ec684a113c 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3985,14 +3985,12 @@ static int kdamond_wait_activation(struct damon_ctx *ctx)
 
 	while (!kdamond_need_stop(ctx)) {
 		unsigned long min_wait_time = 0;
-		bool init_wait_time = false;
 
 		damon_for_each_scheme(s, ctx) {
 			wait_time = damos_wmark_wait_us(s);
-			if (!init_wait_time || wait_time < min_wait_time) {
-				init_wait_time = true;
+			if (list_is_first(&s->list, &ctx->schemes) ||
+			    wait_time < min_wait_time)
 				min_wait_time = wait_time;
-			}
 		}
 		if (!min_wait_time)
 			return 0;
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-10  8:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10  8:51 [PATCH 1/1] mm/damon/core: simplify minimum watermark wait time calculation Adrian Huang (Lenovo)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®