Re: [PATCH bpf-next v5 14/16] selftests/bpf: Add tests for BPF function stack arguments

sashiko-bot
2026-04-17T04:20:18Z

Sashiko AI review found 1 potential issue(s):
- [Medium] The `test_async_cb_many` test fails to verify the execution and result of the asynchronous timer callback.
--

commit ef139a03093697d9985422f1f900de9a12f9a0dc
Author: Yonghong Song <yonghong.song@linux.dev>

selftests/bpf: Add tests for BPF function stack arguments

This commit adds selftests for BPF-to-BPF subprog and kfunc calls that
utilize more than 5 arguments, verifying stack argument passing. It introduces
test scenarios for various stack argument types, including scalars, pointers,
and async callbacks.

> diff --git a/tools/testing/selftests/bpf/prog_tests/stack_arg.c b/tools/testing/selftests/bpf/prog_tests/stack_arg.c
> index 0000000000000..130eaf1c4a78e
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/stack_arg.c
[ ... ]
> +static void test_async_cb_many(void)
> +{
> + struct stack_arg *skel;
> +
> + skel = stack_arg__open();
> + if (!ASSERT_OK_PTR(skel, "open"))
> + return;
> +
> + if (!skel->rodata->has_stack_arg) {
> + test__skip();
> + goto out;
> + }
> +
> + if (!ASSERT_OK(stack_arg__load(skel), "load"))
> + goto out;
> +
> + run_subtest(skel->progs.test_async_cb_many_args, 0);

Does this test verify the asynchronous callback execution and its result?

Since run_subtest() only runs the program and asserts the return value is 0,
the skeleton is immediately destroyed afterward. The timer callback might
not have time to execute and could be canceled during map destruction.

> +
> +out:
> + stack_arg__destroy(skel);
> +}
[ ... ]
> diff --git a/tools/testing/selftests/bpf/progs/stack_arg.c b/tools/testing/selftests/bpf/progs/stack_arg.c
> index 0000000000000..8c198ee952ff4
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/stack_arg.c
[ ... ]
> +static int timer_cb_many_args(void *map, int *key, struct bpf_timer *timer)
> +{
> + timer_result = static_func_many_args(10, 20, 30, 40, 50, 60, 70, 80);
> + return 0;
> +}

The result of the callback (timer_result) is never verified in userspace.
Should there be a polling loop waiting for the timer to fire in the test,
followed by an assertion checking that skel->bss->timer_result == 360?

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260417034658.2625353-1-yonghong.song@linux.dev?part=14