]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
mm/damon/core: process damon_call_control requests on a local list
authorSeongJae Park <sj@kernel.org>
Sat, 17 Jan 2026 17:52:51 +0000 (09:52 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 31 Jan 2026 22:22:46 +0000 (14:22 -0800)
commitebc4734ad2219aaf76c497a6c94a98a2bcdaebc1
tree9f375893b597d4f92cbe139ca183a24c3769112f
parent69714a74c19f5ae8b21e25558d62d893d48a3f18
mm/damon/core: process damon_call_control requests on a local list

kdamond_call() handles damon_call() requests on the ->call_controls list
of damon_ctx, which is shared with damon_call() callers.  To protect the
list from concurrent accesses while letting the callback function
independent of the call_controls_lock, the function does complicated
locking operations.  For each damon_call_control object on the list, the
function removes the control object from the list under locking, invoke
the callback of the control object without locking, and then puts the
control object back to the list if needed, under locking.  It is
complicated, and can contend the locks more frequently with other DAMON
API caller threads as the number of concurrent callback requests
increases.  Contention overhead is not a big deal, but the increased race
opportunity can make headaches.

Simplify the locking sequence by moving all damon_call_control objects
from the shared list to a local list at once under the single lock
protection, processing the callback requests without locking, and adding
back repeat mode controls to the shared list again at once again, again
under the single lock protection.  This change makes the number of locking
in kdamond_call() be always two, regardless of the number of the queued
requests.

Link: https://lkml.kernel.org/r/20260117175256.82826-5-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/core.c