BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Puranjay Mohan" <puranjay12@gmail.com>
Cc: <bpf@vger.kernel.org>, <rcu@vger.kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Harry Yoo (Oracle)" <harry@kernel.org>,
	"Paul E. McKenney" <paulmck@kernel.org>
Subject: Re: [PATCH bpf-next v5 1/4] bpf: Add bpf_call_rcu() kfunc
Date: Tue, 22 Sep 2026 18:35:57 +0000	[thread overview]
Message-ID: <DLM296AAASVA.3IGQUR5NOALQ6@gmail.com> (raw)
In-Reply-To: <CANk7y0hpi+vjXCR1oZBoeL8XLDss-HoufJfYkqNwRUXghFYCMg@mail.gmail.com>

On Tue Sep 22, 2026 at 2:17 PM UTC, Puranjay Mohan wrote:
>> > +     prog = bpf_prog_inc_not_zero(aux->prog);
>> > +     if (IS_ERR(prog)) {
>> > +             WRITE_ONCE(rhk->armed, 0);
>> > +             return -EBADF;
>> > +     }
>>
>> can we drop prog_inc and remove prog pointer from rhk ?
>> with something like if (prog->has_call_rcu) rcu_barrier() during prog unload?
>
> That could work but we would need more than just the calls to
> rcu_barrier_tasks_trace() and/or  rcu_barrier(). As the rcu_barrier
> only waits for callbacks enqueued before it was called, the registered
> callback and re-queue itself and cause problems. So, we would need a
> flag that is set before the call to rcu_barrier() which stops further
> queueing of callbacks from that program. Also, assuming we add these
> barrier calls in bpf_prog_free_deferred() which is runs from
> system_percpu_wq, it could make this run for much longer than
> expected. What is the motivation for using rcu_barrier() instead of
> bpf_prog_inc_not_zero()? is it the 8B pointer in rhk or the atomic
> operation in bpf_prog_inc_not_zero()?

ok. fair enough. let's keep prog inc.

>> > That avoids an allocation and a state machine on the arming path at the
>> > cost of 64 bytes per element, 48 of which are used today.

What was the thinking here? Why ask all progs to waste 16 bytes
for future extensibility that may never happen?
If rcu_head growth we can switch to dynamic alloc while
keeping the struct at 48 bytes.

I feel it's a better trade off.

pw-bot: cr

  reply	other threads:[~2026-09-22 18:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 19:14 [PATCH bpf-next v5 0/4] bpf: Add bpf_call_rcu() and bpf_call_rcu_tasks_trace() Puranjay Mohan
2026-09-21 19:14 ` [PATCH bpf-next v5 1/4] bpf: Add bpf_call_rcu() kfunc Puranjay Mohan
2026-09-21 19:39   ` sashiko-bot
2026-09-21 20:33   ` bot+bpf-ci
2026-09-22  1:53   ` Alexei Starovoitov
2026-09-22 14:17     ` Puranjay Mohan
2026-09-22 18:35       ` Alexei Starovoitov [this message]
2026-09-22 19:09         ` Puranjay Mohan
2026-09-22 23:55           ` Paul E. McKenney
2026-09-21 19:14 ` [PATCH bpf-next v5 2/4] selftests/bpf: Add tests for bpf_call_rcu() Puranjay Mohan
2026-09-21 19:25   ` sashiko-bot
2026-09-21 19:14 ` [PATCH bpf-next v5 3/4] bpf: Add bpf_call_rcu_tasks_trace() kfunc Puranjay Mohan
2026-09-21 19:52   ` sashiko-bot
2026-09-21 20:18   ` bot+bpf-ci
2026-09-21 20:21     ` Puranjay Mohan
2026-09-21 19:14 ` [PATCH bpf-next v5 4/4] selftests/bpf: Add a test for bpf_call_rcu_tasks_trace() Puranjay Mohan

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=DLM296AAASVA.3IGQUR5NOALQ6@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=harry@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=puranjay12@gmail.com \
    --cc=rcu@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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