From: SeongJae Park <sj@kernel.org>
To: SeongJae Park <sj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: (sashiko) [PATCH 01/10] mm/damon/core: introduce damon_ctx->paused
Date: Sat, 21 Mar 2026 13:12:04 -0700 [thread overview]
Message-ID: <20260321201205.95756-1-sj@kernel.org> (raw)
In-Reply-To: <20260321181343.93971-2-sj@kernel.org>
Forwarding Sashiko review for doing discussions via mails.
# review url: https://sashiko.dev/#/patchset/20260321181343.93971-2-sj@kernel.org
# start of sashiko.dev inline review
commit b56d17c42c1dc6d883f3a75d785a05ba53b5c35b
Author: SeongJae Park <sj@kernel.org>
mm/damon/core: introduce damon_ctx->paused
This commit introduces a paused parameter to the DAMON context API.
It allows users to pause and resume kdamond execution while preserving
self-trained data. The main loop is updated to perform limited work
and sleep when the context is paused.
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index db6c67e52d2b..ce010009ca13 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[ ... ]
> @@ -3003,6 +3004,14 @@ static int kdamond_fn(void *data)
> kdamond_call(ctx, false);
> if (ctx->maybe_corrupted)
> break;
> + while (ctx->pause) {
> + if (kdamond_need_stop(ctx))
> + goto done;
> + kdamond_usleep(ctx->attrs.sample_interval);
This isn't a bug, but polling with kdamond_usleep() using the sample
interval could cause many wakeups per second even while the context is
paused. Would it be more efficient to use a waitqueue here to consume
near-zero CPU until the thread is explicitly woken?
> + /* allow caller unset pause via damon_call() */
> + kdamond_call(ctx, false);
If a parameter update fails during kdamond_call() and sets
ctx->maybe_corrupted to true, the loop will continue to run or exit the
pause loop and proceed to kdamond_apply_schemes() with corrupted
structures.
Is it possible to bypass the corruption safeguard here? Should we check
ctx->maybe_corrupted inside this loop to safely terminate the thread?
> + damos_walk_cancel(ctx);
If kdamond_call() processes a request that unpauses the context, this
will immediately cancel any pending or concurrent damos_walk() requests
before the loop condition is re-evaluated.
Could this cause spurious cancellations of walk requests when unpausing
the context?
> + }
> if (!list_empty(&ctx->schemes))
> kdamond_apply_schemes(ctx);
> else
# end of sashiko.dev inline review
# review url: https://sashiko.dev/#/patchset/20260321181343.93971-2-sj@kernel.org
#
# hkml [1] generated a draft of this mail. It can be regenerated
# using below command:
#
# hkml patch sashiko_dev --for_forwarding \
# 20260321181343.93971-2-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail
next prev parent reply other threads:[~2026-03-21 20:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 18:13 [PATCH 00/10] mm/damon: let DAMON be paused and resumed SeongJae Park
2026-03-21 18:13 ` [PATCH 01/10] mm/damon/core: introduce damon_ctx->paused SeongJae Park
2026-03-21 20:12 ` SeongJae Park [this message]
2026-03-21 20:28 ` (sashiko) " SeongJae Park
2026-03-22 0:34 ` SeongJae Park
2026-03-21 18:13 ` [PATCH 02/10] mm/damon/sysfs: add pause file under context dir SeongJae Park
2026-03-21 18:13 ` [PATCH 03/10] Docs/mm/damon/design: update for context pause/resume feature SeongJae Park
2026-03-21 18:13 ` [PATCH 04/10] Docs/admin-guide/mm/damon/usage: update for pause file SeongJae Park
2026-03-21 18:13 ` [PATCH 05/10] Docs/ABI/damon: update for pause sysfs file SeongJae Park
2026-03-21 18:13 ` [PATCH 06/10] mm/damon/tests/core-kunit: test pause commitment SeongJae Park
2026-03-21 18:13 ` [PATCH 07/10] selftests/damon/_damon_sysfs: support pause file staging SeongJae Park
2026-03-21 18:13 ` [PATCH 08/10] selftests/damon/drgn_dump_damon_status: dump pause SeongJae Park
2026-03-21 18:13 ` [PATCH 09/10] selftests/damon/sysfs.py: check pause on assert_ctx_committed() SeongJae Park
2026-03-21 18:13 ` [PATCH 10/10] selftets/damon/sysfs.py: pause DAMON before dumping status SeongJae Park
2026-03-21 20:12 ` (sashiko) " SeongJae Park
2026-03-21 20:47 ` SeongJae Park
2026-03-21 20:07 ` [PATCH 00/10] mm/damon: let DAMON be paused and resumed SeongJae Park
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=20260321201205.95756-1-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.