linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: JaeJoon Jung <rgbi3307@gmail.com>
To: sj@kernel.org
Cc: JaeJoon Jung <rgbi3307@gmail.com>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, rgbi3307@nate.com
Subject: [PATCH] mm/damon/core: reinitialize when passed_sample_intervals occurred overflow
Date: Fri, 16 Jan 2026 14:07:35 +0900	[thread overview]
Message-ID: <20260116050737.21407-1-rgbi3307@gmail.com> (raw)

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



                 reply	other threads:[~2026-01-16  5:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260116050737.21407-1-rgbi3307@gmail.com \
    --to=rgbi3307@gmail.com \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rgbi3307@nate.com \
    --cc=sj@kernel.org \
    /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