]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
mm/damon/stat: detect and use fresh enabled value
authorSeongJae Park <sj@kernel.org>
Sun, 19 Apr 2026 16:10:02 +0000 (09:10 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 27 Apr 2026 12:54:27 +0000 (05:54 -0700)
commitf98590bc08d4aea435e1c2213e38bae0d9e9a7bb
treebc0f0c879b8a9aa6e2bbe75b7697077d1c2c2dc8
parentb98b7ff6025ae82570d4915e083f0cbd8d48b3cf
mm/damon/stat: detect and use fresh enabled value

DAMON_STAT updates 'enabled' parameter value, which represents the running
status of its kdamond, when the user explicitly requests start/stop of the
kdamond.  The kdamond can, however, be stopped even if the user explicitly
requested the stop, if ctx->regions_score_histogram allocation failure at
beginning of the execution of the kdamond.  Hence, if the kdamond is
stopped by the allocation failure, the value of the parameter can be
stale.

Users could show the stale value and be confused.  The problem will only
rarely happen in real and common setups because the allocation is arguably
too small to fail.  Also, unlike the similar bugs that are now fixed in
DAMON_RECLAIM and DAMON_LRU_SORT, kdamond can be restarted in this case,
because DAMON_STAT force-updates the enabled parameter value for user
inputs.  The bug is a bug, though.

The issue stems from the fact that there are multiple events that can
change the status, and following all the events is challenging.
Dynamically detect and use the fresh status for the parameters when those
are requested.

The issue was dicovered [1] by Sashiko.

Link: https://lore.kernel.org/20260419161003.79176-4-sj@kernel.org
Link: https://lore.kernel.org/20260416040602.88665-1-sj@kernel.org
Fixes: 369c415e6073 ("mm/damon: introduce DAMON_STAT module")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Liew Rui Yan <aethernet65535@gmail.com>
Cc: <stable@vger.kernel.org> # 6.17.x
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/stat.c