[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQLBwjVhKFptO1_CEC9q1ugT1Cy2SiG5XgtD+kr7BTrr_A@mail.gmail.com>
Date: Wed, 27 Aug 2025 09:21:49 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Menglong Dong <menglong8.dong@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Eduard <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Matt Bobrowski <mattbobrowski@...gle.com>, Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
bpf <bpf@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>,
linux-trace-kernel <linux-trace-kernel@...r.kernel.org>
Subject: Re: [PATCH bpf-next] bpf: remove unnecessary rcu_read_lock in kprobe_multi_link_prog_run
On Wed, Aug 27, 2025 at 5:38 AM Menglong Dong <menglong8.dong@...il.com> wrote:
>
> Preemption is disabled in ftrace graph, which indicate rcu_read_lock. So
> the rcu_read_lock is not needed in fprobe_entry(), and it is not needed
> in kprobe_multi_link_prog_run() neither.
kprobe_busy_begin() doing preempt_disable() is an implementation
detail that might change.
Having explicit rcu_read_lock() doesn't hurt.
It's a nop anyway in PREEMPT_NONE.
pw-bot: cr
> Signed-off-by: Menglong Dong <dongml2@...natelecom.cn>
> ---
> kernel/trace/bpf_trace.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 606007c387c5..0e79fa84a634 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -2741,12 +2741,10 @@ kprobe_multi_link_prog_run(struct bpf_kprobe_multi_link *link,
> goto out;
> }
>
> - rcu_read_lock();
> regs = ftrace_partial_regs(fregs, bpf_kprobe_multi_pt_regs_ptr());
> old_run_ctx = bpf_set_run_ctx(&run_ctx.session_ctx.run_ctx);
> err = bpf_prog_run(link->link.prog, regs);
> bpf_reset_run_ctx(old_run_ctx);
> - rcu_read_unlock();
>
> out:
> __this_cpu_dec(bpf_prog_active);
> --
> 2.51.0
>
Powered by blists - more mailing lists