From: Song Liu <songliubraving@fb.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Song Liu <song@kernel.org>, bpf <bpf@vger.kernel.org>,
Networking <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
"Kernel Team" <Kernel-team@fb.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH bpf-next] perf/bpf_counter: use bpf_map_create instead of bpf_create_map
Date: Tue, 7 Dec 2021 04:32:06 +0000 [thread overview]
Message-ID: <3221CDA7-F2EF-404A-9289-14F9DF6D01DA@fb.com> (raw)
In-Reply-To: <CAEf4BzbaBcySm3bVumBTrkHMmVDWEVxckdVKvUk=4j9HhSsmBA@mail.gmail.com>
> On Dec 6, 2021, at 6:37 PM, Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:
>
> On Mon, Dec 6, 2021 at 3:08 PM Song Liu <song@kernel.org> wrote:
>>
>> bpf_create_map is deprecated. Replace it with bpf_map_create.
>>
>> Fixes: 992c4225419a ("libbpf: Unify low-level map creation APIs w/ new bpf_map_create()")
>
> This is not a bug fix, it's an improvement. So I don't think "Fixes: "
> is warranted here, tbh.
I got compilation errors before this change, like
util/bpf_counter.c: In function ‘bperf_lock_attr_map’:
util/bpf_counter.c:323:3: error: ‘bpf_create_map’ is deprecated: libbpf v0.7+: use bpf_map_create() instead [-Werror=deprecated-declarations]
map_fd = bpf_create_map(BPF_MAP_TYPE_HASH,
^~~~~~
In file included from util/bpf_counter.h:7,
from util/bpf_counter.c:15:
/data/users/songliubraving/kernel/linux-git/tools/lib/bpf/bpf.h:91:16: note: declared here
LIBBPF_API int bpf_create_map(enum bpf_map_type map_type, int key_size,
^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[4]: *** [/data/users/songliubraving/kernel/linux-git/tools/build/Makefile.build:96: util/bpf_counter.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [/data/users/songliubraving/kernel/linux-git/tools/build/Makefile.build:139: util] Error 2
make[2]: *** [Makefile.perf:665: perf-in.o] Error 2
make[1]: *** [Makefile.perf:240: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
Do we plan to remove bpf_create_map in the future? If not, we can probably just
add '#pragma GCC diagnostic ignored "-Wdeprecated-declarations"' can call it done?
>
>> Signed-off-by: Song Liu <song@kernel.org>
>> ---
>> tools/perf/util/bpf_counter.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c
>> index c17d4a43ce065..ed150a9b3a0c0 100644
>> --- a/tools/perf/util/bpf_counter.c
>> +++ b/tools/perf/util/bpf_counter.c
>> @@ -320,10 +320,10 @@ static int bperf_lock_attr_map(struct target *target)
>> }
>>
>> if (access(path, F_OK)) {
>> - map_fd = bpf_create_map(BPF_MAP_TYPE_HASH,
>> + map_fd = bpf_map_create(BPF_MAP_TYPE_HASH, NULL,
>
> I think perf is trying to be linkable with libbpf as a shared library,
> so on some older versions of libbpf bpf_map_create() won't be (yet)
> available. So to make this work, I think you'll need to define your
> own weak bpf_map_create function that will use bpf_create_map().
Hmm... I didn't know the plan to link libbpf as shared library. In this case,
maybe the #pragma solution is preferred?
Thanks,
Song
next prev parent reply other threads:[~2021-12-07 4:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-06 23:08 [PATCH bpf-next] perf/bpf_counter: use bpf_map_create instead of bpf_create_map Song Liu
2021-12-07 2:37 ` Andrii Nakryiko
2021-12-07 4:32 ` Song Liu [this message]
2021-12-07 5:13 ` Andrii Nakryiko
2021-12-07 6:30 ` Song Liu
2021-12-07 23:02 ` Andrii Nakryiko
2021-12-07 23:10 ` 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=3221CDA7-F2EF-404A-9289-14F9DF6D01DA@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
--cc=song@kernel.org \
/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