From: Yonghong Song <yonghong.song@linux.dev>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
eddyz87@gmail.com, kernel-team@fb.com, martin.lau@kernel.org,
mason@kernel.org, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v3 14/15] selftests/bpf: Add tests for by-value kfunc arguments
Date: Sat, 12 Sep 2026 10:24:57 -0700 [thread overview]
Message-ID: <c3b0d2af-f70f-44ba-979f-c57c5361aff0@linux.dev> (raw)
In-Reply-To: <d6ca13c4e7f5b00fdc9bcea63467374b84e1e8facd74e2322f8e92f3d06a7a24@mail.kernel.org>
On 9/11/26 9:47 AM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/tools/testing/selftests/bpf/progs/aggregate_arg_kfunc.c b/tools/testing/selftests/bpf/progs/aggregate_arg_kfunc.c
>> new file mode 100644
>> index 000000000000..8b0e7aed1ff1
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/progs/aggregate_arg_kfunc.c
> [ ... ]
>
>> +SEC("tc")
>> +__arch_x86_64 __arch_arm64 __load_if_JITed()
>> +__description("aggregate kfunc argument: struct at the tail")
>> +__success __retval(0)
>> +int aggregate_arg_kfunc_tail(struct __sk_buff *skb)
>> +{
>> + u64 a = 1, b = 2;
>> + struct prog_test_pair_arg s = { .lo = a, .hi = b };
>> +
>> + if (bpf_kfunc_call_test_pair_arg_tail(1, 2, 3, 4, 5, s, 6) != a + b + 21)
>> + return 1;
>> + return 0;
>> +}
> Do these tests actually verify that arguments end up in the correct slots?
>
> Looking at the test pattern: bpf_kfunc_call_test_pair_arg_tail(1, 2, 3,
> 4, 5, s, 6) expects 'a + b + 21', but the kfunc returns the sum of all
> its arguments unweighted:
>
> tools/testing/selftests/bpf/test_kmods/bpf_testmod.c:
> __bpf_kfunc u64 bpf_kfunc_call_test_pair_arg_tail(
> u64 a, u64 b, u64 c, u64 d, u64 e,
> struct prog_test_pair_arg s, u64 f)
> {
> return a + b + c + d + e + s.lo + s.hi + f;
> }
>
> The check is invariant under any permutation of values across argument
> slots. It will catch a value that is lost, duplicated or garbage, but
> not a value that ends up in the wrong slot.
>
> Concrete case in this test: aggregate_arg_kfunc_tail is the one case
> where x86-64 moves an argument down into a still-live register (BPF
> slots a..e -> 0..4, s -> 6,7, f -> 5, so f travels through
> BPF_JIT_ARG_TMP). If the scratch handling swapped f with s.lo, the
> callee would read s.lo = 6, f = a, and 1+2+3+4+5 + 6 + b + a still
> equals a + b + 21, so the test passes.
>
> The same holds for the two halves of every 16-byte argument:
> '(u64)(v >> 64) + (u64)v' and 's.lo + s.hi' are symmetric, so a hi/lo
> swap of an __int128 or of prog_test_pair_arg is invisible in all nine
> value tests.
>
> The commit message states "Every test checks the value the kfunc
> returns, so a misplaced argument shows up rather than passing quietly."
> Does this hold if the values are commutative?
I will change kfunc to have different values with different multiplier
for each argument to make the test more robust.
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/34620351527
next prev parent reply other threads:[~2026-09-12 17:25 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 15:49 [PATCH bpf-next v3 00/15] bpf: Support by-value struct and __int128 arguments Yonghong Song
2026-09-11 15:49 ` [PATCH bpf-next v3 01/15] bpf: Read a kfunc's __sz argument only when it is in a register Yonghong Song
2026-09-11 15:49 ` [PATCH bpf-next v3 02/15] selftests/bpf: Add a test for an __int128 by-value argument Yonghong Song
2026-09-11 16:47 ` bot+bpf-ci
2026-09-12 17:07 ` Yonghong Song
2026-09-11 15:49 ` [PATCH bpf-next v3 03/15] bpf: Rename bpf_subprog_info::arg_cnt to arg_slot_cnt Yonghong Song
2026-09-11 15:49 ` [PATCH bpf-next v3 04/15] bpf: Index global function arguments by argument slot Yonghong Song
2026-09-11 15:49 ` [PATCH bpf-next v3 05/15] bpf: Support by-value struct arguments up to 16 bytes Yonghong Song
2026-09-11 15:49 ` [PATCH bpf-next v3 06/15] bpf: Support __int128 as a by-value function argument Yonghong Song
2026-09-11 15:49 ` [PATCH bpf-next v3 07/15] bpf: Rename bpf_call_summary::num_params to arg_slot_cnt Yonghong Song
2026-09-11 15:49 ` [PATCH bpf-next v3 08/15] bpf: Recognize by-value struct and __int128 kfunc arguments Yonghong Song
2026-09-11 16:47 ` bot+bpf-ci
2026-09-12 17:13 ` Yonghong Song
2026-09-11 15:50 ` [PATCH bpf-next v3 09/15] bpf: Prepare kfunc arguments for the JIT from an ABI description Yonghong Song
2026-09-11 15:50 ` [PATCH bpf-next v3 10/15] bpf, x86: Move kfunc arguments into the x86-64 calling convention Yonghong Song
2026-09-11 16:47 ` bot+bpf-ci
2026-09-12 17:14 ` Yonghong Song
2026-09-11 15:50 ` [PATCH bpf-next v3 11/15] bpf, arm64: Move kfunc arguments into the arm64 " Yonghong Song
2026-09-11 16:19 ` sashiko-bot
2026-09-12 17:16 ` Yonghong Song
2026-09-11 16:47 ` bot+bpf-ci
2026-09-12 17:19 ` Yonghong Song
2026-09-11 15:50 ` [PATCH bpf-next v3 12/15] selftests/bpf: Add C tests for by-value arguments up to 16 bytes Yonghong Song
2026-09-11 15:50 ` [PATCH bpf-next v3 13/15] selftests/bpf: Add inline-asm tests for by-value arguments Yonghong Song
2026-09-11 16:06 ` sashiko-bot
2026-09-11 15:50 ` [PATCH bpf-next v3 14/15] selftests/bpf: Add tests for by-value kfunc arguments Yonghong Song
2026-09-11 16:47 ` bot+bpf-ci
2026-09-12 17:24 ` Yonghong Song [this message]
2026-09-11 15:50 ` [PATCH bpf-next v3 15/15] selftests/bpf: Temporary hack to disable register mismatch in arm64 Yonghong Song
2026-09-11 16:47 ` bot+bpf-ci
2026-09-12 3:57 ` Alexei Starovoitov
2026-09-12 17:30 ` Yonghong Song
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=c3b0d2af-f70f-44ba-979f-c57c5361aff0@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=mason@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.