From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
Emil Tsalapatis <emil@etsalapatis.com>, Tejun Heo <tj@kernel.org>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
kkd@meta.com, kernel-team@meta.com
Subject: [PATCH bpf-next v1 2/2] selftests/bpf: Test resolve_btfids arena argument suffixes
Date: Sun, 9 Aug 2026 10:51:54 +0200 [thread overview]
Message-ID: <20260809085155.3305519-3-memxor@gmail.com> (raw)
In-Reply-To: <20260809085155.3305519-1-memxor@gmail.com>
Add a suffix-only kfunc declaration with arena annotations on all five
arguments. Verify that resolve_btfids emits address_space(1) type tags
for every position without KF_ARENA_ARG flags in the BTF ID sets.
Represent expected arena arguments as a per-parameter bitmap so the
test covers suffixes beyond the two positions expressible by flags.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
.../selftests/bpf/prog_tests/resolve_btfids.c | 35 ++++++++++---------
tools/testing/selftests/bpf/progs/btf_data.c | 9 +++++
2 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c b/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c
index 732cfed35e1c..9bd84fe32b89 100644
--- a/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c
+++ b/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c
@@ -15,6 +15,7 @@
#define DECL_TAG_FASTCALL "bpf_fastcall"
#define DECL_TAG_KFUNC "bpf_kfunc"
#define TYPE_ATTR_ARENA "address_space(1)"
+#define ARENA_ARG(n) (1U << (n))
#ifndef KF_FASTCALL
#define KF_FASTCALL (1 << 12)
@@ -49,13 +50,18 @@ struct kfunc_symbol {
const char *name;
s32 id;
u32 flags;
+ u32 arena_args;
+ bool arena_ret;
};
static struct kfunc_symbol kfunc_symbols[] = {
- { "kfunc_a", -1, 0 },
- { "kfunc_b", -1, KF_FASTCALL },
- { "kfunc_c", -1, KF_ARENA_RET | KF_ARENA_ARG1 | KF_ARENA_ARG2 },
- { "kfunc_d", -1, KF_ARENA_ARG2 },
+ { "kfunc_a", -1, 0, 0, false },
+ { "kfunc_b", -1, KF_FASTCALL, 0, false },
+ { "kfunc_c", -1, KF_ARENA_RET | KF_ARENA_ARG1 | KF_ARENA_ARG2,
+ ARENA_ARG(0) | ARENA_ARG(1), true },
+ { "kfunc_d", -1, KF_ARENA_ARG2, ARENA_ARG(1), false },
+ { "kfunc_e", -1, 0, ARENA_ARG(0) | ARENA_ARG(1) | ARENA_ARG(2) |
+ ARENA_ARG(3) | ARENA_ARG(4), false },
};
/* Align the .BTF_ids section to 4 bytes */
@@ -105,6 +111,7 @@ BTF_ID_FLAGS(func, kfunc_a)
BTF_ID_FLAGS(func, kfunc_b, KF_FASTCALL)
BTF_ID_FLAGS(func, kfunc_c, KF_ARENA_RET | KF_ARENA_ARG1 | KF_ARENA_ARG2)
BTF_ID_FLAGS(func, kfunc_d, KF_ARENA_ARG2)
+BTF_ID_FLAGS(func, kfunc_e)
BTF_KFUNCS_END(test_kfunc_set)
/*
@@ -112,6 +119,7 @@ BTF_KFUNCS_END(test_kfunc_set)
* actually sort at least one of the two sets.
*/
BTF_KFUNCS_START(test_kfunc_set_rev)
+BTF_ID_FLAGS(func, kfunc_e)
BTF_ID_FLAGS(func, kfunc_d, KF_ARENA_ARG2)
BTF_ID_FLAGS(func, kfunc_c, KF_ARENA_RET | KF_ARENA_ARG1 | KF_ARENA_ARG2)
BTF_ID_FLAGS(func, kfunc_b, KF_FASTCALL)
@@ -301,15 +309,15 @@ void test_resolve_btfids(void)
}
/*
- * Check resolve_btfids wrapped exactly the arena-flagged return/args
- * with the address_space(1) type attribute, and left other
+ * Check resolve_btfids wrapped exactly the arena-flagged or suffixed
+ * return/args with the address_space(1) type attribute, and left other
* pointers/returns untouched.
*/
for (i = 0; i < ARRAY_SIZE(kfunc_symbols); i++) {
const struct btf_type *fn, *proto;
const struct btf_param *params;
const char *name = kfunc_symbols[i].name;
- u32 fl = kfunc_symbols[i].flags;
+ u32 arena_args = kfunc_symbols[i].arena_args;
__u32 nr;
fn = btf__type_by_id(btf, kfunc_symbols[i].id);
@@ -322,15 +330,10 @@ void test_resolve_btfids(void)
nr = btf_vlen(proto);
ASSERT_EQ(is_arena_tagged_ptr(btf, proto->type),
- !!(fl & KF_ARENA_RET), name);
- if (nr > 0) {
- ASSERT_EQ(is_arena_tagged_ptr(btf, params[0].type),
- !!(fl & KF_ARENA_ARG1), name);
- }
- if (nr > 1) {
- ASSERT_EQ(is_arena_tagged_ptr(btf, params[1].type),
- !!(fl & KF_ARENA_ARG2), name);
- }
+ kfunc_symbols[i].arena_ret, name);
+ for (j = 0; j < nr; j++)
+ ASSERT_EQ(is_arena_tagged_ptr(btf, params[j].type),
+ !!(arena_args & ARENA_ARG(j)), name);
}
out:
diff --git a/tools/testing/selftests/bpf/progs/btf_data.c b/tools/testing/selftests/bpf/progs/btf_data.c
index ec34f7a6e038..ea41c9801432 100644
--- a/tools/testing/selftests/bpf/progs/btf_data.c
+++ b/tools/testing/selftests/bpf/progs/btf_data.c
@@ -68,3 +68,12 @@ int kfunc_d(struct root_struct *a, struct root_struct *b)
{
return 0;
}
+
+int kfunc_e(struct root_struct *a__arena,
+ struct root_struct *b__arena__nullable,
+ struct root_struct *c__arena,
+ struct root_struct *d__arena__nullable,
+ struct root_struct *e__arena)
+{
+ return 0;
+}
--
2.53.0-Meta
next prev parent reply other threads:[~2026-08-09 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 8:51 [PATCH bpf-next v1 0/2] Add resolve_btfids support for __arena kfunc suffix Kumar Kartikeya Dwivedi
2026-08-09 8:51 ` [PATCH bpf-next v1 1/2] resolve_btfids: Emit arena attributes from kfunc parameter suffixes Kumar Kartikeya Dwivedi
2026-08-09 10:10 ` bot+bpf-ci
2026-08-09 14:08 ` Kumar Kartikeya Dwivedi
2026-08-09 8:51 ` Kumar Kartikeya Dwivedi [this message]
2026-08-09 9:57 ` [PATCH bpf-next v1 2/2] selftests/bpf: Test resolve_btfids arena argument suffixes bot+bpf-ci
2026-08-09 14:07 ` 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=20260809085155.3305519-3-memxor@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=ihor.solodrai@linux.dev \
--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 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.