From: sashiko-bot@kernel.org
To: "Xu Kuohai" <xukuohai@huaweicloud.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 15/16] selftests/bpf: Add test for mixed arena percpu object
Date: Tue, 20 Oct 2026 13:57:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-179062@kernel.org> (raw)
In-Reply-To: <a36e6a008493b367af5d9c338cf707fadfc8a632.1792503001.git.xukuohai@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/bpf: unreachable err > 0 branch and silent test bypass in test_arena_percpu_mixed()
--
commit df1443ad7be8c02167841960847603cc924444f9
Author: Xu Kuohai <xukuohai@huawei.com>
selftests/bpf: Add test for mixed arena percpu object
This commit adds a selftest subtest and BPF program to exercise mixing
per-CPU arena variables and a regular global arena variable within the
same BPF arena map.
> diff --git a/tools/testing/selftests/bpf/prog_tests/arena_percpu.c b/tools/testing/selftests/bpf/prog_tests/arena_percpu.c
> index 27d4721c7ae9a..b450be5f2b36c 100644
> --- a/tools/testing/selftests/bpf/prog_tests/arena_percpu.c
> +++ b/tools/testing/selftests/bpf/prog_tests/arena_percpu.c
[ ... ]
> @@ -137,6 +138,99 @@ static void test_arena_percpu_only(void)
> restore_affinity();
> }
>
> +static void test_arena_percpu_mixed(void)
> +{
> + struct arena_percpu_mixed *skel;
> + struct bpf_map *arena, *bss_map;
> + bool *possible = NULL, *online = NULL, *written = NULL;
> + int possible_cpus, online_cpus, nr_written = 0, cpu, err;
[ ... ]
> + for (cpu = 0; cpu < online_cpus; cpu++) {
> + if (!online[cpu] || cpu >= CPU_SETSIZE || !CPU_ISSET(cpu, &affinity_save))
> + continue;
> +
> + err = run_on_cpu(cpu, skel->progs.arena_percpu_mixed_write, "write");
> + if (err < 0)
> + goto out;
> + if (err > 0)
> + continue;
> + written[cpu] = true;
> + nr_written++;
> + }
> + if (!ASSERT_GE(nr_written, 1, "cpus_exercised"))
> + goto out;
[Severity: Medium]
Can the err > 0 branch ever be reached here? Looking at run_on_cpu() in
tools/testing/selftests/bpf/prog_tests/arena_percpu.c:
static int run_on_cpu(int cpu, struct bpf_program *prog, const char *name)
{
LIBBPF_OPTS(bpf_test_run_opts, opts);
int err;
if (pin_to(cpu))
return -1;
err = bpf_prog_test_run_opts(bpf_program__fd(prog), &opts);
if (!ASSERT_OK(err, name))
return -1;
if (!ASSERT_OK(opts.retval, name))
return -1;
return 0;
}
run_on_cpu() only returns -1 or 0, so the err > 0 check is dead code.
Furthermore, if pin_to(cpu) fails (for example, if a CPU cannot be pinned or
goes offline), run_on_cpu() returns -1 without recording an assertion
failure. In test_arena_percpu_mixed(), that triggers goto out, bypassing
ASSERT_GE(nr_written, 1, "cpus_exercised") and all subsequent arena checks
while allowing the subtest to pass silently.
Was run_on_cpu() intended to return a positive value when pin_to(cpu) fails
so the loop can skip that CPU and still enforce nr_written >= 1?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792503001.git.xukuohai@huawei.com?part=15
next prev parent reply other threads:[~2026-10-20 13:57 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 13:22 [PATCH bpf-next 00/16] Add percpu variable support for bpf arena Xu Kuohai
2026-10-20 13:22 ` [PATCH bpf-next 01/16] libbpf: Collect arena percpu data section Xu Kuohai
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 13:22 ` [PATCH bpf-next 02/16] libbpf: Create arena percpu chunk from the arena percpu ELF section Xu Kuohai
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 13:22 ` [PATCH bpf-next 03/16] libbpf: Place the percpu chunks in the bpf arena Xu Kuohai
2026-10-20 13:22 ` [PATCH bpf-next 04/16] libbpf: Copy the percpu chunks into " Xu Kuohai
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 13:22 ` [PATCH bpf-next 05/16] libbpf: Add the arena percpu chunk attribute to map creation options Xu Kuohai
2026-10-20 14:04 ` sashiko-bot
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 13:22 ` [PATCH bpf-next 06/16] libbpf: Relocate arena percpu access instructions Xu Kuohai
2026-10-20 14:29 ` bot+bpf-ci
2026-10-20 13:22 ` [PATCH bpf-next 07/16] libbpf: Add arena percpu feature probe Xu Kuohai
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 13:22 ` [PATCH bpf-next 08/16] bpf: Extend syscall to accept arena percpu information Xu Kuohai
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 13:22 ` [PATCH bpf-next 09/16] bpf: Teach verifier about arena percpu instructions Xu Kuohai
2026-10-20 14:16 ` sashiko-bot
2026-10-20 14:29 ` bot+bpf-ci
2026-10-20 13:22 ` [PATCH bpf-next 10/16] bpf, x86: Add support for arena percpu Xu Kuohai
2026-10-20 14:12 ` sashiko-bot
2026-10-20 13:22 ` [PATCH bpf-next 11/16] bpf, arm64: " Xu Kuohai
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 14:31 ` sashiko-bot
2026-10-20 13:22 ` [PATCH bpf-next 12/16] libbpf: Introduce arena percpu helpers for user space Xu Kuohai
2026-10-20 14:00 ` sashiko-bot
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 13:22 ` [PATCH bpf-next 13/16] bpftool: Emit the arena percpu datasec into skeleton Xu Kuohai
2026-10-20 14:01 ` sashiko-bot
2026-10-20 13:22 ` [PATCH bpf-next 14/16] selftests/bpf: Add test for arena percpu-only object Xu Kuohai
2026-10-20 14:12 ` sashiko-bot
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 13:23 ` [PATCH bpf-next 15/16] selftests/bpf: Add test for mixed arena percpu object Xu Kuohai
2026-10-20 13:57 ` sashiko-bot [this message]
2026-10-20 13:23 ` [PATCH bpf-next 16/16] selftests/bpf: Add test for arena percpu bounds Xu Kuohai
2026-10-20 14:17 ` bot+bpf-ci
2026-10-20 14:47 ` [PATCH bpf-next 00/16] Add percpu variable support for bpf arena Alexei Starovoitov
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=sashiko-outbox-179062@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=xukuohai@huaweicloud.com \
/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.