From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: Tejun Heo <tj@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Emil Tsalapatis <emil@etsalapatis.com>,
kkd@meta.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v3 2/9] bpf: Support __arena and __arena_nullable on struct_ops arguments
Date: Tue, 04 Aug 2026 16:55:35 -0700 [thread overview]
Message-ID: <018d033499f61651ec8761fe0f7ac9662ef3c096.camel@gmail.com> (raw)
In-Reply-To: <20260803125115.2264733-3-memxor@gmail.com>
On Mon, 2026-08-03 at 14:51 +0200, Kumar Kartikeya Dwivedi wrote:
Lgtm except for several nits below.
...
> diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
...
> @@ -226,26 +229,30 @@ static int prepare_arg_info(struct btf *btf,
> info = info_buf;
> for (arg_no = 0; arg_no < nargs; arg_no++) {
> /* Skip arguments that is not suffixed with
> - * "__nullable or __ref".
> + * "__nullable", "__ref", "__arena" or "__arena_nullable".
> */
> is_nullable = btf_param_match_suffix(btf, &stub_args[arg_no],
> MAYBE_NULL_SUFFIX);
> is_refcounted = btf_param_match_suffix(btf, &stub_args[arg_no],
> REFCOUNTED_SUFFIX);
> + is_arena_nullable = btf_param_match_suffix(btf, &stub_args[arg_no],
> + ARENA_MAYBE_NULL_SUFFIX);
> + is_arena = btf_param_match_suffix(btf, &stub_args[arg_no], ARENA_SUFFIX);
>
> if (is_nullable)
> suffix = MAYBE_NULL_SUFFIX;
> else if (is_refcounted)
> suffix = REFCOUNTED_SUFFIX;
> + else if (is_arena_nullable)
> + suffix = ARENA_MAYBE_NULL_SUFFIX;
> + else if (is_arena)
> + suffix = ARENA_SUFFIX;
As discussed already, that's unfortunate that p__arena and p__nullable
are valid, but p__arena__nullable is not, substituted by
p__arena_nullable. Same goes for global subprogs.
> else
> continue;
>
> - /* Should be a pointer to struct */
> - pointed_type = btf_type_resolve_ptr(btf,
> - args[arg_no].type,
> - &arg_btf_id);
> - if (!pointed_type ||
> - !btf_type_is_struct(pointed_type)) {
> + /* Should be a pointer to struct, or any pointer for __arena/__arena_nullable */
> + pointed_type = btf_type_resolve_ptr(btf, args[arg_no].type, &arg_btf_id);
> + if (!pointed_type || (!is_arena && !is_arena_nullable && !btf_type_is_struct(pointed_type))) {
> pr_warn("stub function %s has %s tagging to an unsupported type\n",
> stub_fname, suffix);
> goto err_out;
...
> diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c
> index ed7999ad6c66..d2d7a2904345 100644
> --- a/kernel/bpf/trampoline.c
> +++ b/kernel/bpf/trampoline.c
...
> @@ -695,6 +743,22 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut
> goto out;
> }
>
> + /*
> + * Arena ctx args are converted only by the struct_ops indirect
> + * trampoline, which dispatches to a single known prog. Generic
> + * trampolines can mix progs with different arenas, so no conversion
> + * is possible here. Not reachable today: only struct_ops progs get
> + * arena ctx args and they never ride generic trampolines.
> + */
> + for (kind = 0; kind < BPF_TRAMP_MAX; kind++) {
> + for (i = 0; i < tnodes[kind].nr_nodes; i++) {
> + if (bpf_prog_has_arena_ctx_arg(tnodes[kind].nodes[i]->link->prog)) {
> + err = -ENOTSUPP;
> + goto out;
> + }
> + }
> + }
Nit: should this be done in __bpf_trampoline_link_prog() or
bpf_trampoline_add_prog()? To avoid doing the same check on unlink.
Since this is an invariant violation, do we want to add WARN_ONCE?
> +
> /* clear all bits except SHARE_IPMODIFY and TAIL_CALL_CTX */
> tr->flags &= (BPF_TRAMP_F_SHARE_IPMODIFY | BPF_TRAMP_F_TAIL_CALL_CTX);
>
...
next prev parent reply other threads:[~2026-08-04 23:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 12:51 [PATCH bpf-next v3 0/9] Add arena argument support to kfuncs and struct_ops Kumar Kartikeya Dwivedi
2026-08-03 12:51 ` [PATCH bpf-next v3 1/9] bpf: Support __arena and __arena_nullable kfunc argument suffixes Kumar Kartikeya Dwivedi
2026-08-03 13:19 ` sashiko-bot
2026-08-04 17:42 ` Amery Hung
2026-08-03 12:51 ` [PATCH bpf-next v3 2/9] bpf: Support __arena and __arena_nullable on struct_ops arguments Kumar Kartikeya Dwivedi
2026-08-03 14:19 ` sashiko-bot
2026-08-04 23:55 ` Eduard Zingerman [this message]
2026-08-03 12:51 ` [PATCH bpf-next v3 3/9] bpf, x86: JIT __arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-05 0:40 ` Eduard Zingerman
2026-08-03 12:51 ` [PATCH bpf-next v3 4/9] bpf, x86: Convert struct_ops arena arguments in the trampoline Kumar Kartikeya Dwivedi
2026-08-03 12:51 ` [PATCH bpf-next v3 5/9] selftests/bpf: Add kfunc __arena and __arena_nullable argument tests Kumar Kartikeya Dwivedi
2026-08-03 13:35 ` sashiko-bot
2026-08-04 20:01 ` Eduard Zingerman
2026-08-04 20:14 ` Kumar Kartikeya Dwivedi
2026-08-04 20:24 ` Eduard Zingerman
2026-08-04 20:26 ` Eduard Zingerman
2026-08-04 20:28 ` Kumar Kartikeya Dwivedi
2026-08-04 20:33 ` Eduard Zingerman
2026-08-04 20:36 ` Eduard Zingerman
2026-08-03 12:51 ` [PATCH bpf-next v3 6/9] selftests/bpf: Add JIT-sequence tests for __arena kfunc arguments Kumar Kartikeya Dwivedi
2026-08-03 13:35 ` sashiko-bot
2026-08-03 12:51 ` [PATCH bpf-next v3 7/9] selftests/bpf: Add struct_ops __arena and __arena_nullable argument tests Kumar Kartikeya Dwivedi
2026-08-03 13:39 ` sashiko-bot
2026-08-03 12:51 ` [PATCH bpf-next v3 8/9] bpf, x86: Fix stack-passed arguments for indirect trampolines Kumar Kartikeya Dwivedi
2026-08-03 13:42 ` sashiko-bot
2026-08-03 12:51 ` [PATCH bpf-next v3 9/9] selftests/bpf: Test stack-passed struct_ops arena arguments Kumar Kartikeya Dwivedi
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=018d033499f61651ec8761fe0f7ac9662ef3c096.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=emil@etsalapatis.com \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=memxor@gmail.com \
--cc=tj@kernel.org \
/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