The current implementation only supports repeated calls to a single damon_call_control request per context. This limitation introduces inefficiencies for scenarios that require registering multiple deferred operations. This patch modifies the implementation of kdamond_call() to support repeated calls to multiple damon_call_control requests. To demonstrate the effect of this change, I made minor modifications to samples/damon/prcl.c by adding a new request alongside the original damon_call_control request and performed comparative tests. Before applying the patch, I observed, [ 381.661821] damon_sample_prcl: start [ 381.668199] damon_sample_prcl: repeat_call_v2 [ 381.668208] damon_sample_prcl: repeat_call [ 381.668211] damon_sample_prcl: wss: 0 [ 381.675194] damon_sample_prcl: repeat_call [ 381.675202] damon_sample_prcl: wss: 0 after applying the patch, I saw, [ 61.750723] damon_sample_prcl: start [ 61.757104] damon_sample_prcl: repeat_call_v2 [ 61.757106] damon_sample_prcl: repeat_call [ 61.757107] damon_sample_prcl: wss: 0 [ 61.763067] damon_sample_prcl: repeat_call_v2 [ 61.763069] damon_sample_prcl: repeat_call [ 61.763070] damon_sample_prcl: wss: 0 Signed-off-by: Enze Li --- mm/damon/core.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 109b050c795a..66b5bae44f22 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -2526,13 +2526,19 @@ static void kdamond_call(struct damon_ctx *ctx, bool cancel) list_add(&control->list, &repeat_controls); } } - control = list_first_entry_or_null(&repeat_controls, - struct damon_call_control, list); - if (!control || cancel) - return; - mutex_lock(&ctx->call_controls_lock); - list_add_tail(&control->list, &ctx->call_controls); - mutex_unlock(&ctx->call_controls_lock); + while (true) { + control = list_first_entry_or_null(&repeat_controls, + struct damon_call_control, list); + if (!control) + break; + /* Unlink from the repeate_controls list. */ + list_del(&control->list); + if (cancel) + continue; + mutex_lock(&ctx->call_controls_lock); + list_add(&control->list, &ctx->call_controls); + mutex_unlock(&ctx->call_controls_lock); + } } /* Returns negative error code if it's not activated but should return */ base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449 -- 2.52.0