From: Leon Hwang <leon.hwang@linux.dev>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, yonghong.song@linux.dev, song@kernel.org,
eddyz87@gmail.com, qmo@kernel.org, dxu@dxuuu.xyz,
kernel-patches-bot@fb.com, "Daniel Müller" <deso@posteo.net>
Subject: Re: [PATCH bpf-next v3 3/4] bpf, bpftool: Generate skeleton for global percpu data
Date: Thu, 29 May 2025 10:56:14 +0800 [thread overview]
Message-ID: <2d94fcd1-9ddd-49c4-86b6-720b3636ad24@linux.dev> (raw)
In-Reply-To: <CAEf4BzY9KeVeo2+6Ht1v3rL6UdwNxABZCSK1OZ_sD8qhpYZaeQ@mail.gmail.com>
On 28/5/25 06:31, Andrii Nakryiko wrote:
> Adding libbpf-rs maintainer, Daniel, for awareness, as Rust skeleton
> will have to add support for this, once this patch set lands upstream.
>
>
[...]
>> +
>> + if (map_cnt) {
>> + bpf_object__for_each_map(map, obj) {
>> + if (bpf_map__is_internal_percpu(map) &&
>> + get_map_ident(map, ident, sizeof(ident)))
>> + printf("\tobj->%s = NULL;\n", ident);
>> + }
>> + }
>
> hm... maybe we can avoid this by making libbpf re-mmap() this
> initialization image to be read-only during bpf_object load? Then the
> pointer can stay in the skeleton and be available for querying of
> "initialization values" (if anyone cares), and we won't have any extra
> post-processing steps in code generated skeleton code?
>
> And Rust skeleton will be able to expose this as a non-mutable
> reference with no extra magic behind it?
>
>
We can re-mmap() it as read-only.
However, in the case of the Rust skeleton, users could still use unsafe
code to cast immutable variables to mutable ones.
That said, it's better to guide users toward treating them as immutable.
Thanks,
Leon
next prev parent reply other threads:[~2025-05-29 2:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-26 16:21 [PATCH bpf-next v3 0/4] bpf: Introduce global percpu data Leon Hwang
2025-05-26 16:21 ` [PATCH bpf-next v3 1/4] " Leon Hwang
2025-05-27 22:31 ` Andrii Nakryiko
2025-05-29 2:03 ` Leon Hwang
2025-05-26 16:21 ` [PATCH bpf-next v3 2/4] bpf, libbpf: Support " Leon Hwang
2025-05-27 22:31 ` Andrii Nakryiko
2025-05-29 2:24 ` Leon Hwang
2025-05-27 22:40 ` Alexei Starovoitov
2025-05-27 23:25 ` Andrii Nakryiko
2025-05-28 2:35 ` Alexei Starovoitov
2025-05-28 16:05 ` Andrii Nakryiko
2025-05-29 2:43 ` Leon Hwang
2025-06-02 23:50 ` Andrii Nakryiko
2025-06-03 2:45 ` Leon Hwang
2025-06-05 16:29 ` Andrii Nakryiko
2025-05-26 16:21 ` [PATCH bpf-next v3 3/4] bpf, bpftool: Generate skeleton for " Leon Hwang
2025-05-27 22:31 ` Andrii Nakryiko
2025-05-29 2:56 ` Leon Hwang [this message]
2025-06-02 23:50 ` Andrii Nakryiko
2025-06-03 2:47 ` Leon Hwang
2025-05-26 16:21 ` [PATCH bpf-next v3 4/4] selftests/bpf: Add cases to test " Leon Hwang
2025-05-27 22:31 ` [PATCH bpf-next v3 0/4] bpf: Introduce " Andrii Nakryiko
2025-05-28 17:10 ` Yonghong Song
2025-05-29 1:59 ` 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=2d94fcd1-9ddd-49c4-86b6-720b3636ad24@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=deso@posteo.net \
--cc=dxu@dxuuu.xyz \
--cc=eddyz87@gmail.com \
--cc=kernel-patches-bot@fb.com \
--cc=qmo@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