From: Leon Hwang <leon.hwang@linux.dev>
To: Andrii Nakryiko <andrii@kernel.org>, sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v11 05/10] libbpf: Add support for global percpu data
Date: Tue, 11 Aug 2026 23:49:06 +0800 [thread overview]
Message-ID: <28c25566-3b96-4dad-9bae-086b26ddc91b@linux.dev> (raw)
In-Reply-To: <2b16a129-1329-436e-b796-ce83ba4d608b@linux.dev>
On 2026/8/7 10:36, Leon Hwang wrote:
> On 7/8/26 00:57, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>> - [Low] Dead code in percpu global data feature check
>> --
>>
>> --- Patch [5]: [PATCH bpf-next v11 05/10] libbpf: Add support for global percpu data ---
>> commit ee97f8a8e25b5e9337024df3dd6f3a1aae4f6cdc
>> Author: Leon Hwang <leon.hwang@linux.dev>
>>
>> libbpf: Add support for global percpu data
>>
>> This commit adds support for global percpu data in libbpf by introducing a
>> new ".percpu" section. It updates the lightweight skeleton loader to use
>> BPF_F_ALL_CPUS when updating the percpu_array map and marks the mmaped data
>> as read-only after population.
>>
>>> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
>>> index 514e4e9daa825..9f79a8e850fdb 100644
>>> --- a/tools/lib/bpf/libbpf.c
>>> +++ b/tools/lib/bpf/libbpf.c
>>
>> [ ... ]
>>
>>> @@ -5293,18 +5326,26 @@ static int
>>> bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map)
>>> {
>>> enum libbpf_map_type map_type = map->libbpf_type;
>>> + bool is_percpu = map_type == LIBBPF_MAP_PERCPU;
>>> + const __u64 update_flags = is_percpu ? BPF_F_ALL_CPUS : 0;
>>> int err, zero = 0;
>>> size_t mmap_sz;
>>>
>>> + if (is_percpu && !obj->gen_loader && !kernel_supports(obj, FEAT_PERCPU_DATA)) {
>>> + pr_warn("map '%s': kernel does not support percpu data.\n",
>>> + bpf_map__name(map));
>>> + return -EOPNOTSUPP;
>>> + }
>>> +
>>
>> [Severity: Low]
>> Is this check reachable?
>>
>> Looking at bpf_object__create_maps(), if the kernel does not support
>> FEAT_PERCPU_DATA, map->autocreate is set to false and the map processing
>> loop continues early:
>>
>> bpf_object__create_maps() {
>> ...
>> if (bpf_map__is_internal(map) && bpf_map__type(map) == BPF_MAP_TYPE_PERCPU_ARRAY &&
>> !kernel_supports(obj, FEAT_PERCPU_DATA))
>> map->autocreate = false;
>>
>> if (!map->autocreate) {
>> pr_debug("map '%s': skipped auto-creating...\n", map->name);
>> continue;
>> }
>> ...
>> }
>>
>> Since bpf_object__populate_internal_map() is called later in this same
>> loop (after the continue), wouldn't the !kernel_supports() condition
>> already be filtered out, making this warning dead code?
>>
>
> True.
>
> Will drop this warning.
>
> And, update 'bpf_map__type(map) == BPF_MAP_TYPE_PERCPU_ARRAY' to
> 'map->libbpf_type == LIBBPF_MAP_PERCPU' in bpf_object__create_maps().
>
Hi Andrii,
Could you apply this series to bpf-next tree? This series seems good
enough to be merged.
Then, I'll post a separate patch to drop the warning, and update the iff
condition.
Thanks,
Leon
next prev parent reply other threads:[~2026-08-11 15:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 16:31 [PATCH bpf-next v11 00/10] bpf: Introduce global percpu data Leon Hwang
2026-08-06 16:31 ` [PATCH bpf-next v11 01/10] bpf: Drop duplicate blank lines in kernel/bpf/ Leon Hwang
2026-08-06 16:31 ` [PATCH bpf-next v11 02/10] bpf: Factor out check_map_mem_read helper in verifier Leon Hwang
2026-08-10 21:38 ` Eduard Zingerman
2026-08-06 16:31 ` [PATCH bpf-next v11 03/10] bpf: Introduce global percpu data Leon Hwang
2026-08-10 23:22 ` Eduard Zingerman
2026-08-11 4:16 ` Leon Hwang
2026-08-11 7:54 ` Eduard Zingerman
2026-08-06 16:31 ` [PATCH bpf-next v11 04/10] libbpf: Probe percpu data feature Leon Hwang
2026-08-06 17:05 ` sashiko-bot
2026-08-07 2:26 ` Leon Hwang
2026-08-06 16:31 ` [PATCH bpf-next v11 05/10] libbpf: Add support for global percpu data Leon Hwang
2026-08-06 16:57 ` sashiko-bot
2026-08-07 2:36 ` Leon Hwang
2026-08-11 15:49 ` Leon Hwang [this message]
2026-08-06 16:31 ` [PATCH bpf-next v11 06/10] bpftool: Generate skeleton " Leon Hwang
2026-08-06 16:31 ` [PATCH bpf-next v11 07/10] selftests/bpf: Add tests to verify " Leon Hwang
2026-08-06 16:31 ` [PATCH bpf-next v11 08/10] selftests/bpf: Test direct reading/writing read-only percpu_array map Leon Hwang
2026-08-06 16:31 ` [PATCH bpf-next v11 09/10] selftests/bpf: Test verifier log for global percpu data Leon Hwang
2026-08-06 16:31 ` [PATCH bpf-next v11 10/10] selftests/bpf: Verify bpf_iter " 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=28c25566-3b96-4dad-9bae-086b26ddc91b@linux.dev \
--to=leon.hwang@linux.dev \
--cc=andrii@kernel.org \
--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