From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "Eduard Zingerman" <eddyz87@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 5/9] selftests/bpf: Add kfunc __arena and __arena_nullable argument tests
Date: Tue, 04 Aug 2026 22:14:49 +0200 [thread overview]
Message-ID: <DKGFO6NR1WR4.JUGJA7Q941BU@gmail.com> (raw)
In-Reply-To: <7f0d996cbfb2703450b9974d18c9f60ac2a3a959.camel@gmail.com>
On Tue Aug 4, 2026 at 10:01 PM CEST, Eduard Zingerman wrote:
> On Mon, 2026-08-03 at 14:51 +0200, Kumar Kartikeya Dwivedi wrote:
>
> ...
>
>> +SEC("syscall")
>> +__arch_x86_64
>> +__success __retval(0)
>> +int arena_arg_forms(void *ctx)
>> +{
>> +#if defined(__BPF_FEATURE_ADDR_SPACE_CAST)
>> + u64 __arena *val;
>> + u64 ret;
>> +
>> + val = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0);
>> + if (!val)
>> + return 1;
>> +
>> + /* PTR_TO_ARENA argument */
>> + *val = 41;
>> + ret = bpf_kfunc_arena_arg_test((u64 *)val);
>
> Thinking a bit more about the PTR_TO_ARENA vs SCALAR_VALUE in the
> patch #1. Looking the test cases added, the use case is to pass
> pointers annotated with __attribute__((address_space(1))) to such
> functions, e.g. obtained as:
> - a return value from bpf_arena_alloc_pages
> - or a nested pointer in some arena located structure:
> struct foo {
> int __arena *ptr;
> };
> ...
> sturct foo __arena *foo = ...;
> bpf_kfunc_arena_arg_test(foo->ptr);
>
> The way these kfuncs are currently generated in vmlinux.h,
> they lack the address space annotation, and hence you need
> to explicitly do the casting, as here:
>
> ret = bpf_kfunc_arena_arg_test((u64 *)val);
For now they are in bpf_testmod, but your point stands regardless.
>
> This is both inconvenient *and* adds a useless address space cast
> instruction (translation of the cast).
>
> Which leads to several conclusions:
> - We should reach a consensus regarding KF_ARENA* usage, as these
> kfuncs would clearly benefit from having __arena annotations on
> parameters (on the BPF side, on the host side these should be
> declared as plain pointers).
Yes, but even if we do, for the time begin, we won't have support for
automatically emitting it until resolve_btfids changes are done. That said, I
can manually add the annotation for now.
> - In patch #1, it appears that there is no need to allow PTR_TO_ARENA
> for parameters passed to such a function. At-least I don't see a C
> code not involving manual casts that would require such support.
This one I don't understand. Why wouldn't we get PTR_TO_ARENA typed paramters as
arguments?
>
> ...
next prev parent reply other threads:[~2026-08-04 20:14 UTC|newest]
Thread overview: 24+ 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-03 12:51 ` [PATCH bpf-next v3 3/9] bpf, x86: JIT __arena kfunc argument rebasing Kumar Kartikeya Dwivedi
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 [this message]
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=DKGFO6NR1WR4.JUGJA7Q941BU@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=kernel-team@meta.com \
--cc=kkd@meta.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