BPF List
 help / color / mirror / Atom feed
* [PATCH bpf] selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build
@ 2024-12-13  0:32 Eduard Zingerman
  2024-12-13  0:34 ` Eduard Zingerman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eduard Zingerman @ 2024-12-13  0:32 UTC (permalink / raw)
  To: bpf, ast
  Cc: andrii, daniel, martin.lau, kernel-team, yonghong.song,
	Eduard Zingerman

BPF_TARGET_ENDIAN is used in CLANG_BPF_BUILD_RULE and co macros.
It is defined as a recursively expanded variable, meaning that it is
recomputed each time the value is needed. Thus, it is recomputed for
each *.bpf.o file compilation. The variable is computed by running a C
compiler in a shell. This significantly hinders parallel build
performance for *.bpf.o files.

This commit changes BPF_TARGET_ENDIAN to be a simply expanded
variable.

    # Build performance stats before this commit
    $ git clean -xfd; time make -j12
    real	1m0.000s
    ...

    # Build performance stats after this commit
    $ git clean -xfd; time make -j12
    real	0m43.605s
    ...

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
---
 tools/testing/selftests/bpf/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index bb8cf8f5bf11..9e870e519c30 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -461,10 +461,10 @@ $(shell $(1) $(2) -dM -E - </dev/null | grep -E 'MIPS(EL|EB)|_MIPS_SZ(PTR|LONG)
 endef
 
 # Determine target endianness.
-IS_LITTLE_ENDIAN = $(shell $(CC) -dM -E - </dev/null | \
+IS_LITTLE_ENDIAN := $(shell $(CC) -dM -E - </dev/null | \
 			grep 'define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__')
-MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
-BPF_TARGET_ENDIAN=$(if $(IS_LITTLE_ENDIAN),--target=bpfel,--target=bpfeb)
+MENDIAN:=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
+BPF_TARGET_ENDIAN:=$(if $(IS_LITTLE_ENDIAN),--target=bpfel,--target=bpfeb)
 
 ifneq ($(CROSS_COMPILE),)
 CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))
-- 
2.47.0


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

* Re: [PATCH bpf] selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build
  2024-12-13  0:32 [PATCH bpf] selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build Eduard Zingerman
@ 2024-12-13  0:34 ` Eduard Zingerman
  2024-12-13  4:41 ` Yonghong Song
  2024-12-13  6:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eduard Zingerman @ 2024-12-13  0:34 UTC (permalink / raw)
  To: bpf, ast; +Cc: andrii, daniel, martin.lau, kernel-team, yonghong.song

On Thu, 2024-12-12 at 16:32 -0800, Eduard Zingerman wrote:

Wrong tree, it should have been 'bpf-next' :(


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

* Re: [PATCH bpf] selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build
  2024-12-13  0:32 [PATCH bpf] selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build Eduard Zingerman
  2024-12-13  0:34 ` Eduard Zingerman
@ 2024-12-13  4:41 ` Yonghong Song
  2024-12-13  6:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Yonghong Song @ 2024-12-13  4:41 UTC (permalink / raw)
  To: Eduard Zingerman, bpf, ast; +Cc: andrii, daniel, martin.lau, kernel-team




On 12/12/24 4:32 PM, Eduard Zingerman wrote:
> BPF_TARGET_ENDIAN is used in CLANG_BPF_BUILD_RULE and co macros.
> It is defined as a recursively expanded variable, meaning that it is
> recomputed each time the value is needed. Thus, it is recomputed for
> each *.bpf.o file compilation. The variable is computed by running a C
> compiler in a shell. This significantly hinders parallel build
> performance for *.bpf.o files.
>
> This commit changes BPF_TARGET_ENDIAN to be a simply expanded
> variable.
>
>      # Build performance stats before this commit
>      $ git clean -xfd; time make -j12
>      real	1m0.000s
>      ...
>
>      # Build performance stats after this commit
>      $ git clean -xfd; time make -j12
>      real	0m43.605s
>      ...
>
> Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>

LGTM except should target to bpf-next.

Acked-by: Yonghong Song <yonghong.song@linux.dev>

> ---
>   tools/testing/selftests/bpf/Makefile | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index bb8cf8f5bf11..9e870e519c30 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -461,10 +461,10 @@ $(shell $(1) $(2) -dM -E - </dev/null | grep -E 'MIPS(EL|EB)|_MIPS_SZ(PTR|LONG)
>   endef
>   
>   # Determine target endianness.
> -IS_LITTLE_ENDIAN = $(shell $(CC) -dM -E - </dev/null | \
> +IS_LITTLE_ENDIAN := $(shell $(CC) -dM -E - </dev/null | \
>   			grep 'define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__')
> -MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
> -BPF_TARGET_ENDIAN=$(if $(IS_LITTLE_ENDIAN),--target=bpfel,--target=bpfeb)
> +MENDIAN:=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
> +BPF_TARGET_ENDIAN:=$(if $(IS_LITTLE_ENDIAN),--target=bpfel,--target=bpfeb)
>   
>   ifneq ($(CROSS_COMPILE),)
>   CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))


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

* Re: [PATCH bpf] selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build
  2024-12-13  0:32 [PATCH bpf] selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build Eduard Zingerman
  2024-12-13  0:34 ` Eduard Zingerman
  2024-12-13  4:41 ` Yonghong Song
@ 2024-12-13  6:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-13  6:10 UTC (permalink / raw)
  To: Eduard Zingerman
  Cc: bpf, ast, andrii, daniel, martin.lau, kernel-team, yonghong.song

Hello:

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

On Thu, 12 Dec 2024 16:32:24 -0800 you wrote:
> BPF_TARGET_ENDIAN is used in CLANG_BPF_BUILD_RULE and co macros.
> It is defined as a recursively expanded variable, meaning that it is
> recomputed each time the value is needed. Thus, it is recomputed for
> each *.bpf.o file compilation. The variable is computed by running a C
> compiler in a shell. This significantly hinders parallel build
> performance for *.bpf.o files.
> 
> [...]

Here is the summary with links:
  - [bpf] selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build
    https://git.kernel.org/bpf/bpf-next/c/5506b7d7bbdb

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

end of thread, other threads:[~2024-12-13  6:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13  0:32 [PATCH bpf] selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build Eduard Zingerman
2024-12-13  0:34 ` Eduard Zingerman
2024-12-13  4:41 ` Yonghong Song
2024-12-13  6:10 ` 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