All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpftool: Fix generated code in codegen_asserts
@ 2022-03-28  8:37 Jiri Olsa
  2022-03-28 14:57 ` Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jiri Olsa @ 2022-03-28  8:37 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Delyan Kratunov, Arnaldo Carvalho de Melo, netdev, bpf,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh

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.

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\
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] bpftool: Fix generated code in codegen_asserts
  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-29  2:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-03-28 14:57 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Delyan Kratunov, Arnaldo Carvalho de Melo, netdev, bpf,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh

Em Mon, Mar 28, 2022 at 10:37:03AM +0200, Jiri Olsa escreveu:
> 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.

We need some Makefile dependency to trigger the skels to be regenerated
when bpftool is updated.

And before that to notice that the bpftool source code changed and thus
the bootstrap bpftool needs to be rebuilt.

So, after a full tools/perf/ build from scratch it works:

Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Ah, and to wire up a tools/perf/ build when doing a selftests build
perhaps so that libbpf developers can check if in-kernel tools linking
against it still builds when they change libbpf/bpftool?

Regards,

- Arnaldo
 
> 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\
> -- 
> 2.35.1

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bpftool: Fix generated code in codegen_asserts
  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-29  2:20 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 7+ messages in thread
From: Yonghong Song @ 2022-03-28 15:41 UTC (permalink / raw)
  To: Jiri Olsa, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Delyan Kratunov, Arnaldo Carvalho de Melo, netdev, bpf,
	Martin KaFai Lau, Song Liu, John Fastabend, KP Singh



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?

> 
> 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\

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bpftool: Fix generated code in codegen_asserts
  2022-03-28 15:41 ` Yonghong Song
@ 2022-03-28 18:50   ` Jiri Olsa
  2022-03-28 21:31     ` Andrii Nakryiko
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Olsa @ 2022-03-28 18:50 UTC (permalink / raw)
  To: Yonghong Song
  Cc: Jiri Olsa, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Delyan Kratunov, Arnaldo Carvalho de Melo, netdev, bpf,
	Martin KaFai Lau, Song Liu, John Fastabend, KP Singh

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

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\

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bpftool: Fix generated code in codegen_asserts
  2022-03-28 18:50   ` Jiri Olsa
@ 2022-03-28 21:31     ` Andrii Nakryiko
  2022-03-28 22:53       ` Yonghong Song
  0 siblings, 1 reply; 7+ messages in thread
From: Andrii Nakryiko @ 2022-03-28 21:31 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Yonghong Song, Jiri Olsa, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Delyan Kratunov, Arnaldo Carvalho de Melo,
	Networking, bpf, Martin KaFai Lau, Song Liu, John Fastabend,
	KP Singh

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.

>
> 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\

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bpftool: Fix generated code in codegen_asserts
  2022-03-28 21:31     ` Andrii Nakryiko
@ 2022-03-28 22:53       ` Yonghong Song
  0 siblings, 0 replies; 7+ messages in thread
From: Yonghong Song @ 2022-03-28 22:53 UTC (permalink / raw)
  To: Andrii Nakryiko, Jiri Olsa
  Cc: Jiri Olsa, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Delyan Kratunov, Arnaldo Carvalho de Melo, Networking, bpf,
	Martin KaFai Lau, Song Liu, John Fastabend, KP Singh



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\

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bpftool: Fix generated code in codegen_asserts
  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-29  2:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-29  2:20 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: ast, daniel, andrii, delyank, acme, netdev, bpf, kafai,
	songliubraving, yhs, john.fastabend, kpsingh

Hello:

This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Mon, 28 Mar 2022 10:37:03 +0200 you 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
> 
> [...]

Here is the summary with links:
  - bpftool: Fix generated code in codegen_asserts
    https://git.kernel.org/bpf/bpf/c/ef8a257b4e49

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-29  2:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-03-29  2:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.