Re: [PATCH bpf-next 2/2] uprobes: Switch uretprobes_srcu to SRCU-fast-updown
Peter Zijlstra <[email protected]> Fri, 31 Jul 2026 01:37:20 +0200
| Newsgroups | org.kernel.vger.rcu,org.kernel.vger.bpf,org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users,org.kernel.vger.linux-trace-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Jul 30, 2026 at 03:27:27PM -0700, Andrii Nakryiko wrote: > On Tue, Jul 21, 2026 at 12:44 PM Kumar Kartikeya Dwivedi > <[email protected]> wrote: > > > > On Fri Jul 10, 2026 at 11:23 PM CEST, Andrii Nakryiko wrote: > > > On Mon, Jul 6, 2026 at 10:28 AM Puranjay Mohan <[email protected]> wrote: > > >> > > >> 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 <[email protected]> > > >> --- > > >> include/linux/uprobes.h | 5 +++-- > > >> kernel/events/uprobes.c | 29 +++++++++++++++++------------ > > >> 2 files changed, 20 insertions(+), 14 deletions(-) > > >> > > > > > > Very straightforward replacement and will improve performance, thanks! > > > LGTM. Peter or Mingo, I assume you guys will want to route this > > > through your tip tree, right? > > > > > > Acked-by: Andrii Nakryiko <[email protected]> > > > > > > > Hi Peter, Ingo, > > > > Gentle ping for this. > > > > Another ping, please consider applying, thanks! Got them, thanks!