From: Yonghong Song <yhs@fb.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Jiri Olsa <olsajiri@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Delyan Kratunov <delyank@fb.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>
Subject: Re: [PATCH] bpftool: Fix generated code in codegen_asserts
Date: Mon, 28 Mar 2022 15:53:38 -0700 [thread overview]
Message-ID: <596ed6c0-7e2b-334e-27df-93d734352dcf@fb.com> (raw)
In-Reply-To: <CAEf4BzaCnG7A+Ns1dw8KYbmzU_q_T96-Niu=1j6o=+KRxYT1bQ@mail.gmail.com>
On 3/28/22 2:31 PM, Andrii Nakryiko wrote:
> On Mon, Mar 28, 2022 at 11:50 AM Jiri Olsa <olsajiri@gmail.com> wrote:
>>
>> On Mon, Mar 28, 2022 at 08:41:18AM -0700, Yonghong Song wrote:
>>>
>>>
>>> On 3/28/22 1:37 AM, Jiri Olsa wrote:
>>>> Arnaldo reported perf compilation fail with:
>>>>
>>>> $ make -k BUILD_BPF_SKEL=1 CORESIGHT=1 PYTHON=python3
>>>> ...
>>>> In file included from util/bpf_counter.c:28:
>>>> /tmp/build/perf//util/bpf_skel/bperf_leader.skel.h: In function ‘bperf_leader_bpf__assert’:
>>>> /tmp/build/perf//util/bpf_skel/bperf_leader.skel.h:351:51: error: unused parameter ‘s’ [-Werror=unused-parameter]
>>>> 351 | bperf_leader_bpf__assert(struct bperf_leader_bpf *s)
>>>> | ~~~~~~~~~~~~~~~~~~~~~~~~~^
>>>> cc1: all warnings being treated as errors
>>>>
>>>> If there's nothing to generate in the new assert function,
>>>> we will get unused 's' warn/error, adding 'unused' attribute to it.
>>>
>>> If there is nothing to generate, should we avoid generating
>>> the assert function itself?
>>
>> good point, will check
>
> we can use this function for some more assertions in the future, so
> instead of trying to be smart about generating or not of this
> function, I think unused attribute is a more robust solution.
Okay, if there are possibly more assertions down the road,
I am fine to keep the function even if it is empty to avoid
more and more conditions to decide whether the functions
should be generated at all.
>
>>
>> jirka
>>
>>>
>>>>
>>>> Cc: Delyan Kratunov <delyank@fb.com>
>>>> Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>>>> Fixes: 08d4dba6ae77 ("bpftool: Bpf skeletons assert type sizes")
>>>> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>>>> ---
>>>> tools/bpf/bpftool/gen.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
>>>> index 7ba7ff55d2ea..91af2850b505 100644
>>>> --- a/tools/bpf/bpftool/gen.c
>>>> +++ b/tools/bpf/bpftool/gen.c
>>>> @@ -477,7 +477,7 @@ static void codegen_asserts(struct bpf_object *obj, const char *obj_name)
>>>> codegen("\
>>>> \n\
>>>> __attribute__((unused)) static void \n\
>>>> - %1$s__assert(struct %1$s *s) \n\
>>>> + %1$s__assert(struct %1$s *s __attribute__((unused))) \n\
>>>> { \n\
>>>> #ifdef __cplusplus \n\
>>>> #define _Static_assert static_assert \n\
next prev parent reply other threads:[~2022-03-28 22:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 8:37 [PATCH] bpftool: Fix generated code in codegen_asserts Jiri Olsa
2022-03-28 14:57 ` Arnaldo Carvalho de Melo
2022-03-28 15:41 ` Yonghong Song
2022-03-28 18:50 ` Jiri Olsa
2022-03-28 21:31 ` Andrii Nakryiko
2022-03-28 22:53 ` Yonghong Song [this message]
2022-03-29 2:20 ` patchwork-bot+netdevbpf
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=596ed6c0-7e2b-334e-27df-93d734352dcf@fb.com \
--to=yhs@fb.com \
--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=delyank@fb.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=netdev@vger.kernel.org \
--cc=olsajiri@gmail.com \
--cc=songliubraving@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