BPF List
 help / color / mirror / Atom feed
* [PATCH v1] bpf: Add missing force_checksrc macro
@ 2024-08-28 15:25 Alexey Gladkov
  2024-08-28 16:32 ` Masahiro Yamada
  0 siblings, 1 reply; 12+ messages in thread
From: Alexey Gladkov @ 2024-08-28 15:25 UTC (permalink / raw)
  To: linux-kernel, bpf, linux-kbuild
  Cc: Masahiro Yamada, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Oleg Nesterov

According to the documentation, when building a kernel with the C=2
parameter, all source files should be checked. But this does not happen
for the kernel/bpf/ directory.

$ touch kernel/bpf/core.o
$ make C=2 CHECK=true kernel/bpf/core.o

Outputs:

  CHECK   scripts/mod/empty.c
  CALL    scripts/checksyscalls.sh
  DESCEND objtool
  INSTALL libsubcmd_headers
  CC      kernel/bpf/core.o

As can be seen the compilation is done, but CHECK is not executed. This
happens because kernel/bpf/Makefile has defined its own rule for
compilation and forgotten the macro that does the check.

Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
 kernel/bpf/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 0291eef9ce92..f0ba6bf73bb6 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -58,3 +58,4 @@ vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
 
 $(obj)/%.o: %.c FORCE
 	$(call if_changed_rule,cc_o_c)
+	$(call cmd,force_checksrc)
-- 
2.46.0


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

* Re: [PATCH v1] bpf: Add missing force_checksrc macro
  2024-08-28 15:25 [PATCH v1] bpf: Add missing force_checksrc macro Alexey Gladkov
@ 2024-08-28 16:32 ` Masahiro Yamada
  2024-08-28 17:06   ` [PATCH v2] bpf: Remove custom build rule Alexey Gladkov
  0 siblings, 1 reply; 12+ messages in thread
From: Masahiro Yamada @ 2024-08-28 16:32 UTC (permalink / raw)
  To: Alexey Gladkov
  Cc: linux-kernel, bpf, linux-kbuild, Alexei Starovoitov,
	Andrii Nakryiko, Daniel Borkmann, Oleg Nesterov

On Thu, Aug 29, 2024 at 12:42 AM Alexey Gladkov <legion@kernel.org> wrote:
>
> According to the documentation, when building a kernel with the C=2
> parameter, all source files should be checked. But this does not happen
> for the kernel/bpf/ directory.
>
> $ touch kernel/bpf/core.o
> $ make C=2 CHECK=true kernel/bpf/core.o
>
> Outputs:
>
>   CHECK   scripts/mod/empty.c
>   CALL    scripts/checksyscalls.sh
>   DESCEND objtool
>   INSTALL libsubcmd_headers
>   CC      kernel/bpf/core.o
>
> As can be seen the compilation is done, but CHECK is not executed. This
> happens because kernel/bpf/Makefile has defined its own rule for
> compilation and forgotten the macro that does the check.
>
> Signed-off-by: Alexey Gladkov <legion@kernel.org>


NACK.


This Makefile is already screwed up.

There is no need to duplicate the build code.

Please remove the last 6 lines of kernel/bpf/Makefile



See the following code as an example:
arch/arm/boot/compressed/fdt_rw.c




Like this:

$ cat kernel/bpf/btf_iter.c
#include "../../tools/lib/bpf/btf_iter.c"


Same for
kernel/bpf/btf_relocate.c
kernel/bpf/relo_core.c









> ---
>  kernel/bpf/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> index 0291eef9ce92..f0ba6bf73bb6 100644
> --- a/kernel/bpf/Makefile
> +++ b/kernel/bpf/Makefile
> @@ -58,3 +58,4 @@ vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
>
>  $(obj)/%.o: %.c FORCE
>         $(call if_changed_rule,cc_o_c)
> +       $(call cmd,force_checksrc)
> --
> 2.46.0
>
>


-- 
Best Regards
Masahiro Yamada

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

* [PATCH v2] bpf: Remove custom build rule
  2024-08-28 16:32 ` Masahiro Yamada
@ 2024-08-28 17:06   ` Alexey Gladkov
  2024-08-28 17:22     ` Masahiro Yamada
  0 siblings, 1 reply; 12+ messages in thread
