Linux Kernel Selftest development
 help / color / mirror / Atom feed
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 06/11] libbpf: Add support for global percpu data
Date: Wed, 24 Jun 2026 12:13:55 +0800	[thread overview]
Message-ID: <8f06ad4d-d003-4671-9dd4-24b5c7e4b806@linux.dev> (raw)
In-Reply-To: <CAEf4BzZSeMSMnuYdLvEfb7-pmbthjU3J7W3QB4q9-WN_4+QrbA@mail.gmail.com>

On 24/6/26 06:45, Andrii Nakryiko wrote:
> On Mon, Jun 22, 2026 at 7:37 AM Leon Hwang <leon.hwang@linux.dev> wrote:
[...]
>> @@ -5353,6 +5387,13 @@ bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map)
>>                         return err;
>>                 }
>>                 map->mmaped = mmaped;
>> +       } else if (is_percpu) {
>> +               if (mprotect(map->mmaped, mmap_sz, PROT_READ)) {
>> +                       err = -errno;
>> +                       pr_warn("map '%s': failed to mprotect() contents: %s\n",
>> +                               bpf_map__name(map), errstr(err));
>> +                       return err;
>> +               }
> 
> hm... do we need to do this? what happens for LIBBPF_MAP_KCONFIG, do
> we just null out the initial image? should we just do that here?
> Basically what I am asking is how important it is to access initial
> per-CPU image after load? What's the realistic use case for that?
> 

This was suggested by you in v3:
https://lore.kernel.org/bpf/CAEf4BzY9KeVeo2+6Ht1v3rL6UdwNxABZCSK1OZ_sD8qhpYZaeQ@mail.gmail.com/

>>         } else if (map->mmaped) {
>>                 munmap(map->mmaped, mmap_sz);
>>                 map->mmaped = NULL;
>> @@ -10806,16 +10847,19 @@ int bpf_map__fd(const struct bpf_map *map)
>>
>>  static bool map_uses_real_name(const struct bpf_map *map)
>>  {
>> -       /* Since libbpf started to support custom .data.* and .rodata.* maps,
>> -        * their user-visible name differs from kernel-visible name. Users see
>> -        * such map's corresponding ELF section name as a map name.
>> -        * This check distinguishes .data/.rodata from .data.* and .rodata.*
>> -        * maps to know which name has to be returned to the user.
>> +       /*
>> +        * Since libbpf started to support custom .data.*, .rodata.* and
>> +        * .percpu.* maps, their user-visible name differs from
>> +        * kernel-visible name. Users see such map's corresponding ELF section
>> +        * name as a map name. This check distinguishes plain .data/.rodata/.percpu
>> +        * from .data.*, .rodata.* and .percpu.* to choose which name to return.
>>          */
>>         if (map->libbpf_type == LIBBPF_MAP_DATA && strcmp(map->real_name, DATA_SEC) != 0)
>>                 return true;
>>         if (map->libbpf_type == LIBBPF_MAP_RODATA && strcmp(map->real_name, RODATA_SEC) != 0)
>>                 return true;
>> +       if (map->libbpf_type == LIBBPF_MAP_PERCPU && strcmp(map->real_name, PERCPU_SEC) != 0)
>> +               return true;
> 
> um... this is extra logic for DATA/RODATA is supposed to be backwards
> compatible legacy stuff. We shouldn't need this for PERCPU_SEC. It
> should actually be called just ".percpu", not "<object_name>.percpu".
> 
Understand the backwards compatibility after reading the comment in
internal_map_name().

Will drop this hunk, and set "map->name" as ".percpu" in
bpf_object__init_internal_map().

Thanks,
Leon


  reply	other threads:[~2026-06-24  4:14 UTC|newest]

Thread overview: 31+ 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-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 [this message]
2026-06-24 16:45       ` Andrii Nakryiko
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
2026-06-24 16:47       ` Andrii Nakryiko
2026-06-22 14:35 ` [PATCH bpf-next v7 08/11] selftests/bpf: Add tests to verify " 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-24 16:48       ` Andrii Nakryiko
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: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=8f06ad4d-d003-4671-9dd4-24b5c7e4b806@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