All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/damon/core: reinitialize when passed_sample_intervals occurred overflow
@ 2026-01-16  5:07 JaeJoon Jung
  0 siblings, 0 replies; only message in thread
From: JaeJoon Jung @ 2026-01-16  5:07 UTC (permalink / raw)
  To: sj; +Cc: JaeJoon Jung, damon, linux-mm, linux-kernel, rgbi3307

To concisely explain the variables that calculate the time flow in
kdamond_fn(), we write them as follows:

unsigned long ctx->passed_sample_intervals: c.psi
unsigned long ctx->next_ops_update_sis: c.nui

Normal:
[-----------------+---------------+-------------------+----------]
                c.psi           c.nui
                  --------------->              next c.nui
                        if (c.psi >= c.nui) ---------->

Overflow(OF):
[-----------------+---------------+-------------------+----------]
                                c.psi               c.nui
                                  -------------------->
                                            if (c.psi >= c.nui) ---> OF
[-----+-----------
    next c.nui

Overflow(OF) occurred if (c.psi >= next c.nui):
Overflow may occur as shown above. In this case, re-run kdamond_init_ctx()
to reinitialize the relevant variables.

Signed-off-by: JaeJoon Jung <rgbi3307@gmail.com>
---
 mm/damon/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index f9fc0375890a..c4b2831cff89 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2740,6 +2740,11 @@ static int kdamond_fn(void *data)
 			if (ctx->ops.update)
 				ctx->ops.update(ctx);
 			sz_limit = damon_region_sz_limit(ctx);
+
+			/* reinitialize when overflow occurs */
+			if (ctx->passed_sample_intervals >=
+					ctx->next_ops_update_sis)
+				kdamond_init_ctx(ctx);
 		}
 	}
 done:
--
2.43.0


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

only message in thread, other threads:[~2026-01-16  5:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-16  5:07 [PATCH] mm/damon/core: reinitialize when passed_sample_intervals occurred overflow JaeJoon Jung

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.