From: Leon Hwang <leon.hwang@linux.dev>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Quentin Monnet <qmo@kernel.org>, Shuah Khan <shuah@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
kernel-patches-bot@fb.com
Subject: Re: [PATCH bpf-next v7 07/11] bpftool: Generate skeleton for global percpu data
Date: Wed, 24 Jun 2026 12:15:00 +0800 [thread overview]
Message-ID: <2330e6a8-c7eb-4296-8aa0-feaafd6b09cf@linux.dev> (raw)
In-Reply-To: <CAEf4Bzay2Wssj1J4fEq3T7iTOBDswEZunm1OQNDJvPr2Cz2Usg@mail.gmail.com>
On 24/6/26 06:46, Andrii Nakryiko wrote:
> On Mon, Jun 22, 2026 at 7:37 AM Leon Hwang <leon.hwang@linux.dev> wrote:
[...]
>> @@ -263,13 +268,12 @@ static bool is_mmapable_map(const struct bpf_map *map, char *buf, size_t sz)
>> return true;
>> }
>>
>> - if (!bpf_map__is_internal(map) || !(bpf_map__map_flags(map) & BPF_F_MMAPABLE))
>> - return false;
>> -
>> - if (!get_map_ident(map, buf, sz))
>> - return false;
>> + if (bpf_map__is_internal(map) &&
>> + ((bpf_map__map_flags(map) & BPF_F_MMAPABLE) || bpf_map_is_percpu_data(map)) &&
>> + get_map_ident(map, buf, sz))
>> + return true;
>>
>
> just add `if (bpf_map_is_percpu_data(map) return true;`? maybe also
> move get_map_ident check a bit earlier. I think that will be a bit
> cleaner, this condition is quite hard to follow
>
Makes sense.
With adding the helper bpf_map_is_skel_data(), will this change looks
more readable?
+static bool bpf_map_is_skel_data(const struct bpf_map *map)
+{
+ return bpf_map__is_internal(map) &&
+ ((bpf_map__map_flags(map) & BPF_F_MMAPABLE) ||
+ bpf_map__type(map) == BPF_MAP_TYPE_PERCPU_ARRAY);
+}
+
static bool is_mmapable_map(const struct bpf_map *map, char *buf,
size_t sz)
{
size_t tmp_sz;
@@ -263,7 +274,7 @@ static bool is_mmapable_map(const struct bpf_map
*map, char *buf, size_t sz)
return true;
}
- if (!bpf_map__is_internal(map) || !(bpf_map__map_flags(map) &
BPF_F_MMAPABLE))
+ if (!bpf_map_is_skel_data(map))
return false;
if (!get_map_ident(map, buf, sz))
>> - return true;
>> + return false;
>> }
>>
>> static int codegen_datasecs(struct bpf_object *obj, const char *obj_name)
>> @@ -343,6 +347,9 @@ static int codegen_subskel_datasecs(struct bpf_object *obj, const char *obj_name
>> if (!is_mmapable_map(map, map_ident, sizeof(map_ident)))
>> continue;
>>
>> + if (bpf_map_is_percpu_data(map))
>> + continue;
>> +
>> sec = find_type_for_map(btf, map_ident);
>> if (!sec)
>> continue;
>> @@ -669,7 +676,7 @@ static void codegen_destroy(struct bpf_object *obj, const char *obj_name)
>> if (!get_map_ident(map, ident, sizeof(ident)))
>> continue;
>> if (bpf_map__is_internal(map) &&
>> - (bpf_map__map_flags(map) & BPF_F_MMAPABLE))
>> + ((bpf_map__map_flags(map) & BPF_F_MMAPABLE) || bpf_map_is_percpu_data(map)))
>
> also we can add a helper to check if it's an internal map with a
> dedicated data section in the skeleton (too lazy to think of a good
> name right now.. ;)
>
How about bpf_map_is_skel_data()?
Then, this 'if' will be updated as 'if (bpf_map_is_skel_data(map))'.
Thanks,
Leon
>> printf("\tskel_free_map_data(skel->%1$s, skel->maps.%1$s.initial_value, %2$zu);\n",
>> ident, bpf_map_mmap_sz(map));
>> codegen("\
>
> [...]
next prev parent reply other threads:[~2026-06-24 4:15 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 14:35 [PATCH bpf-next v7 00/11] bpf: Introduce global percpu data Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 01/11] bpf: Drop duplicate blank lines in verifier Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 02/11] bpf: Disallow interpreter fallback for user BPF_ADDR_SPACE_CAST insn Leon Hwang
2026-06-22 15:07 ` sashiko-bot
2026-06-23 4:00 ` Leon Hwang
2026-06-23 22:45 ` Andrii Nakryiko
2026-06-24 4:10 ` Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 03/11] bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 04/11] bpf: Introduce global percpu data Leon Hwang
2026-06-23 22:45 ` Andrii Nakryiko
2026-06-24 4:11 ` Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 05/11] libbpf: Probe percpu data feature Leon Hwang
2026-06-23 22:45 ` Andrii Nakryiko
2026-06-24 4:11 ` Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 06/11] libbpf: Add support for global percpu data Leon Hwang
2026-06-23 22:45 ` Andrii Nakryiko
2026-06-24 4:13 ` Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 07/11] bpftool: Generate skeleton " Leon Hwang
2026-06-23 22:46 ` Andrii Nakryiko
2026-06-24 4:15 ` Leon Hwang [this message]
2026-06-22 14:35 ` [PATCH bpf-next v7 08/11] selftests/bpf: Add tests to verify " Leon Hwang
2026-06-22 14:57 ` sashiko-bot
2026-06-23 4:04 ` Leon Hwang
2026-06-22 15:24 ` bot+bpf-ci
2026-06-23 4:02 ` Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 09/11] selftests/bpf: Add test to verify accessing rdonly percpu_array Leon Hwang
2026-06-23 22:46 ` Andrii Nakryiko
2026-06-24 4:16 ` Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 10/11] selftests/bpf: Add tests to verify verifier log for global percpu data Leon Hwang
2026-06-22 14:35 ` [PATCH bpf-next v7 11/11] selftests/bpf: Add test to verify bpf_iter " Leon Hwang
2026-06-22 15:08 ` sashiko-bot
2026-06-23 4:05 ` Leon Hwang
2026-06-24 6:28 ` Leon Hwang
2026-06-22 15:24 ` bot+bpf-ci
2026-06-23 4:04 ` 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=2330e6a8-c7eb-4296-8aa0-feaafd6b09cf@linux.dev \
--to=leon.hwang@linux.dev \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-patches-bot@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=qmo@kernel.org \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@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