From: SeongJae Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: SeongJae Park <sj@kernel.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: [PATCH 3/7] mm/damon/core: clarify damon_set_attrs() usages
Date: Sat, 7 Mar 2026 11:53:51 -0800 [thread overview]
Message-ID: <20260307195356.203753-4-sj@kernel.org> (raw)
In-Reply-To: <20260307195356.203753-1-sj@kernel.org>
damon_set_attrs() is called for multiple purposes from multiple places.
Calling it in an unsafe context can make DAMON internal state polluted
and results in unexpected behaviors. Clarify when it is safe, and where
it is being called.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/core.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 4e931f7380477..7f74982535aca 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -751,8 +751,16 @@ static bool damon_valid_intervals_goal(struct damon_attrs *attrs)
* @ctx: monitoring context
* @attrs: monitoring attributes
*
- * This function should be called while the kdamond is not running, an access
- * check results aggregation is not ongoing (e.g., from damon_call().
+ * This function updates monitoring results and next monitoring/damos operation
+ * schedules. Because those are periodically updated by kdamond, this should
+ * be called from a safe contexts. Such contexts include damon_ctx setup time
+ * while the kdamond is not yet started, and inside of kdamond_fn().
+ *
+ * In detail, all DAMON API callers directly call this function for initial
+ * setup of damon_ctx before calling damon_start(). Some of the API callers
+ * also indirectly call this function via damon_call() -> damon_commit() for
+ * online parameters updates. Finally, kdamond_fn() itself use this for
+ * applying auto-tuned monitoring intervals.
*
* Every time interval is in micro-seconds.
*
--
2.47.3
next prev parent reply other threads:[~2026-03-07 19:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 19:53 [PATCH 0/7] mm/damon: improve/fixup/update ratio calculation, test and documentation SeongJae Park
2026-03-07 19:53 ` [PATCH 1/7] mm/damon/core: use mult_frac() SeongJae Park
2026-03-07 19:53 ` [PATCH 2/7] mm/damon/tests/core-kunit: add a test for damon_is_last_region() SeongJae Park
2026-03-09 2:34 ` wang lian
2026-03-07 19:53 ` SeongJae Park [this message]
2026-03-07 19:53 ` [PATCH 4/7] mm/damon: document non-zero length damon_region assumption SeongJae Park
2026-03-07 19:53 ` [PATCH 5/7] Docs/admin-guide/mm/damn/lru_sort: fix intervals autotune parameter name SeongJae Park
2026-03-07 19:53 ` [PATCH 6/7] Docs/mm/damon/maintainer-profile: use flexible review cadence SeongJae Park
2026-03-07 19:53 ` [PATCH 7/7] Docs/mm/damon/index: fix typo: autoamted -> automated SeongJae Park
2026-03-09 2:27 ` [PATCH 0/7] mm/damon: improve/fixup/update ratio calculation, test and documentation wang lian
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=20260307195356.203753-4-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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