From: Alexey Gladkov @ 2024-08-28 17:06 UTC (permalink / raw)
  To: linux-kernel, bpf, linux-kbuild
  Cc: Masahiro Yamada, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Oleg Nesterov

According to the documentation, when building a kernel with the C=2
parameter, all source files should be checked. But this does not happen
for the kernel/bpf/ directory.

$ touch kernel/bpf/core.o
$ make C=2 CHECK=true kernel/bpf/core.o

Outputs:

  CHECK   scripts/mod/empty.c
  CALL    scripts/checksyscalls.sh
  DESCEND objtool
  INSTALL libsubcmd_headers
  CC      kernel/bpf/core.o

As can be seen the compilation is done, but CHECK is not executed. This
happens because kernel/bpf/Makefile has defined its own rule for
compilation and forgotten the macro that does the check.

There is no need to duplicate the build code, and this rule can be
removed to use generic rules.

Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
 kernel/bpf/Makefile | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 0291eef9ce92..9b9c151b5c82 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/
 obj-$(CONFIG_BPF_SYSCALL) += relo_core.o
 obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o
 obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o
-
-# Some source files are common to libbpf.
-vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
-
-$(obj)/%.o: %.c FORCE
-	$(call if_changed_rule,cc_o_c)
-- 
2.46.0


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

* Re: [PATCH v2] bpf: Remove custom build rule
  2024-08-28 17:06   ` [PATCH v2] bpf: Remove custom build rule Alexey Gladkov
@ 2024-08-28 17:22     ` Masahiro Yamada
  2024-08-28 17:49       ` Alexey Gladkov
  2024-08-28 18:10       ` [PATCH v3] " Alexey Gladkov
  0 siblings, 2 replies; 12+ messages in thread
From: Masahiro Yamada @ 2024-08-28 17:22 UTC (permalink / raw)
  To: Alexey Gladkov
  Cc: linux-kernel, bpf, linux-kbuild, Alexei Starovoitov,
	Andrii Nakryiko, Daniel Borkmann, Oleg Nesterov

On Thu, Aug 29, 2024 at 2:07 AM Alexey Gladkov <legion@kernel.org> wrote:
>
> According to the documentation, when building a kernel with the C=2
> parameter, all source files should be checked. But this does not happen
> for the kernel/bpf/ directory.
>
> $ touch kernel/bpf/core.o
> $ make C=2 CHECK=true kernel/bpf/core.o
>
> Outputs:
>
>   CHECK   scripts/mod/empty.c
>   CALL    scripts/checksyscalls.sh
>   DESCEND objtool
>   INSTALL libsubcmd_headers
>   CC      kernel/bpf/core.o
>
> As can be seen the compilation is done, but CHECK is not executed. This
> happens because kernel/bpf/Makefile has defined its own rule for
> compilation and forgotten the macro that does the check.
>
> There is no need to duplicate the build code, and this rule can be
> removed to use generic rules.
>
> Signed-off-by: Alexey Gladkov <legion@kernel.org>


Did you compile-test this?

See my previous email.




I said this:

$ cat kernel/bpf/btf_iter.c
#include "../../tools/lib/bpf/btf_iter.c"


Same for
kernel/bpf/btf_relocate.c
kernel/bpf/relo_core.c











> ---
>  kernel/bpf/Makefile | 6 ------
>  1 file changed, 6 deletions(-)
>
> diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> index 0291eef9ce92..9b9c151b5c82 100644
> --- a/kernel/bpf/Makefile
> +++ b/kernel/bpf/Makefile
> @@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/
>  obj-$(CONFIG_BPF_SYSCALL) += relo_core.o
>  obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o
>  obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o
> -
> -# Some source files are common to libbpf.
> -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
> -
> -$(obj)/%.o: %.c FORCE
> -       $(call if_changed_rule,cc_o_c)
> --
> 2.46.0
>


--
Best Regards
Masahiro Yamada

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

