From: SJ Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Yifan Feng <evanfengff@gmail.com>,
stable@vger.kernel.org, SJ Park <sj@kernel.org>,
damon@lists.linux.dev, linux-mm@kvack.org
Subject: [PATCH mm-hotfixes-unstable 2/3] mm/damon/core: fix damos_walk() hang with zero watermarks interval
Date: Mon, 23 Nov 2026 07:00:47 -0800 [thread overview]
Message-ID: <20261123150049.81317-3-sj@kernel.org> (raw)
In-Reply-To: <20261123150049.81317-1-sj@kernel.org>
From: Yifan Feng <evanfengff@gmail.com>
kdamond_wait_activation() cancels damos_walk() requests while all
schemes are deactivated by their watermarks. But it returns without
waiting when the watermarks check interval of a deactivated scheme is
zero, which is the default of the DAMON sysfs interface. The kdamond
main loop then runs with all schemes deactivated.
In that state, kdamond_apply_schemes() finds no scheme to apply and
returns before it calls damos_walk_complete(). The walk request is
neither completed nor cancelled, so damos_walk() waits until the
watermarks activate a scheme again, possibly forever.
For example, with a scheme that has the free_mem_rate metric, zero
interval_us and a high watermark below the current free memory rate,
writing update_schemes_tried_regions to the kdamond state file never
returns and cannot be killed. The writer holds damon_sysfs_lock, so all
other DAMON sysfs writes including "off" fail with -EBUSY meanwhile.
Cancel the walk request in kdamond_apply_schemes() when no scheme is
activated, as kdamond_wait_activation() does for a non-zero interval.
Link: https://lore.kernel.org/20261121025626.75981-1-evanfengff@gmail.com
Fixes: bf0eaba0ff9c ("mm/damon/core: implement damos_walk()")
Cc: <stable@vger.kernel.org> # 6.14.x
Suggested-by: SJ Park <sj@kernel.org>
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v2
- v2: https://lore.kernel.org/20261121025626.75981-1-evanfengff@gmail.com
- Collect R-b: from SJ.
- Rebase to the latest mm-new.
Changes from v1
- v1: https://lore.kernel.org/r/20261118235012.14859-1-evanfengff@gmail.com
- Cancel the walk when no scheme is activated, and leave
has_schemes_to_apply as it is (SJ Park).
mm/damon/core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index b8678a53b0a98..2748f91999240 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3492,9 +3492,13 @@ static noinline_for_stack void kdamond_apply_schemes(struct damon_ctx *c)
struct damon_target *t;
struct damos *s;
bool has_schemes_to_apply = false;
+ bool has_activated_schemes = false;
unsigned long max_region_sz;
damon_for_each_scheme(s, c) {
+ if (s->wmarks.activated)
+ has_activated_schemes = true;
+
if (time_before(c->passed_sample_intervals, s->next_apply_sis))
continue;
@@ -3506,8 +3510,12 @@ static noinline_for_stack void kdamond_apply_schemes(struct damon_ctx *c)
damos_adjust_quota(c, s);
}
- if (!has_schemes_to_apply)
+ if (!has_schemes_to_apply) {
+ /* The walk cannot be completed while no scheme is activated */
+ if (!has_activated_schemes)
+ damos_walk_cancel(c);
return;
+ }
max_region_sz = damon_region_sz_limit(c);
mutex_lock(&c->walk_control_lock);
--
2.47.3
next prev parent reply other threads:[~2026-11-23 15:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:00 [PATCH mm-hotfixes-unstable 0/3] mm/damon: three fixes for idle_time overflow and damos_walk() hang SJ Park
2026-11-23 15:00 ` [PATCH mm-hotfixes-unstable 1/3] mm/damon/stat: avoid 32-bit overflow in idle time milliseconds SJ Park
2026-11-23 15:00 ` SJ Park [this message]
2026-11-23 15:00 ` [PATCH mm-hotfixes-unstable 3/3] mm/damon/core: do not overwrite wmarks.activated in damos_commit() SJ Park
2026-11-23 15:16 ` [PATCH mm-hotfixes-unstable 0/3] mm/damon: three fixes for idle_time overflow and damos_walk() hang 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=20261123150049.81317-3-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=evanfengff@gmail.com \
--cc=linux-mm@kvack.org \
--cc=stable@vger.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