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

Yonghong Song
2026-04-18T18:27:45Z

On 4/17/26 5:52 PM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/tools/testing/selftests/bpf/prog_tests/stack_arg.c b/tools/testing/selftests/bpf/prog_tests/stack_arg.c
>> new file mode 100644
>> index 000000000000..130eaf1c4a78
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/prog_tests/stack_arg.c
>> @@ -0,0 +1,133 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
>> +
>> +#include <test_progs.h>
>> +#include <network_helpers.h>
>> +#include "stack_arg.skel.h"
>> +#include "stack_arg_kfunc.skel.h"
>> +
>> +static void run_subtest(struct bpf_program *prog, int expected)
>> +{
>> + int err, prog_fd;
>> + LIBBPF_OPTS(bpf_test_run_opts, topts,
>> + .data_in = &pkt_v4,
>> + .data_size_in = sizeof(pkt_v4),
>> + .repeat = 1,
>> + );
>> +
>> + prog_fd = bpf_program__fd(prog);
>> + err = bpf_prog_test_run_opts(prog_fd, &topts);
>> + ASSERT_OK(err, "test_run");
>> + ASSERT_EQ(topts.retval, expected, "retval");
>> +}
> [ ... ]
>
>> +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);
>> +
>> +out:
>> + stack_arg__destroy(skel);
>> +}
> Does this test adequately verify the asynchronous timer 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.
>
> The result of the callback (timer_result) is never verified in
> userspace. Should there be a polling loop waiting for the timer to fire,
> followed by an assertion checking that skel->bss->timer_result == 360?

Okay, the timer test is incomplete. Let me add more meet to actually get
a timer result.

>
> Reference: https://lore.kernel.org/bpf/20260417042017.CF065C19425@smtp.kernel.org/
>
> [ ... ]
>
>
> ---
> 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/24592562564