[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240820085950.200358-1-jirislaby@kernel.org>
Date: Tue, 20 Aug 2024 10:59:50 +0200
From: "Jiri Slaby (SUSE)" <jirislaby@...nel.org>
To: masahiroy@...nel.org
Cc: linux-kernel@...r.kernel.org,
Jiri Slaby <jslaby@...e.cz>,
Nathan Chancellor <nathan@...nel.org>,
Nicolas Schier <nicolas@...sle.eu>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>,
Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>,
Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>,
linux-kbuild@...r.kernel.org,
bpf@...r.kernel.org,
shung-hsi.yu@...e.com,
msuchanek@...e.com
Subject: [RFC] kbuild: bpf: Do not run pahole with -j on 32bit userspace
From: Jiri Slaby <jslaby@...e.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@...e.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@...nel.org>
Cc: Nathan Chancellor <nathan@...nel.org>
Cc: Nicolas Schier <nicolas@...sle.eu>
Cc: Alexei Starovoitov <ast@...nel.org>
Cc: Daniel Borkmann <daniel@...earbox.net>
Cc: Andrii Nakryiko <andrii@...nel.org>
Cc: Martin KaFai Lau <martin.lau@...ux.dev>
Cc: Eduard Zingerman <eddyz87@...il.com>
Cc: Song Liu <song@...nel.org>
Cc: Yonghong Song <yonghong.song@...ux.dev>
Cc: John Fastabend <john.fastabend@...il.com>
Cc: KP Singh <kpsingh@...nel.org>
Cc: Stanislav Fomichev <sdf@...ichev.me>
Cc: Hao Luo <haoluo@...gle.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: linux-kernel@...r.kernel.org
Cc: linux-kbuild@...r.kernel.org
Cc: bpf@...r.kernel.org
Cc: shung-hsi.yu@...e.com
Cc: msuchanek@...e.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
Powered by blists - more mailing lists