From: SJ Park <sj@kernel.org>
Cc: SJ Park <sj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: [RFC PATCH v2 04/10] mm/damon/core: set damon_ctx->walk_control_obsolete in damon_new_ctx()
Date: Wed, 16 Sep 2026 21:05:30 -0700 [thread overview]
Message-ID: <20260917040537.107341-5-sj@kernel.org> (raw)
In-Reply-To: <20260917040537.107341-1-sj@kernel.org>
damos_walk() should be called for a damon_ctx context that has
successfully started at least once. That's because
damon_ctx->walk_control_obsolete is initialized when kdamond starts. If
the rule is violated, an indefinite wait can happen. There is no
existing violation of the rule.
damon_call() had a similar rule, and it turned out keeping the rule is
not easy for damon_call()'s case. Hence, commit 8023b5f47e09
("mm/damon/core: set ctx->call_controls_obsolete in damon_new_ctx()")
added the initialization in damon_new_ctx() and removed the rule.
Keeping the rule for damos_walk() is relatively easier. But having
slightly different rules for similar functions could be confusing.
Sashiko, for example, repeatedly asked questions about this. Do the
initialization of walk_control_obsolete in damon_new_ctx() for
consistency.
[1] https://lore.kernel.org/20260915011614.102342-1-sj@kernel.org
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 7bbbd44379301..9120a1b707b24 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -939,6 +939,7 @@ struct damon_ctx *damon_new_ctx(void)
INIT_LIST_HEAD(&ctx->schemes);
ctx->call_controls_obsolete = true;
+ ctx->walk_control_obsolete = true;
prandom_seed_state(&ctx->rnd_state, get_random_u64());
return ctx;
@@ -2308,10 +2309,6 @@ int damon_call(struct damon_ctx *ctx, struct damon_call_control *control)
* passed at least one &damos->apply_interval_us, kdamond marks the request as
* completed so that damos_walk() can wakeup and return.
*
- * Note that this function should be called only after damon_start() with the
- * @ctx has succeeded. Otherwise, this function could fall into an indefinite
- * wait.
- *
* Return: 0 on success, negative error code otherwise.
*/
int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control)
--
2.47.3
next prev parent reply other threads:[~2026-09-17 4:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 4:05 [RFC PATCH v2 00/10] mm/damon: improve readability, clarity and test coverage SJ Park
2026-09-17 4:05 ` [RFC PATCH v2 01/10] mm/damon/api: remove NR_DAMOS_FILTER_TYPES SJ Park
2026-09-17 4:09 ` sashiko-bot
2026-09-17 4:05 ` [RFC PATCH v2 02/10] mm/damon/core: use abs_diff() in damon_feed_loop_next_input() SJ Park
2026-09-17 4:09 ` sashiko-bot
2026-09-17 4:05 ` [RFC PATCH v2 03/10] mm/damon/core: use mult_frac() " SJ Park
2026-09-17 4:09 ` sashiko-bot
2026-09-17 4:05 ` SJ Park [this message]
2026-09-17 4:13 ` [RFC PATCH v2 04/10] mm/damon/core: set damon_ctx->walk_control_obsolete in damon_new_ctx() sashiko-bot
2026-09-17 4:05 ` [RFC PATCH v2 05/10] mm/damon/core: document damon_call()/damon_start() race hang issue SJ Park
2026-09-17 4:13 ` sashiko-bot
2026-09-17 4:05 ` [RFC PATCH v2 06/10] mm/damon/paddr: remove pa parameter from damon_pa_filter_pass() SJ Park
2026-09-17 4:08 ` sashiko-bot
2026-09-17 4:05 ` [RFC PATCH v2 07/10] mm/damon/tests/core-kunit: test eligible_mem_bp commitment SJ Park
2026-09-17 4:11 ` sashiko-bot
2026-09-17 4:05 ` [RFC PATCH v2 08/10] mm/damon/tests/core-kunit: add probe_hits_wsum damos filter commit test SJ Park
2026-09-17 4:09 ` sashiko-bot
2026-09-17 4:05 ` [RFC PATCH v2 09/10] selftests/damon/sysfs_memcg_path_leak: fail only for real DAMON leak SJ Park
2026-09-17 4:13 ` sashiko-bot
2026-09-17 4:05 ` [RFC PATCH v2 10/10] Docs/mm/damon/design: clarify bp is basis point SJ Park
2026-09-17 4:09 ` sashiko-bot
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=20260917040537.107341-5-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 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.