* Re: [PATCH v2] bpf: Remove custom build rule
  2024-08-28 17:22     ` Masahiro Yamada
@ 2024-08-28 17:49       ` Alexey Gladkov
  2024-08-28 18:10       ` [PATCH v3] " Alexey Gladkov
  1 sibling, 0 replies; 12+ messages in thread
From: Alexey Gladkov @ 2024-08-28 17:49 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kernel, bpf, linux-kbuild, Alexei Starovoitov,
	Andrii Nakryiko, Daniel Borkmann, Oleg Nesterov

On Thu, Aug 29, 2024 at 02:22:33AM +0900, Masahiro Yamada wrote:
> On Thu, Aug 29, 2024 at 2:07 AM Alexey Gladkov <legion@kernel.org> wrote:
> >
> > According to the documentation, when building a kernel with the C=2
> > parameter, all source files should be checked. But this does not happen
> > for the kernel/bpf/ directory.
> >
> > $ touch kernel/bpf/core.o
> > $ make C=2 CHECK=true kernel/bpf/core.o
> >
> > Outputs:
> >
> >   CHECK   scripts/mod/empty.c
> >   CALL    scripts/checksyscalls.sh
> >   DESCEND objtool
> >   INSTALL libsubcmd_headers
> >   CC      kernel/bpf/core.o
> >
> > As can be seen the compilation is done, but CHECK is not executed. This
> > happens because kernel/bpf/Makefile has defined its own rule for
> > compilation and forgotten the macro that does the check.
> >
> > There is no need to duplicate the build code, and this rule can be
> > removed to use generic rules.
> >
> > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> 
> 
> Did you compile-test this?

Yes. I repeated my steps for reproduce:

$ touch kernel/bpf/core.c
$ make C=2 CHECK=true |grep kernel/bpf/core
  CC      kernel/bpf/core.o
  CHECK   kernel/bpf/core.c

but maybe my config is too small.

> 
> See my previous email.
> 
> 
> 
> 
> I said this:
> 
> $ cat kernel/bpf/btf_iter.c
> #include "../../tools/lib/bpf/btf_iter.c"
> 
> 
> Same for
> kernel/bpf/btf_relocate.c
> kernel/bpf/relo_core.c
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> > ---
> >  kernel/bpf/Makefile | 6 ------
> >  1 file changed, 6 deletions(-)
> >
> > diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> > index 0291eef9ce92..9b9c151b5c82 100644
> > --- a/kernel/bpf/Makefile
> > +++ b/kernel/bpf/Makefile
> > @@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/
> >  obj-$(CONFIG_BPF_SYSCALL) += relo_core.o
> >  obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o
> >  obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o
> > -
> > -# Some source files are common to libbpf.
> > -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
> > -
> > -$(obj)/%.o: %.c FORCE
> > -       $(call if_changed_rule,cc_o_c)
> > --
> > 2.46.0
> >
> 
> 
> --
> Best Regards
> Masahiro Yamada
> 

-- 
Rgrds, legion


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

* [PATCH v3] bpf: Remove custom build rule
  2024-08-28 17:22     ` Masahiro Yamada
  2024-08-28 17:49       ` Alexey Gladkov
@ 2024-08-28 18:10       ` Alexey Gladkov
  2024-08-28 18:32         ` Masahiro Yamada
                           ` (3 more replies)
  1 sibling, 4 replies; 12+ messages in thread
From: Alexey Gladkov @ 2024-08-28 18:10 UTC (permalink / raw)
  To: linux-kernel, bpf, linux-kbuild
  Cc: Masahiro Yamada, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Oleg Nesterov

According to the documentation, when building a kernel with the C=2
parameter, all source files should be checked. But this does not happen
for the kernel/bpf/ directory.

$ touch kernel/bpf/core.c
$ make C=2 CHECK=true kernel/bpf/core.o

Outputs:

  CHECK   scripts/mod/empty.c
  CALL    scripts/checksyscalls.sh
  DESCEND objtool
  INSTALL libsubcmd_headers
  CC      kernel/bpf/core.o

As can be seen the compilation is done, but CHECK is not executed. This
happens because kernel/bpf/Makefile has defined its own rule for
compilation and forgotten the macro that does the check.

There is no need to duplicate the build code, and this rule can be
removed to use generic rules.

Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
 kernel/bpf/Makefile       | 6 ------
 kernel/bpf/btf_iter.c     | 2 ++
 kernel/bpf/btf_relocate.c | 2 ++
 kernel/bpf/relo_core.c    | 2 ++
 4 files changed, 6 insertions(+), 6 deletions(-)
 create mode 100644 kernel/bpf/btf_iter.c
 create mode 100644 kernel/bpf/btf_relocate.c
 create mode 100644 kernel/bpf/relo_core.c

diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 0291eef9ce92..9b9c151b5c82 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/
 obj-$(CONFIG_BPF_SYSCALL) += relo_core.o
 obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o
 obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o
-
-# Some source files are common to libbpf.
-vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
-
-$(obj)/%.o: %.c FORCE
-	$(call if_changed_rule,cc_o_c)
diff --git a/kernel/bpf/btf_iter.c b/kernel/bpf/btf_iter.c
new file mode 100644
index 000000000000..eab8493a1669
--- /dev/null
+++ b/kernel/bpf/btf_iter.c
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include "../../tools/lib/bpf/btf_iter.c"
diff --git a/kernel/bpf/btf_relocate.c b/kernel/bpf/btf_relocate.c
new file mode 100644
index 000000000000..8c89c7b59ef8
--- /dev/null
+++ b/kernel/bpf/btf_relocate.c
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include "../../tools/lib/bpf/btf_relocate.c"
diff --git a/kernel/bpf/relo_core.c b/kernel/bpf/relo_core.c
new file mode 100644
index 000000000000..6a36fbc0e5ab
--- /dev/null
+++ b/kernel/bpf/relo_core.c
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include "../../tools/lib/bpf/relo_core.c"
-- 
2.46.0


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

* Re: [PATCH v3] bpf: Remove custom build rule
  2024-08-28 18:10       ` [PATCH v3] " Alexey Gladkov
@ 2024-08-28 18:32         ` Masahiro Yamada
  2024-08-28 19:14         ` Oleg Nesterov
                           ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Masahiro Yamada @ 2024-08-28 18:32 UTC (permalink / raw)
  To: Alexey Gladkov
  Cc: linux-kernel, bpf, linux-kbuild, Alexei Starovoitov,
	Andrii Nakryiko, Daniel Borkmann, Oleg Nesterov

On Thu, Aug 29, 2024 at 3:11 AM Alexey Gladkov <legion@kernel.org> wrote:
>
> According to the documentation, when building a kernel with the C=2
> parameter, all source files should be checked. But this does not happen
> for the kernel/bpf/ directory.
>
> $ touch kernel/bpf/core.c
> $ make C=2 CHECK=true kernel/bpf/core.o
>
> Outputs:
>
>   CHECK   scripts/mod/empty.c
>   CALL    scripts/checksyscalls.sh
>   DESCEND objtool
>   INSTALL libsubcmd_headers
>   CC      kernel/bpf/core.o
>
> As can be seen the compilation is done, but CHECK is not executed. This
> happens because kernel/bpf/Makefile has defined its own rule for
> compilation and forgotten the macro that does the check.
>
> There is no need to duplicate the build code, and this rule can be
> removed to use generic rules.
>
> Signed-off-by: Alexey Gladkov <legion@kernel.org>


Acked-by: Masahiro Yamada <masahiroy@kernel.org>


> ---
>  kernel/bpf/Makefile       | 6 ------
>  kernel/bpf/btf_iter.c     | 2 ++
>  kernel/bpf/btf_relocate.c | 2 ++
>  kernel/bpf/relo_core.c    | 2 ++
>  4 files changed, 6 insertions(+), 6 deletions(-)
>  create mode 100644 kernel/bpf/btf_iter.c
>  create mode 100644 kernel/bpf/btf_relocate.c
>  create mode 100644 kernel/bpf/relo_core.c
>
> diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> index 0291eef9ce92..9b9c151b5c82 100644
> --- a/kernel/bpf/Makefile
> +++ b/kernel/bpf/Makefile
> @@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/
>  obj-$(CONFIG_BPF_SYSCALL) += relo_core.o
>  obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o
>  obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o
> -
> -# Some source files are common to libbpf.
> -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
> -
> -$(obj)/%.o: %.c FORCE
> -       $(call if_changed_rule,cc_o_c)
> diff --git a/kernel/bpf/btf_iter.c b/kernel/bpf/btf_iter.c
> new file mode 100644
> index 000000000000..eab8493a1669
> --- /dev/null
> +++ b/kernel/bpf/btf_iter.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/btf_iter.c"
> diff --git a/kernel/bpf/btf_relocate.c b/kernel/bpf/btf_relocate.c
> new file mode 100644
> index 000000000000..8c89c7b59ef8
> --- /dev/null
> +++ b/kernel/bpf/btf_relocate.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/btf_relocate.c"
> diff --git a/kernel/bpf/relo_core.c b/kernel/bpf/relo_core.c
> new file mode 100644
> index 000000000000..6a36fbc0e5ab
> --- /dev/null
> +++ b/kernel/bpf/relo_core.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/relo_core.c"
> --
> 2.46.0
>


-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH v3] bpf: Remove custom build rule
  2024-08-28 18:10       ` [PATCH v3] " Alexey Gladkov
  2024-08-28 18:32         ` Masahiro Yamada
@ 2024-08-28 19:14         ` Oleg Nesterov
  2024-08-29 10:12         ` Alan Maguire
  2024-08-29 19:24         ` Alexei Starovoitov
  3 siblings, 0 replies; 12+ messages in thread
