]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
uprobes: travers uprobe's consumer list locklessly under SRCU protection
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 3 Sep 2024 17:45:59 +0000 (10:45 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 5 Sep 2024 14:56:14 +0000 (16:56 +0200)
commitcc01bd044e6a521d2cd128f685ee8d23ef0067f2
tree8fae8a6534fefde18200e51121096b4bb0dcdca2
parent59da880afed211c989ef65da577b24215ce57774
uprobes: travers uprobe's consumer list locklessly under SRCU protection

uprobe->register_rwsem is one of a few big bottlenecks to scalability of
uprobes, so we need to get rid of it to improve uprobe performance and
multi-CPU scalability.

First, we turn uprobe's consumer list to a typical doubly-linked list
and utilize existing RCU-aware helpers for traversing such lists, as
well as adding and removing elements from it.

For entry uprobes we already have SRCU protection active since before
uprobe lookup. For uretprobe we keep refcount, guaranteeing that uprobe
won't go away from under us, but we add SRCU protection around consumer
list traversal.

Lastly, to keep handler_chain()'s UPROBE_HANDLER_REMOVE handling simple,
we remember whether any removal was requested during handler calls, but
then we double-check the decision under a proper register_rwsem using
consumers' filter callbacks. Handler removal is very rare, so this extra
lock won't hurt performance, overall, but we also avoid the need for any
extra protection (e.g., seqcount locks).

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/r/20240903174603.3554182-5-andrii@kernel.org
include/linux/uprobes.h
kernel/events/uprobes.c