From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Sechang Lim" <rhkrqnwk98@gmail.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Neeraj Upadhyay" <neeraj.upadhyay@kernel.org>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"Josh Triplett" <josh@joshtriplett.org>,
"Boqun Feng" <boqun@kernel.org>,
"Uladzislau Rezki" <urezki@gmail.com>
Cc: "Steven Rostedt" <rostedt@goodmis.org>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
"Lai Jiangshan" <jiangshanlai@gmail.com>,
"Zqiang" <qiang.zhang@linux.dev>, <rcu@vger.kernel.org>,
<bpf@vger.kernel.org>
Subject: Re: [PATCH] rcu: Mark rcu_read_unlock_special() notrace
Date: Tue, 24 Nov 2026 21:08:46 +0000 [thread overview]
Message-ID: <DN3QYI65E4KR.27D6XBG0SUWVI@gmail.com> (raw)
In-Reply-To: <20261124185659.1370644-1-rhkrqnwk98@gmail.com>
On Tue, Nov 24, 2026 at 10:56 AM Sechang Lim <rhkrqnwk98@gmail.com> wrote:
> The BPF trampoline calls rcu_read_unlock() on its exit path. If the
> task was preempted in the RCU read-side critical section, this ends up
> in rcu_read_unlock_special(). When a BPF fentry or fexit program is
> attached to rcu_read_unlock_special() itself, the trampoline runs again
Not quite. need_qs and exp_hint set rcu_read_unlock_special.s too,
no preemption needed.
With fexit it recurses on entry, before the prog runs:
__rcu_read_unlock() nesting 1 -> 0, .s != 0
rcu_read_unlock_special()
__bpf_tramp_enter()
percpu_ref_get() nesting 0 -> 1 -> 0, .s != 0
rcu_read_unlock_special()
> -static void rcu_read_unlock_special(struct task_struct *t)
> +static notrace void rcu_read_unlock_special(struct task_struct *t)
It should be fixed on bpf side. Only the bpf trampoline recurses.
ftrace, fprobe and kprobes take ftrace_test_recursion_trylock().
notrace takes the function away from them and from livepatch.
__rcu_read_unlock() is in btf_id_deny for the same reason.
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index e7013ed..0e8afc0 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -24735,6 +24735,7 @@ BTF_ID(func, preempt_count_sub)
#ifdef CONFIG_PREEMPT_RCU
BTF_ID(func, __rcu_read_lock)
BTF_ID(func, __rcu_read_unlock)
+BTF_ID(func, rcu_read_unlock_special)
#endif
BTF_SET_END(btf_id_deny)
Pls target bpf-next.
pw-bot: cr
next prev parent reply other threads:[~2026-11-24 21:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 18:56 [PATCH] rcu: Mark rcu_read_unlock_special() notrace Sechang Lim
2026-11-24 18:59 ` Bradley Morgan
2026-11-24 19:11 ` sashiko-bot
2026-11-24 21:08 ` Alexei Starovoitov [this message]
2026-11-24 22:11 ` Bradley Morgan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DN3QYI65E4KR.27D6XBG0SUWVI@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=boqun@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rhkrqnwk98@gmail.com \
--cc=rostedt@goodmis.org \
--cc=urezki@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.