From: Oleg Nesterov @ 2024-08-28 19:14 UTC (permalink / raw)
  To: Alexey Gladkov
  Cc: linux-kernel, bpf, linux-kbuild, Masahiro Yamada,
	Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann

I know nothing about Kbuild, I can only confirm that this patch fixes the
problem I encountered in practice.

On 08/28, Alexey Gladkov wrote:
>
> $ touch kernel/bpf/core.c
> $ make C=2 CHECK=true kernel/bpf/core.o
>
> Outputs:
>
>   CHECK   scripts/mod/empty.c
>   CALL    scripts/checksyscalls.sh
>   DESCEND objtool
>   INSTALL libsubcmd_headers
>   CC      kernel/bpf/core.o
>
> As can be seen the compilation is done, but CHECK is not executed.

And after that

	$ make C=2 CHECK=true kernel/bpf/core.o
	  CHECK   scripts/mod/empty.c
	  CALL    scripts/checksyscalls.sh
	  DESCEND objtool
	  INSTALL libsubcmd_headers

CHECK is also not executed.

compare with, for example,

	$ touch kernel/trace/trace.c
	$ make C=2 CHECK=true kernel/trace/trace.o
	  CHECK   scripts/mod/empty.c
	  CALL    scripts/checksyscalls.sh
	  DESCEND objtool
	  INSTALL libsubcmd_headers
	  CC      kernel/trace/trace.o
	  CHECK   kernel/trace/trace.c
	$ make C=2 CHECK=true kernel/trace/trace.o
	  CHECK   scripts/mod/empty.c
	  CALL    scripts/checksyscalls.sh
	  DESCEND objtool
	  INSTALL libsubcmd_headers
	  CHECK   kernel/trace/trace.c

Tested-by: Oleg Nesterov <oleg@redhat.com>


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

