public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] kbuild: bpf: Do not run pahole with -j on 32bit userspace
@ 2024-08-20  8:59 Jiri Slaby (SUSE)
  2024-08-20  9:08 ` Jiri Slaby
  2024-08-20 14:33 ` Jiri Olsa
  0 siblings, 2 replies; 19+ messages in thread
From: Jiri Slaby (SUSE) @ 2024-08-20  8:59 UTC (permalink / raw)
  To: masahiroy
  Cc: linux-kernel, Jiri Slaby, Nathan Chancellor, Nicolas Schier,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	linux-kbuild, bpf, shung-hsi.yu, msuchanek

From: Jiri Slaby <jslaby@suse.cz>

== WARNING ==
This is only a PoC. There are deficiencies like CROSS_COMPILE or LLVM
are completely unhandled.

The simple version is just do there:
  ifeq ($(CONFIG_64BIT,y)
but it has its own deficiencies, of course.

So any ideas, inputs?
== WARNING ==

When pahole is run with -j on 32bit userspace (32bit pahole in
particular), it randomly fails with OOM:
> btf_encoder__tag_kfuncs: Failed to get ELF section(62) data: out of memory.
> btf_encoder__encode: failed to tag kfuncs!

or simply SIGSEGV (failed to allocate the btf encoder).

It very depends on how many threads are created.

So do not invoke pahole with -j on 32bit.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Fixes: b4f72786429c ("scripts/pahole-flags.sh: Parse DWARF and generate BTF with multithreading.")
Closes: https://bugzilla.suse.com/show_bug.cgi?id=1229450
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Song Liu <song@kernel.org>
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Stanislav Fomichev <sdf@fomichev.me>
Cc: Hao Luo <haoluo@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-kbuild@vger.kernel.org
Cc: bpf@vger.kernel.org
Cc: shung-hsi.yu@suse.com
Cc: msuchanek@suse.com
---
 init/Kconfig            |  4 ++++
 scripts/Makefile.btf    |  2 ++
 scripts/pahole-class.sh | 21 +++++++++++++++++++++
 3 files changed, 27 insertions(+)
 create mode 100644 scripts/pahole-class.sh

diff --git a/init/Kconfig b/init/Kconfig
index f36ca8a0e209..f5e80497eef0 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -113,6 +113,10 @@ config PAHOLE_VERSION
 	int
 	default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
 
+config PAHOLE_CLASS
+	string
+	default $(shell,$(srctree)/scripts/pahole-class.sh $(PAHOLE))
+
 config CONSTRUCTORS
 	bool
 
diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf
index b75f09f3f424..f7de8e922bce 100644
--- a/scripts/Makefile.btf
+++ b/scripts/Makefile.btf
@@ -12,7 +12,9 @@ endif
 
 pahole-flags-$(call test-ge, $(pahole-ver), 121)	+= --btf_gen_floats
 
+ifeq ($(CONFIG_PAHOLE_CLASS),ELF64)
 pahole-flags-$(call test-ge, $(pahole-ver), 122)	+= -j
+endif
 
 pahole-flags-$(call test-ge, $(pahole-ver), 125)	+= --skip_encoding_btf_inconsistent_proto --btf_gen_optimized
 
diff --git a/scripts/pahole-class.sh b/scripts/pahole-class.sh
new file mode 100644
index 000000000000..d15a92077f76
--- /dev/null
+++ b/scripts/pahole-class.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Usage: $ ./pahole-class.sh pahole
+#
+# Prints pahole's ELF class, such as ELF64
+
+if [ ! -x "$(command -v "$@")" ]; then
+	echo 0
+	exit 1
+fi
+
+PAHOLE="$(which "$@")"
+CLASS="$(readelf -h "$PAHOLE" 2>/dev/null | sed -n 's/.*Class: *// p')"
+
+# Scripts like scripts/dummy-tools/pahole
+if [ -n "$CLASS" ]; then
+	echo "$CLASS"
+else
+	echo ELF64
+fi
-- 
2.46.0


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

end of thread, other threads:[~2024-09-25  8:18 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20  8:59 [RFC] kbuild: bpf: Do not run pahole with -j on 32bit userspace Jiri Slaby (SUSE)
2024-08-20  9:08 ` Jiri Slaby
2024-08-20 14:33 ` Jiri Olsa
2024-08-21  5:32   ` Jiri Slaby
2024-08-21  6:40     ` Jiri Slaby
2024-08-21  7:29       ` Jiri Slaby
2024-08-22  3:55         ` Shung-Hsi Yu
2024-08-22 15:24           ` Arnaldo Carvalho de Melo
2024-08-26  8:57             ` Jiri Slaby
2024-08-26 17:03               ` Arnaldo Carvalho de Melo
2024-08-26 18:42                 ` Sedat Dilek
2024-08-26 18:48                   ` Phil Auld
2024-08-26 20:04                     ` Arnaldo Carvalho de Melo
2024-08-26 22:07                       ` Andrii Nakryiko
2024-08-27  8:37                 ` Jiri Slaby
2024-09-04  6:06                   ` Jiri Slaby
2024-08-26 20:02               ` Arnaldo Carvalho de Melo
2024-08-26 10:18             ` Sedat Dilek
2024-09-25  8:17               ` Sedat Dilek

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