mm/damon: reset thread status parameters upon kdamond termination
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 13 repliesIn review
- v1 RFC1 patch 16 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | mm/damon/lru_sort: reset thread status parameters upon kdamond terminationmm/ | +11 | 1 reply | |
| 2/2 | mm/damon/reclaim: reset thread status parameters upon kdamond terminationmm/ | +11 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/2] mm/damon: reset thread status parameters upon kdamond termination
Problem
========
When kdamond terminates unexpectedly, 'enabled' remains 'Y' and 'kdamond_pid' remains stale. This prevents user from restarting DAMON because both writing 'Y' and 'N' to 'enabled' will fail.
"Unexpected termination" here means the kdamond exits without any user request (e.g., not by writing 'N' to 'enabled').
User Impact
===========
Once kdamond terminates this way, it cannot be restarted via sysfs because:
1. DAMON_LRU_SORT/DAMON_RECLAIM is built into the kernel, so it cannot be unloaded and reloaded at runtime.
2. Writing 'N' to 'enabled' fails because kdamond no longer exists; Writing 'Y' does nothing, as 'enabled' is already Y.
As a result, the only way to restore DAMON functionality is a full system reboot.
Solution
========damon_commit_ctx() sets 'maybe_corrupted=true' at the beginning and only sets it to false upon successful completion. When 'maybe_corrupted' remains true, kdamond will terminate eventually.
Therefore:
1. In damon_{lru_sort, reclaim}_turn(): Add fallback logic to reset parameters when damon_stop() fails but kdamond is not running.
2. In damon_{lru_sort, reclaim}_apply_parameters(): Reset parameters when damon_commit_ctx() fails, as kdamond will terminate due to maybe_corrupted mechanism.
Changes from RFC-v1
(https://lore.kernel.org/[email protected])
- Remove RFC tag.
- Remove 'damon_thread_status' structure and damon_update_thread_status() (SJ pointed out this was too much extension of core API for a problem that can be fixed more simply).
- Add a fallback in damon_{lru_sort, reclaim}_turn() 'N' path. If damon_stop() fails but kdamond is not running, forcefully reset the parameters.
- Reset 'enabled' and 'kdamond_pid' when damon_commit_ctx() fails in damon_{lru_sort, reclaim}_apply_parameters() (kdamond will terminate eventually in this case).
Liew Rui Yan (2):
mm/damon/lru_sort: reset thread status parameters upon kdamond
termination
mm/damon/reclaim: reset thread status parameters upon kdamond
termination
mm/damon/lru_sort.c | 13 +++++++++++-- mm/damon/reclaim.c | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-)
Signature · 1 line
2.53.0