From: Leon Hwang <leon.hwang@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v12 04/10] libbpf: Probe percpu data feature
Date: Fri, 14 Aug 2026 14:11:25 +0800 [thread overview]
Message-ID: <9835140c-1a55-4b96-9bbd-a36882f2ac5e@linux.dev> (raw)
In-Reply-To: <20260813153811.6C69D1F000E9@smtp.kernel.org>
On 13/8/26 23:38, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The feature probe `probe_kern_percpu_data` incorrectly returns a negative error code and logs a warning when the kernel lacks support for `BPF_MAP_TYPE_PERCPU_ARRAY`. Feature probes in libbpf should silently return 0 when a feature is missing to gracefully indicate its absence without polluting stderr.
> --
>
> --- Patch [4]: [PATCH bpf-next v12 04/10] libbpf: Probe percpu data feature ---
> commit 783c3759ac5b8bbe1c5368930abe9953ff13c465
> Author: Leon Hwang <leon.hwang@linux.dev>
>
> libbpf: Probe percpu data feature
>
> This commit adds a feature probe for global percpu data support. It allows
> libbpf to detect if the kernel supports percpu data early and make capability
> decisions accordingly.
>
>> diff --git a/tools/lib/bpf/features.c b/tools/lib/bpf/features.c
>> index b7e388f99d0bb..ef9581c113035 100644
>> --- a/tools/lib/bpf/features.c
>> +++ b/tools/lib/bpf/features.c
> [ ... ]
>> +static int probe_kern_percpu_data(int token_fd)
>> +{
>> + struct bpf_insn insns[] = {
>> + BPF_LD_MAP_VALUE(BPF_REG_1, 0, 0),
>> + BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 0),
>> + BPF_EXIT_INSN(),
>> + };
>> + LIBBPF_OPTS(bpf_map_create_opts, map_opts,
>> + .token_fd = token_fd,
>> + .map_flags = token_fd ? BPF_F_TOKEN_FD : 0,
>> + );
>> + LIBBPF_OPTS(bpf_prog_load_opts, prog_opts,
>> + .token_fd = token_fd,
>> + .prog_flags = token_fd ? BPF_F_TOKEN_FD : 0,
>> + );
>> + int ret, map, insn_cnt = ARRAY_SIZE(insns);
>> +
>> + map = bpf_map_create(BPF_MAP_TYPE_PERCPU_ARRAY, "libbpf_percpu", sizeof(int), 8, 1,
>> + &map_opts);
>> + if (map < 0) {
>> + pr_warn("Error in %s(): %s. Couldn't create simple percpu_array map.\n",
>> + __func__, errstr(map));
>> + return map;
>> + }
>
> [Severity: Medium]
> Will this cause spurious warnings when probing environments that don't support
> BPF_MAP_TYPE_PERCPU_ARRAY?
>
> Since feat_supported() expects feature probes to return 0 when a feature is
> missing, returning a negative error code here causes feat_supported() to log
> an additional failure warning.
>
> Should this return 0 instead of map (and perhaps omit the pr_warn) to
> gracefully indicate the feature's absence without polluting stderr?
>
No.
Since percpu_array map is a basic map in bpf, this map creation should
likely succeed. If it fails, the kernels are too old to use such new libbpf.
Thanks,
Leon
next prev parent reply other threads:[~2026-08-14 6:11 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 15:23 [PATCH bpf-next v12 00/10] bpf: Introduce global percpu data Leon Hwang
2026-08-13 15:23 ` [PATCH bpf-next v12 01/10] bpf: Drop duplicate blank lines in kernel/bpf/ Leon Hwang
2026-08-13 16:26 ` bot+bpf-ci
2026-08-14 6:07 ` Leon Hwang
2026-08-13 15:23 ` [PATCH bpf-next v12 02/10] bpf: Factor out check_map_mem_read helper in verifier Leon Hwang
2026-08-13 16:26 ` bot+bpf-ci
2026-08-14 6:10 ` Leon Hwang
2026-08-13 15:23 ` [PATCH bpf-next v12 03/10] bpf: Introduce global percpu data Leon Hwang
2026-08-13 15:23 ` [PATCH bpf-next v12 04/10] libbpf: Probe percpu data feature Leon Hwang
2026-08-13 15:38 ` sashiko-bot
2026-08-14 6:11 ` Leon Hwang [this message]
2026-08-13 15:23 ` [PATCH bpf-next v12 05/10] libbpf: Add support for global percpu data Leon Hwang
2026-08-13 15:42 ` sashiko-bot
2026-08-14 6:12 ` Leon Hwang
2026-08-13 16:26 ` bot+bpf-ci
2026-08-13 17:41 ` Andrii Nakryiko
2026-08-14 6:11 ` Leon Hwang
2026-08-13 15:23 ` [PATCH bpf-next v12 06/10] bpftool: Generate skeleton " Leon Hwang
2026-08-13 16:26 ` bot+bpf-ci
2026-08-14 6:12 ` Leon Hwang
2026-08-13 17:56 ` Andrii Nakryiko
2026-08-14 2:03 ` Leon Hwang
2026-08-13 15:23 ` [PATCH bpf-next v12 07/10] selftests/bpf: Add tests to verify " Leon Hwang
2026-08-13 15:42 ` sashiko-bot
2026-08-14 6:13 ` Leon Hwang
2026-08-13 16:26 ` bot+bpf-ci
2026-08-14 6:13 ` Leon Hwang
2026-08-13 15:23 ` [PATCH bpf-next v12 08/10] selftests/bpf: Test direct reading/writing read-only percpu_array map Leon Hwang
2026-08-13 15:23 ` [PATCH bpf-next v12 09/10] selftests/bpf: Test verifier log for global percpu data Leon Hwang
2026-08-13 15:23 ` [PATCH bpf-next v12 10/10] selftests/bpf: Verify bpf_iter " Leon Hwang
2026-08-13 16:26 ` bot+bpf-ci
2026-08-14 6:13 ` Leon Hwang
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=9835140c-1a55-4b96-9bbd-a36882f2ac5e@linux.dev \
--to=leon.hwang@linux.dev \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox