BPF List
 help / color / mirror / Atom feed
From: Bradley Morgan <bradley.morgan@linux.dev>
To: alexei.starovoitov@gmail.com
Cc: boqun@kernel.org, bpf@vger.kernel.org, frederic@kernel.org,
	jiangshanlai@gmail.com, joelagnelf@nvidia.com,
	josh@joshtriplett.org, mathieu.desnoyers@efficios.com,
	neeraj.upadhyay@kernel.org, paulmck@kernel.org,
	qiang.zhang@linux.dev, rcu@vger.kernel.org, rhkrqnwk98@gmail.com,
	rostedt@goodmis.org, urezki@gmail.com
Subject: Re: [PATCH] rcu: Mark rcu_read_unlock_special() notrace
Date: Tue, 24 Nov 2026 22:11:51 +0000	[thread overview]
Message-ID: <F6FC9F7A-43BE-44E4-92FD-034AB96A1C3C@linux.dev> (raw)
In-Reply-To: <DN3QYI65E4KR.27D6XBG0SUWVI@gmail.com>

On 24 November 2026 21:08:46 GMT, Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>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)

ahh crap, brain fog, sorry.

yeah, this approach looks good, again, looks correct to me, won't blow
anything up.

If a patch is submitted:

Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>

> 
>Pls target bpf-next.
>
>pw-bot: cr
>
>


--- Thanks!

      reply	other threads:[~2026-11-24 22:11 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
2026-11-24 22:11   ` Bradley Morgan [this message]

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=F6FC9F7A-43BE-44E4-92FD-034AB96A1C3C@linux.dev \
    --to=bradley.morgan@linux.dev \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox