summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorPuranjay Mohan <puranjay@kernel.org>2026-07-06 10:27:42 -0700
committerPeter Zijlstra <peterz@infradead.org>2026-08-03 10:09:08 +0200
commit36c8b02c3fe9ba56d6f11ec055cd879bc49871f7 (patch)
tree6c305ed66a2aa3e5f9f4fd8ba624004de874794e /include/linux
parentfa8a2d55139fb2e0b09e68c34b730adac92d18d6 (diff)
uprobes: Switch uretprobes_srcu to SRCU-fast-updown
uretprobes_srcu currently uses normal SRCU, which issues two smp_mb() per read lock/unlock pair. This overhead is paid on every uretprobe hit. Switch to SRCU-fast-updown, which eliminates the per-reader memory barriers by moving the ordering cost to the grace-period side (synchronize_rcu() instead of smp_mb()). This is acceptable because grace periods (uprobe unregistration) are infrequent compared to reader-side uretprobe hits. The updown flavor is required because the SRCU read lock is taken in prepare_uretprobe() when a return instance is created and is held until that return instance is finalized. The traced thread returns to user space in between, so the lock is inherently released in a different context from where it was acquired: on the normal return path via uprobe_handle_trampoline() -> hprobe_finalize(), or from ri_timer() (expiry) or dup_utask() (fork) via hprobe_expire(). srcu_down_read_fast() / srcu_up_read_fast() are designed for this acquire-here / release-elsewhere pattern and, unlike the same-context srcu_read_lock_fast() variant, do not carry the lockdep read-side tracking that would warn on it. The short, same-context SRCU sections in ri_timer() and dup_utask() (which guard the uprobe against reuse across the hprobe_expire() cmpxchg) instead use guard(srcu_fast_updown) for proper lockdep coverage. Signed-off-by: Puranjay Mohan <puranjay@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://patch.msgid.link/20260706172744.3920417-3-puranjay@kernel.org
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/uprobes.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h
index 18be159bbc34..d34dbc0fbbfe 100644
--- a/include/linux/uprobes.h
+++ b/include/linux/uprobes.h
@@ -25,6 +25,7 @@ struct mm_struct;
struct inode;
struct notifier_block;
struct page;
+struct srcu_ctr;
/*
* Allowed return values from uprobe consumer's handler callback
@@ -106,7 +107,7 @@ enum hprobe_state {
* underlying uprobe is not guaranteed anymore. __UPROBE_DEAD is just an
* internal marker and is handled transparently by hprobe_fetch() helper.
*
- * When uprobe is SRCU-protected, we also record srcu_idx value, necessary for
+ * When uprobe is SRCU-protected, we also record srcu_scp value, necessary for
* SRCU unlocking.
*
* See hprobe_expire() and hprobe_fetch() for details of race-free uprobe
@@ -115,7 +116,7 @@ enum hprobe_state {
*/
struct hprobe {
enum hprobe_state state;
- int srcu_idx;
+ struct srcu_ctr __percpu *srcu_scp;
struct uprobe *uprobe;
};