* Re: [PATCH v3] bpf: Remove custom build rule
  2024-08-28 18:10       ` [PATCH v3] " Alexey Gladkov
  2024-08-28 18:32         ` Masahiro Yamada
  2024-08-28 19:14         ` Oleg Nesterov
@ 2024-08-29 10:12         ` Alan Maguire
  2024-08-29 19:24         ` Alexei Starovoitov
  3 siblings, 0 replies; 12+ messages in thread
From: Alan Maguire @ 2024-08-29 10:12 UTC (permalink / raw)
  To: Alexey Gladkov, linux-kernel, bpf, linux-kbuild
  Cc: Masahiro Yamada, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Oleg Nesterov

On 28/08/2024 19:10, Alexey Gladkov wrote:
> According to the documentation, when building a kernel with the C=2
> parameter, all source files should be checked. But this does not happen
> for the kernel/bpf/ directory.
> 
> $ touch kernel/bpf/core.c
> $ make C=2 CHECK=true kernel/bpf/core.o
> 
> Outputs:
> 
>   CHECK   scripts/mod/empty.c
>   CALL    scripts/checksyscalls.sh
>   DESCEND objtool
>   INSTALL libsubcmd_headers
>   CC      kernel/bpf/core.o
> 
> As can be seen the compilation is done, but CHECK is not executed. This
> happens because kernel/bpf/Makefile has defined its own rule for
> compilation and forgotten the macro that does the check.
> 
> There is no need to duplicate the build code, and this rule can be
> removed to use generic rules.
> 
> Signed-off-by: Alexey Gladkov <legion@kernel.org>

Tested-by: Alan Maguire <alan.maguire@oracle.com>

The aim from the BPF side is just to share the btf_iter.c,
btf_relocate.c and relo_core.c files for both libbpf and kernel build.
Those files need to live in tools/lib/bpf because the libbpf standalone
repo on github is built from tools/lib/bpf.

Since the approach in this patch continues to support that while it
doesn't break other things like check targets it's definitely preferred.

Thanks for the fix!

Alan

> ---
>  kernel/bpf/Makefile       | 6 ------
>  kernel/bpf/btf_iter.c     | 2 ++
>  kernel/bpf/btf_relocate.c | 2 ++
>  kernel/bpf/relo_core.c    | 2 ++
>  4 files changed, 6 insertions(+), 6 deletions(-)
>  create mode 100644 kernel/bpf/btf_iter.c
>  create mode 100644 kernel/bpf/btf_relocate.c
>  create mode 100644 kernel/bpf/relo_core.c
> 
> diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> index 0291eef9ce92..9b9c151b5c82 100644
> --- a/kernel/bpf/Makefile
> +++ b/kernel/bpf/Makefile
> @@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/
>  obj-$(CONFIG_BPF_SYSCALL) += relo_core.o
>  obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o
>  obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o
> -
> -# Some source files are common to libbpf.
> -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
> -
> -$(obj)/%.o: %.c FORCE
> -	$(call if_changed_rule,cc_o_c)
> diff --git a/kernel/bpf/btf_iter.c b/kernel/bpf/btf_iter.c
> new file mode 100644
> index 000000000000..eab8493a1669
> --- /dev/null
> +++ b/kernel/bpf/btf_iter.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/btf_iter.c"
> diff --git a/kernel/bpf/btf_relocate.c b/kernel/bpf/btf_relocate.c
> new file mode 100644
> index 000000000000..8c89c7b59ef8
> --- /dev/null
> +++ b/kernel/bpf/btf_relocate.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/btf_relocate.c"
> diff --git a/kernel/bpf/relo_core.c b/kernel/bpf/relo_core.c
> new file mode 100644
> index 000000000000..6a36fbc0e5ab
> --- /dev/null
> +++ b/kernel/bpf/relo_core.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/relo_core.c"

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

* Re: [PATCH v3] bpf: Remove custom build rule
  2024-08-28 18:10       ` [PATCH v3] " Alexey Gladkov
                           ` (2 preceding siblings ...)
  2024-08-29 10:12         ` Alan Maguire
@ 2024-08-29 19:24         ` Alexei Starovoitov
  2024-08-30  7:43           ` [PATCH v4] " Alexey Gladkov
  3 siblings, 1 reply; 12+ messages in thread
From: Alexei Starovoitov @ 2024-08-29 19:24 UTC (permalink / raw)
  To: Alexey Gladkov
  Cc: LKML, bpf, Linux Kbuild mailing list, Masahiro Yamada,
	Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Oleg Nesterov

On Wed, Aug 28, 2024 at 11:11 AM Alexey Gladkov <legion@kernel.org> wrote:
>
> --- /dev/null
> +++ b/kernel/bpf/btf_iter.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/btf_iter.c"

These files are licensed as
// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
in libbpf directory.
Pls use that.

Pls keep acks/reviews-bys/tested-by when you respin.

Thanks

pw-bot: cr

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

* [PATCH v4] bpf: Remove custom build rule
  2024-08-29 19:24         ` Alexei Starovoitov
@ 2024-08-30  7:43           ` Alexey Gladkov
  2024-08-30 16:00             ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 12+ messages in thread
From: Alexey Gladkov @ 2024-08-30  7:43 UTC (permalink / raw)
  To: linux-kernel, bpf, linux-kbuild
  Cc: Masahiro Yamada, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Oleg Nesterov, Alan Maguire

According to the documentation, when building a kernel with the C=2
parameter, all source files should be checked. But this does not happen
for the kernel/bpf/ directory.

