* [PATCH] uprobes: Remove redundant guard(rcu) in find_active_uprobe_speculative()
@ 2026-07-30 1:45 Masami Hiramatsu (Google)
2026-07-30 3:38 ` Masami Hiramatsu
0 siblings, 1 reply; 2+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-07-30 1:45 UTC (permalink / raw)
To: Masami Hiramatsu, Oleg Nesterov, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim
Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, James Clark, linux-kernel, linux-trace-kernel,
linux-perf-users
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
find_active_uprobe_speculative() is called from find_active_uprobe_rcu(),
which is invoked by handle_swbp() and handle_syscall_uprobe().
Both callers already hold RCU Tasks Trace (via rcu_read_lock_trace() or
guard(rcu_tasks_trace)()).
Calling guard(rcu)() inside find_active_uprobe_speculative() is redundant
because the caller already guarantees RCU Tasks Trace protection.
Furthermore, standard RCU (rcu_read_lock()) does not protect uprobes_tree
against asynchronous uprobe destruction (call_rcu_tasks_trace()).
Remove the redundant guard(rcu)() from find_active_uprobe_speculative() and
replace it with lockdep_assert(rcu_read_lock_trace_held()) and a comment
documenting that callers must hold RCU Tasks Trace protection, matching the
convention used by find_active_uprobe_rcu() and find_uprobe_rcu().
Fixes: e0925f2dc4de ("uprobes: add speculative lockless VMA-to-inode-to-uprobe resolution")
Assisted-by: Antigravity:gemini-3.6-flash
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
kernel/events/uprobes.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 4084e926e284..b4e253d43b30 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -2424,6 +2424,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
return is_trap_insn(&opcode);
}
+/* assumes being inside RCU Tasks Trace protected region */
static struct uprobe *find_active_uprobe_speculative(unsigned long bp_vaddr)
{
struct mm_struct *mm = current->mm;
@@ -2433,7 +2434,7 @@ static struct uprobe *find_active_uprobe_speculative(unsigned long bp_vaddr)
loff_t offset;
unsigned int seq;
- guard(rcu)();
+ lockdep_assert(rcu_read_lock_trace_held());
if (!mmap_lock_speculate_try_begin(mm, &seq))
return NULL;
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] uprobes: Remove redundant guard(rcu) in find_active_uprobe_speculative()
2026-07-30 1:45 [PATCH] uprobes: Remove redundant guard(rcu) in find_active_uprobe_speculative() Masami Hiramatsu (Google)
@ 2026-07-30 3:38 ` Masami Hiramatsu
0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2026-07-30 3:38 UTC (permalink / raw)
To: Masami Hiramatsu (Google)
Cc: Oleg Nesterov, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, linux-kernel, linux-trace-kernel, linux-perf-users
On Thu, 30 Jul 2026 10:45:39 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> find_active_uprobe_speculative() is called from find_active_uprobe_rcu(),
> which is invoked by handle_swbp() and handle_syscall_uprobe().
> Both callers already hold RCU Tasks Trace (via rcu_read_lock_trace() or
> guard(rcu_tasks_trace)()).
>
> Calling guard(rcu)() inside find_active_uprobe_speculative() is redundant
> because the caupller already guarantees RCU Tasks Trace protection.
> Furthermore, standard RCU (rcu_read_lock()) does not protect uprobes_tree
> against asynchronous uprobe destruction (call_rcu_tasks_trace()).
>
> Remove the redundant guard(rcu)() from find_active_uprobe_speculative() and
> replace it with lockdep_assert(rcu_read_lock_trace_held()) and a comment
> documenting that callers must hold RCU Tasks Trace protection, matching the
> convention used by find_active_uprobe_rcu() and find_uprobe_rcu().
>
> Fixes: e0925f2dc4de ("uprobes: add speculative lockless VMA-to-inode-to-uprobe resolution")
> Assisted-by: Antigravity:gemini-3.6-flash
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Sashiko mentioned that this guard is not for uprobes_tree, but VMA lookup.
Please ignore this.
Thanks,
> ---
> kernel/events/uprobes.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 4084e926e284..b4e253d43b30 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -2424,6 +2424,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
> return is_trap_insn(&opcode);
> }
>
> +/* assumes being inside RCU Tasks Trace protected region */
> static struct uprobe *find_active_uprobe_speculative(unsigned long bp_vaddr)
> {
> struct mm_struct *mm = current->mm;
> @@ -2433,7 +2434,7 @@ static struct uprobe *find_active_uprobe_speculative(unsigned long bp_vaddr)
> loff_t offset;
> unsigned int seq;
>
> - guard(rcu)();
> + lockdep_assert(rcu_read_lock_trace_held());
>
> if (!mmap_lock_speculate_try_begin(mm, &seq))
> return NULL;
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-30 3:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30 1:45 [PATCH] uprobes: Remove redundant guard(rcu) in find_active_uprobe_speculative() Masami Hiramatsu (Google)
2026-07-30 3:38 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox