From: Stijn Tintel <stijn@linux-ipv6.be>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>, Song Liu <song@kernel.org>
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
"open list" <linux-kernel@vger.kernel.org>,
"KP Singh" <kpsingh@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
"Yonghong Song" <yhs@fb.com>, "Song Liu" <songliubraving@fb.com>,
"Martin KaFai Lau" <kafai@fb.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Alexei Starovoitov" <ast@kernel.org>
Subject: Re: [PATCH] libbpf: fix BPF_MAP_TYPE_PERF_EVENT_ARRAY auto-pinning
Date: Thu, 24 Feb 2022 17:38:17 +0200 [thread overview]
Message-ID: <0f1fb86b-f8df-b209-9a89-512cbc142e04@linux-ipv6.be> (raw)
In-Reply-To: <ac624e07-5310-438a-dce3-d2edb01e8031@linux-ipv6.be>
On 24/02/2022 12:08, Stijn Tintel wrote:
> On 24/02/2022 01:15, Andrii Nakryiko wrote:
>> On Tue, Feb 22, 2022 at 6:37 PM Song Liu <song@kernel.org> wrote:
>>> On Tue, Feb 22, 2022 at 12:51 PM Stijn Tintel <stijn@linux-ipv6.be> wrote:
>>>> When a BPF map of type BPF_MAP_TYPE_PERF_EVENT_ARRAY doesn't have the
>>>> max_entries parameter set, this parameter will be set to the number of
>>>> possible CPUs. Due to this, the map_is_reuse_compat function will return
>>>> false, causing the following error when trying to reuse the map:
>>>>
>>>> libbpf: couldn't reuse pinned map at '/sys/fs/bpf/m_logging': parameter mismatch
>>>>
>>>> Fix this by checking against the number of possible CPUs if the
>>>> max_entries parameter is not set in the map definition.
>>>>
>>>> Fixes: 57a00f41644f ("libbpf: Add auto-pinning of maps when loading BPF objects")
>>>> Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
>>> Acked-by: Song Liu <songliubraving@fb.com>
>>>
>>> I think the following fix would be more future proof, but the patch
>>> as-is is better for
>>> stable backport? How about we add a follow up patch on top of current
>>> patch to fix
>>> def->max_entries once for all?
>> Keeping special logic for PERF_EVENT_ARRAY in one place is
>> preferrable. With this, the changes in map_is_reuse_compat() shouldn't
>> be necessary at all. Stijn, can you please send v2 with Song's
>> proposed changes?
>>
> Will do!
Unfortunately that doesn't work. In bpf_object__create_maps, we call
bpf_object__reuse_map and map_is_reuse_compat before
bpf_object__create_map, so we check map_info.max_entries ==
map->def.max_entries before the latter is being overwritten.
So I propose to send a v2 based on my initial submission, but use __u32
for def_max_entries instead of int, unless someone has another suggestion?
Thanks,
Stijn
next prev parent reply other threads:[~2022-02-24 15:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 20:42 Stijn Tintel
2022-02-23 2:36 ` Song Liu
2022-02-23 23:15 ` Andrii Nakryiko
2022-02-24 10:08 ` Stijn Tintel
2022-02-24 15:38 ` Stijn Tintel [this message]
2022-02-25 3:48 ` Song Liu
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=0f1fb86b-f8df-b209-9a89-512cbc142e04@linux-ipv6.be \
--to=stijn@linux-ipv6.be \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=song@kernel.org \
--cc=songliubraving@fb.com \
--cc=toke@redhat.com \
--cc=yhs@fb.com \
/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
all inboxes | Powered by JetHome®