$ touch kernel/bpf/core.o
$ make C=2 CHECK=true kernel/bpf/core.o

Outputs:

  CHECK   scripts/mod/empty.c
  CALL    scripts/checksyscalls.sh
  DESCEND objtool
  INSTALL libsubcmd_headers
  CC      kernel/bpf/core.o

As can be seen the compilation is done, but CHECK is not executed. This
happens because kernel/bpf/Makefile has defined its own rule for
compilation and forgotten the macro that does the check.

There is no need to duplicate the build code, and this rule can be
removed to use generic rules.

Acked-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Oleg Nesterov <oleg@redhat.com>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
 kernel/bpf/Makefile       | 6 ------
 kernel/bpf/btf_iter.c     | 2 ++
 kernel/bpf/btf_relocate.c | 2 ++
 kernel/bpf/relo_core.c    | 2 ++
 4 files changed, 6 insertions(+), 6 deletions(-)
 create mode 100644 kernel/bpf/btf_iter.c
 create mode 100644 kernel/bpf/btf_relocate.c
 create mode 100644 kernel/bpf/relo_core.c

diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 0291eef9ce92..9b9c151b5c82 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/
 obj-$(CONFIG_BPF_SYSCALL) += relo_core.o
 obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o
 obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o
-
-# Some source files are common to libbpf.
-vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
-
-$(obj)/%.o: %.c FORCE
-	$(call if_changed_rule,cc_o_c)
diff --git a/kernel/bpf/btf_iter.c b/kernel/bpf/btf_iter.c
new file mode 100644
index 000000000000..0e2c66a52df9
--- /dev/null
+++ b/kernel/bpf/btf_iter.c
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+#include "../../tools/lib/bpf/btf_iter.c"
diff --git a/kernel/bpf/btf_relocate.c b/kernel/bpf/btf_relocate.c
new file mode 100644
index 000000000000..c12ccbf66507
--- /dev/null
+++ b/kernel/bpf/btf_relocate.c
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+#include "../../tools/lib/bpf/btf_relocate.c"
diff --git a/kernel/bpf/relo_core.c b/kernel/bpf/relo_core.c
new file mode 100644
index 000000000000..aa822c9fcfde
--- /dev/null
+++ b/kernel/bpf/relo_core.c
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+#include "../../tools/lib/bpf/relo_core.c"
-- 
2.46.0


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

* Re: [PATCH v4] bpf: Remove custom build rule
  2024-08-30  7:43           ` [PATCH v4] " Alexey Gladkov
@ 2024-08-30 16:00             ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-30 16:00 UTC (permalink / raw)
  To: Alexey Gladkov
  Cc: linux-kernel, bpf, linux-kbuild, masahiroy, ast, andrii, daniel,
	oleg, alan.maguire

Hello:

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

On Fri, 30 Aug 2024 09:43:50 +0200 you wrote:
> According to the documentation, when building a kernel with the C=2
> parameter, all source files should be checked. But this does not happen
> for the kernel/bpf/ directory.
> 
> $ touch kernel/bpf/core.o
> $ make C=2 CHECK=true kernel/bpf/core.o
> 
> [...]

Here is the summary with links:
  - [v4] bpf: Remove custom build rule
    https://git.kernel.org/bpf/bpf-next/c/1dd7622ef508

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] 12+ messages in thread

end of thread, other threads:[~2024-08-30 16:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 15:25 [PATCH v1] bpf: Add missing force_checksrc macro Alexey Gladkov
2024-08-28 16:32 ` Masahiro Yamada
2024-08-28 17:06   ` [PATCH v2] bpf: Remove custom build rule Alexey Gladkov
2024-08-28 17:22     ` Masahiro Yamada
2024-08-28 17:49       ` Alexey Gladkov
2024-08-28 18:10       ` [PATCH v3] " Alexey Gladkov
2024-08-28 18:32         ` Masahiro Yamada
2024-08-28 19:14         ` Oleg Nesterov
2024-08-29 10:12         ` Alan Maguire
2024-08-29 19:24         ` Alexei Starovoitov
2024-08-30  7:43           ` [PATCH v4] " Alexey Gladkov
2024-08-30 16:00             ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox