linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf/core.c - silence warning messages
@ 2019-06-07  2:39 Valdis Klētnieks
  2019-06-11  5:46 ` Andrii Nakryiko
  2019-06-12 14:56 ` Daniel Borkmann
  0 siblings, 2 replies; 10+ messages in thread
From: Valdis Klētnieks @ 2019-06-07  2:39 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann; +Cc: netdev, linux-kernel

Compiling kernel/bpf/core.c with W=1 causes a flood of warnings:

kernel/bpf/core.c:1198:65: warning: initialized field overwritten [-Woverride-init]
 1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
      |                                                                 ^~~~
kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
 1087 |  INSN_3(ALU, ADD,  X),   \
      |  ^~~~~~
kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
 1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
      |   ^~~~~~~~~~~~
kernel/bpf/core.c:1198:65: note: (near initialization for 'public_insntable[12]')
 1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
      |                                                                 ^~~~
kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
 1087 |  INSN_3(ALU, ADD,  X),   \
      |  ^~~~~~
kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
 1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
      |   ^~~~~~~~~~~~

98 copies of the above.

The attached patch silences the warnings, because we *know* we're overwriting
the default initializer. That leaves bpf/core.c with only 6 other warnings,
which become more visible in comparison.

Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>

diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 4c2fa3ac56f6..2606665f2cb5 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_CGROUP_BPF) += cgroup.o
 ifeq ($(CONFIG_INET),y)
 obj-$(CONFIG_BPF_SYSCALL) += reuseport_array.o
 endif
+CFLAGS_core.o          += $(call cc-disable-warning, override-init)



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

* Re: [PATCH] bpf/core.c - silence warning messages
  2019-06-07  2:39 [PATCH] bpf/core.c - silence warning messages Valdis Klētnieks
@ 2019-06-11  5:46 ` Andrii Nakryiko
  2019-06-12 14:56 ` Daniel Borkmann
  1 sibling, 0 replies; 10+ messages in thread
From: Andrii Nakryiko @ 2019-06-11  5:46 UTC (permalink / raw)
  To: Valdis Klētnieks
  Cc: Alexei Starovoitov, Daniel Borkmann, Networking, open list, bpf

On Thu, Jun 6, 2019 at 8:08 PM Valdis Klētnieks <valdis.kletnieks@vt.edu> wrote:
>
> Compiling kernel/bpf/core.c with W=1 causes a flood of warnings:
>
> kernel/bpf/core.c:1198:65: warning: initialized field overwritten [-Woverride-init]
>  1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
>       |                                                                 ^~~~
> kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
>  1087 |  INSN_3(ALU, ADD,  X),   \
>       |  ^~~~~~
> kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
>  1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
>       |   ^~~~~~~~~~~~
> kernel/bpf/core.c:1198:65: note: (near initialization for 'public_insntable[12]')
>  1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
>       |                                                                 ^~~~
> kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
>  1087 |  INSN_3(ALU, ADD,  X),   \
>       |  ^~~~~~
> kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
>  1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
>       |   ^~~~~~~~~~~~
>
> 98 copies of the above.
>
> The attached patch silences the warnings, because we *know* we're overwriting
> the default initializer. That leaves bpf/core.c with only 6 other warnings,
> which become more visible in comparison.
>
> Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>

Thanks! Please include bpf-next in [PATCH] prefix in the future. I've
also CC'ed bpf@vger.kernel.org list.

Acked-by: Andrii Nakryiko <andriin@fb.com>

>
> diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> index 4c2fa3ac56f6..2606665f2cb5 100644
> --- a/kernel/bpf/Makefile
> +++ b/kernel/bpf/Makefile
> @@ -21,3 +21,4 @@ obj-$(CONFIG_CGROUP_BPF) += cgroup.o
>  ifeq ($(CONFIG_INET),y)
>  obj-$(CONFIG_BPF_SYSCALL) += reuseport_array.o
>  endif
> +CFLAGS_core.o          += $(call cc-disable-warning, override-init)
>
>

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

* Re: [PATCH] bpf/core.c - silence warning messages
  2019-06-07  2:39 [PATCH] bpf/core.c - silence warning messages Valdis Klētnieks
  2019-06-11  5:46 ` Andrii Nakryiko
@ 2019-06-12 14:56 ` Daniel Borkmann
  1 sibling, 0 replies; 10+ messages in thread
From: Daniel Borkmann @ 2019-06-12 14:56 UTC (permalink / raw)
  To: Valdis Klētnieks, Alexei Starovoitov; +Cc: netdev, linux-kernel, bpf

On 06/07/2019 04:39 AM, Valdis Klētnieks wrote:
> Compiling kernel/bpf/core.c with W=1 causes a flood of warnings:
> 
> kernel/bpf/core.c:1198:65: warning: initialized field overwritten [-Woverride-init]
>  1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
>       |                                                                 ^~~~
> kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
>  1087 |  INSN_3(ALU, ADD,  X),   \
>       |  ^~~~~~
> kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
>  1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
>       |   ^~~~~~~~~~~~
> kernel/bpf/core.c:1198:65: note: (near initialization for 'public_insntable[12]')
>  1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
>       |                                                                 ^~~~
> kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
>  1087 |  INSN_3(ALU, ADD,  X),   \
>       |  ^~~~~~
> kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
>  1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
>       |   ^~~~~~~~~~~~
> 
> 98 copies of the above.
> 
> The attached patch silences the warnings, because we *know* we're overwriting
> the default initializer. That leaves bpf/core.c with only 6 other warnings,
> which become more visible in comparison.
> 
> Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>

Makes sense, applied!

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

* Re: [PATCH] bpf/core.c - silence warning messages
  2019-01-28 23:35   ` valdis.kletnieks
@ 2019-01-29  3:12     ` Song Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Song Liu @ 2019-01-29  3:12 UTC (permalink / raw)
  To: Valdis Kletnieks
  Cc: Alexei Starovoitov, Daniel Borkmann, Networking, open list

On Mon, Jan 28, 2019 at 3:35 PM <valdis.kletnieks@vt.edu> wrote:
>
> On Mon, 28 Jan 2019 09:18:45 -0800, Song Liu said:
> > On Sun, Jan 27, 2019 at 8:43 PM <valdis.kletnieks@vt.edu> wrote:
>
> > > The attached patch silences the warnings, because we *know* we're overwriting
> > > the default initializer. That leaves bpf/core.c with only 6 other warnings,
> > > which become more visible in comparison.
> >
> > My concern is that this will also mute the warning for other parts of
> > bpf/core.c.
>
> I checked and there weren't any warnings for other parts of the file.  Also, this message
> doesn't even happen unless you build with W=1, which apparently happens so rarely
> that nobody else has submitted a patch.
>
> Is there a high likelihood that another overwrite of an initializer is going to
> be included in the source?
>
> > Maybe we should move bpf_opcode_in_insntable() to a separate file, and mute
> > warning for that file?
>
> Seems to be overkill - the intent of this patch was mostly to make the *other*
> warnings issued with W=1 more noticable.

Yeah, I also felt this might be overkill while asking initially.

Acked-by: Song Liu <songliubraving@fb.com>

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

* Re: [PATCH] bpf/core.c - silence warning messages
  2019-01-28 23:48     ` valdis.kletnieks
@ 2019-01-28 23:54       ` Daniel Borkmann
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Borkmann @ 2019-01-28 23:54 UTC (permalink / raw)
  To: valdis.kletnieks; +Cc: Song Liu, Alexei Starovoitov, Networking, open list

On 01/29/2019 12:48 AM, valdis.kletnieks@vt.edu wrote:
> On Tue, 29 Jan 2019 00:22:26 +0100, Daniel Borkmann said:
>> I think moving in separate file would be overkill, imho. However, lets get
>> the kdoc and prototype warning fixed.
> 
> I have a bunch of spare time at the moment, so the kdoc and prototype
> warnings are on my to-do list.

Great, thanks!

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

* Re: [PATCH] bpf/core.c - silence warning messages
  2019-01-28 23:22   ` Daniel Borkmann
@ 2019-01-28 23:48     ` valdis.kletnieks
  2019-01-28 23:54       ` Daniel Borkmann
  0 siblings, 1 reply; 10+ messages in thread
From: valdis.kletnieks @ 2019-01-28 23:48 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: Song Liu, Alexei Starovoitov, Networking, open list

On Tue, 29 Jan 2019 00:22:26 +0100, Daniel Borkmann said:
> I think moving in separate file would be overkill, imho. However, lets get
> the kdoc and prototype warning fixed.

I have a bunch of spare time at the moment, so the kdoc and prototype
warnings are on my to-do list.



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

* Re: [PATCH] bpf/core.c - silence warning messages
  2019-01-28 17:18 ` Song Liu
  2019-01-28 23:22   ` Daniel Borkmann
@ 2019-01-28 23:35   ` valdis.kletnieks
  2019-01-29  3:12     ` Song Liu
  1 sibling, 1 reply; 10+ messages in thread
From: valdis.kletnieks @ 2019-01-28 23:35 UTC (permalink / raw)
  To: Song Liu; +Cc: Alexei Starovoitov, Daniel Borkmann, Networking, open list

On Mon, 28 Jan 2019 09:18:45 -0800, Song Liu said:
> On Sun, Jan 27, 2019 at 8:43 PM <valdis.kletnieks@vt.edu> wrote:

> > The attached patch silences the warnings, because we *know* we're overwriting
> > the default initializer. That leaves bpf/core.c with only 6 other warnings,
> > which become more visible in comparison.
>
> My concern is that this will also mute the warning for other parts of
> bpf/core.c.

I checked and there weren't any warnings for other parts of the file.  Also, this message
doesn't even happen unless you build with W=1, which apparently happens so rarely
that nobody else has submitted a patch.

Is there a high likelihood that another overwrite of an initializer is going to
be included in the source?

> Maybe we should move bpf_opcode_in_insntable() to a separate file, and mute
> warning for that file?

Seems to be overkill - the intent of this patch was mostly to make the *other*
warnings issued with W=1 more noticable.


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

* Re: [PATCH] bpf/core.c - silence warning messages
  2019-01-28 17:18 ` Song Liu
@ 2019-01-28 23:22   ` Daniel Borkmann
  2019-01-28 23:48     ` valdis.kletnieks
  2019-01-28 23:35   ` valdis.kletnieks
  1 sibling, 1 reply; 10+ messages in thread
From: Daniel Borkmann @ 2019-01-28 23:22 UTC (permalink / raw)
  To: Song Liu, Valdis Kletnieks; +Cc: Alexei Starovoitov, Networking, open list

On 01/28/2019 06:18 PM, Song Liu wrote:
> On Sun, Jan 27, 2019 at 8:43 PM <valdis.kletnieks@vt.edu> wrote:
>>
>> Compiling kernel/bpf/core.c with W=1 causes a flood of warnings:
>>
>> kernel/bpf/core.c:1198:65: warning: initialized field overwritten [-Woverride-init]
>>  1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
>>       |                                                                 ^~~~
>> kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
>>  1087 |  INSN_3(ALU, ADD,  X),   \
>>       |  ^~~~~~
>> kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
>>  1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
>>       |   ^~~~~~~~~~~~
>> kernel/bpf/core.c:1198:65: note: (near initialization for 'public_insntable[12]')
>>  1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
>>       |                                                                 ^~~~
>> kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
>>  1087 |  INSN_3(ALU, ADD,  X),   \
>>       |  ^~~~~~
>> kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
>>  1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
>>       |   ^~~~~~~~~~~~
>>
>> 98 copies of the above.
>>
>> The attached patch silences the warnings, because we *know* we're overwriting
>> the default initializer. That leaves bpf/core.c with only 6 other warnings,
>> which become more visible in comparison.
> 
> My concern is that this will also mute the warning for other parts of
> bpf/core.c.

Agree, valid concern.

> Maybe we should move bpf_opcode_in_insntable() to a separate file, and mute
> warning for that file?

I think moving in separate file would be overkill, imho. However, lets get
the kdoc and prototype warning fixed.

Thanks,
Daniel

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

* Re: [PATCH] bpf/core.c - silence warning messages
  2019-01-28  4:11 valdis.kletnieks
@ 2019-01-28 17:18 ` Song Liu
  2019-01-28 23:22   ` Daniel Borkmann
  2019-01-28 23:35   ` valdis.kletnieks
  0 siblings, 2 replies; 10+ messages in thread
From: Song Liu @ 2019-01-28 17:18 UTC (permalink / raw)
  To: Valdis Kletnieks
  Cc: Alexei Starovoitov, Daniel Borkmann, Networking, open list

On Sun, Jan 27, 2019 at 8:43 PM <valdis.kletnieks@vt.edu> wrote:
>
> Compiling kernel/bpf/core.c with W=1 causes a flood of warnings:
>
> kernel/bpf/core.c:1198:65: warning: initialized field overwritten [-Woverride-init]
>  1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
>       |                                                                 ^~~~
> kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
>  1087 |  INSN_3(ALU, ADD,  X),   \
>       |  ^~~~~~
> kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
>  1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
>       |   ^~~~~~~~~~~~
> kernel/bpf/core.c:1198:65: note: (near initialization for 'public_insntable[12]')
>  1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
>       |                                                                 ^~~~
> kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
>  1087 |  INSN_3(ALU, ADD,  X),   \
>       |  ^~~~~~
> kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
>  1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
>       |   ^~~~~~~~~~~~
>
> 98 copies of the above.
>
> The attached patch silences the warnings, because we *know* we're overwriting
> the default initializer. That leaves bpf/core.c with only 6 other warnings,
> which become more visible in comparison.

My concern is that this will also mute the warning for other parts of
bpf/core.c.

Maybe we should move bpf_opcode_in_insntable() to a separate file, and mute
warning for that file?

Daniel and Alexei, what do you think?

Thanks,
Song


>
> Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
>
> diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> index 4c2fa3ac56f6..2606665f2cb5 100644
> --- a/kernel/bpf/Makefile
> +++ b/kernel/bpf/Makefile
> @@ -21,3 +21,4 @@ obj-$(CONFIG_CGROUP_BPF) += cgroup.o
>  ifeq ($(CONFIG_INET),y)
>  obj-$(CONFIG_BPF_SYSCALL) += reuseport_array.o
>  endif
> +CFLAGS_core.o          += $(call cc-disable-warning, override-init)
>

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

* [PATCH] bpf/core.c - silence warning messages
@ 2019-01-28  4:11 valdis.kletnieks
  2019-01-28 17:18 ` Song Liu
  0 siblings, 1 reply; 10+ messages in thread
From: valdis.kletnieks @ 2019-01-28  4:11 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann; +Cc: netdev, linux-kernel

Compiling kernel/bpf/core.c with W=1 causes a flood of warnings:

kernel/bpf/core.c:1198:65: warning: initialized field overwritten [-Woverride-init]
 1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
      |                                                                 ^~~~
kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
 1087 |  INSN_3(ALU, ADD,  X),   \
      |  ^~~~~~
kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
 1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
      |   ^~~~~~~~~~~~
kernel/bpf/core.c:1198:65: note: (near initialization for 'public_insntable[12]')
 1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
      |                                                                 ^~~~
kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
 1087 |  INSN_3(ALU, ADD,  X),   \
      |  ^~~~~~
kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
 1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
      |   ^~~~~~~~~~~~

98 copies of the above.

The attached patch silences the warnings, because we *know* we're overwriting
the default initializer. That leaves bpf/core.c with only 6 other warnings,
which become more visible in comparison.

Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>

diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 4c2fa3ac56f6..2606665f2cb5 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_CGROUP_BPF) += cgroup.o
 ifeq ($(CONFIG_INET),y)
 obj-$(CONFIG_BPF_SYSCALL) += reuseport_array.o
 endif
+CFLAGS_core.o          += $(call cc-disable-warning, override-init)


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

end of thread, other threads:[~2019-06-12 14:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-07  2:39 [PATCH] bpf/core.c - silence warning messages Valdis Klētnieks
2019-06-11  5:46 ` Andrii Nakryiko
2019-06-12 14:56 ` Daniel Borkmann
  -- strict thread matches above, loose matches on Subject: below --
2019-01-28  4:11 valdis.kletnieks
2019-01-28 17:18 ` Song Liu
2019-01-28 23:22   ` Daniel Borkmann
2019-01-28 23:48     ` valdis.kletnieks
2019-01-28 23:54       ` Daniel Borkmann
2019-01-28 23:35   ` valdis.kletnieks
2019-01-29  3:12     ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).