Skip to contentSkip to conversation

Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

PATCH Applied Nathan Chancellor 7 participants 27 messages Feb 1, 2022 – Feb 23, 2023

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

Hi all,

This series allows CONFIG_DEBUG_INFO_DWARF5 to be selected with CONFIG_DEBUG_INFO_BTF=y by checking the pahole version.

The first four patches add CONFIG_PAHOLE_VERSION and scripts/pahole-version.sh to clean up all the places that pahole's version is transformed into a 3-digit form.

The fourth patch adds a PAHOLE_VERSION dependency to DEBUG_INFO_DWARF5 so that there are no build errors when it is selected with DEBUG_INFO_BTF.

I build tested Fedora's aarch64 and x86_64 config with ToT clang 14.0.0 and GCC 11 with CONFIG_DEBUG_INFO_DWARF5 enabled with both pahole 1.21 and 1.23.

Nathan Chancellor (5):
MAINTAINERS: Add scripts/pahole-flags.sh to BPF section
kbuild: Add CONFIG_PAHOLE_VERSION scripts/pahole-flags.sh: Use pahole-version.sh lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

 MAINTAINERS               |  2 ++
 init/Kconfig              |  4 ++++
 lib/Kconfig.debug         |  6 +++---
 scripts/pahole-flags.sh   |  2 +-
 scripts/pahole-version.sh | 13 +++++++++++++
 5 files changed, 23 insertions(+), 4 deletions(-)
 create mode 100755 scripts/pahole-version.sh

base-commit: 533de4aea6a91eb670ff8ff2b082bb34f2c5d6ab

Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/5 MAINTAINERS: Add scripts/pahole-flags.sh to BPF section

Currently, scripts/pahole-flags.sh has no formal maintainer. Add it to the BPF section so that patches to it can be properly reviewed and picked up.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 0d7883977e9b..0d422452c8ff 100644
@@ -3523,6 +3523,7 @@ F:	net/sched/act_bpf.c
 F:	net/sched/cls_bpf.c
 F:	samples/bpf/
 F:	scripts/bpf_doc.py
+F:	scripts/pahole-flags.sh
 F:	tools/bpf/
 F:	tools/lib/bpf/
 F:	tools/testing/selftests/bpf/
Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/5 kbuild: Add CONFIG_PAHOLE_VERSION

In reply to Nathan Chancellor

There are a few different places where pahole's version is turned into a three digit form with the exact same command. Move this command into scripts/pahole-version.sh to reduce the amount of duplication across the tree.

Create CONFIG_PAHOLE_VERSION so the version code can be used in Kconfig to enable and disable configuration options based on the pahole version, which is already done in a couple of places.

---
 MAINTAINERS               |  1 +
 init/Kconfig              |  4 ++++
 scripts/pahole-version.sh | 13 +++++++++++++
 3 files changed, 18 insertions(+)
 create mode 100755 scripts/pahole-version.sh
MAINTAINERS +1 -0
index 0d422452c8ff..d8a66d50f224 100644
@@ -3524,6 +3524,7 @@ F:	net/sched/cls_bpf.c
 F:	samples/bpf/
 F:	scripts/bpf_doc.py
 F:	scripts/pahole-flags.sh
+F:	scripts/pahole-version.sh
 F:	tools/bpf/
 F:	tools/lib/bpf/
 F:	tools/testing/selftests/bpf/
init/Kconfig +4 -0
index e9119bf54b1f..7328d4f25370 100644
@@ -86,6 +86,10 @@ config CC_HAS_ASM_INLINE
 config CC_HAS_NO_PROFILE_FN_ATTR
 	def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
 
+config PAHOLE_VERSION
+	int
+	default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
+
 config CONSTRUCTORS
 	bool
 
scripts/pahole-version.sh new file +13 -0
new file mode 100755
index 000000000000..f8a32ab93ad1
@@ -0,0 +1,13 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Usage: $ ./pahole-version.sh pahole
+#
+# Prints pahole's version in a 3-digit form, such as 119 for v1.19.
+
+if [ ! -x "$(command -v "$@")" ]; then
+	echo 0
+	exit 1
+fi
+
+"$@" --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'
Signature · 1 line
2.35.1
#3 lore raw

PATCH 3/5 scripts/pahole-flags.sh: Use pahole-version.sh

In reply to Nathan Chancellor

Use pahole-version.sh to get pahole's version code to reduce the amount of duplication across the tree.

---
 scripts/pahole-flags.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/pahole-flags.sh +1 -1
index e6093adf4c06..c293941612e7 100755
@@ -7,7 +7,7 @@ if ! [ -x "$(command -v ${PAHOLE})" ]; then
 	exit 0
 fi
 
-pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
+pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE})
 
 if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
 	# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
Signature · 1 line
2.35.1
#4 lore raw

PATCH 4/5 lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION

In reply to Nathan Chancellor

Now that CONFIG_PAHOLE_VERSION exists, use it in the definition of CONFIG_PAHOLE_HAS_SPLIT_BTF and CONFIG_PAHOLE_HAS_BTF_TAG to reduce the amount of duplication across the tree.

---
 lib/Kconfig.debug | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/Kconfig.debug +2 -2
index 6159859769fa..bd487d480902 100644
@@ -323,10 +323,10 @@ config DEBUG_INFO_BTF
 	  DWARF type info into equivalent deduplicated BTF type info.
 
 config PAHOLE_HAS_SPLIT_BTF
-	def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "119")
+	def_bool PAHOLE_VERSION >= 119
 
 config PAHOLE_HAS_BTF_TAG
-	def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "123")
+	def_bool PAHOLE_VERSION >= 123
 	depends on CC_IS_CLANG
 	help
 	  Decide whether pahole emits btf_tag attributes (btf_type_tag and
Signature · 1 line
2.35.1
#5 lore raw

PATCH 5/5 lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

In reply to Nathan Chancellor

Commit 98cd6f521f10 ("Kconfig: allow explicit opt in to DWARF v5") prevented CONFIG_DEBUG_INFO_DWARF5 from being selected when CONFIG_DEBUG_INFO_BTF is enabled because pahole had issues with clang's DWARF5 info. This was resolved by [1], which is in pahole v1.21.

Allow DEBUG_INFO_DWARF5 to be selected with DEBUG_INFO_BTF when using pahole v1.21 or newer.

[1]: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=7d8e829f636f47aba2e1b6eda57e74d8e31f733c

---
 lib/Kconfig.debug | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
index bd487d480902..1555da672275 100644
@@ -296,7 +296,7 @@ config DEBUG_INFO_DWARF4
 config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
-	depends on !DEBUG_INFO_BTF
+	depends on !DEBUG_INFO_BTF || PAHOLE_VERSION >= 121
 	help
 	  Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
 	  5.0+ accepts the -gdwarf-5 flag but only had partial support for some
Signature · 1 line
2.35.1
Acked-by on the v1 series
#6 lore raw
In reply to Nathan Chancellor
Quoted 18 lines · Nathan Chancellor

Hi all,

This series allows CONFIG_DEBUG_INFO_DWARF5 to be selected with CONFIG_DEBUG_INFO_BTF=y by checking the pahole version.

The first four patches add CONFIG_PAHOLE_VERSION and scripts/pahole-version.sh to clean up all the places that pahole's version is transformed into a 3-digit form.

The fourth patch adds a PAHOLE_VERSION dependency to DEBUG_INFO_DWARF5 so that there are no build errors when it is selected with DEBUG_INFO_BTF.

I build tested Fedora's aarch64 and x86_64 config with ToT clang 14.0.0 and GCC 11 with CONFIG_DEBUG_INFO_DWARF5 enabled with both pahole 1.21 and 1.23.

Quoted 7 lines

Nathan Chancellor (5):
MAINTAINERS: Add scripts/pahole-flags.sh to BPF section
kbuild: Add CONFIG_PAHOLE_VERSION scripts/pahole-flags.sh: Use pahole-version.sh lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

LGTM. I'd probably combine patches 2 and 3, but it's minor. I really like the CONFIG_PAHOLE_VERSION and how much cleaner it makes Kconfig options.

Quoted 13 lines
 MAINTAINERS               |  2 ++
 init/Kconfig              |  4 ++++
 lib/Kconfig.debug         |  6 +++---
 scripts/pahole-flags.sh   |  2 +-
 scripts/pahole-version.sh | 13 +++++++++++++
 5 files changed, 23 insertions(+), 4 deletions(-)
 create mode 100755 scripts/pahole-version.sh

base-commit: 533de4aea6a91eb670ff8ff2b082bb34f2c5d6ab --
2.35.1

maintainer
#7 lore raw
Quoted 25 lines · Andrii Nakryiko
Quoted 16 lines · Nathan Chancellor

This series allows CONFIG_DEBUG_INFO_DWARF5 to be selected with CONFIG_DEBUG_INFO_BTF=y by checking the pahole version.

The first four patches add CONFIG_PAHOLE_VERSION and scripts/pahole-version.sh to clean up all the places that pahole's version is transformed into a 3-digit form.

The fourth patch adds a PAHOLE_VERSION dependency to DEBUG_INFO_DWARF5 so that there are no build errors when it is selected with DEBUG_INFO_BTF.

I build tested Fedora's aarch64 and x86_64 config with ToT clang 14.0.0 and GCC 11 with CONFIG_DEBUG_INFO_DWARF5 enabled with both pahole 1.21 and 1.23.

Quoted 7 lines

Nathan Chancellor (5):
MAINTAINERS: Add scripts/pahole-flags.sh to BPF section
kbuild: Add CONFIG_PAHOLE_VERSION scripts/pahole-flags.sh: Use pahole-version.sh lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

Quoted 3 lines

LGTM. I'd probably combine patches 2 and 3, but it's minor. I really like the CONFIG_PAHOLE_VERSION and how much cleaner it makes Kconfig options.

+1, thanks for working on getting this enabled! I think patches 2 and 3 are rather logically separate, so as-is is fine as well imho. Applied, thanks!

#8 lore raw
In reply to Nathan Chancellor
This series was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Hello:

This series was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Quoted 10 lines · On Tue, 1 Feb 2022 13:56:19 -0700 you wrote:

Hi all,

This series allows CONFIG_DEBUG_INFO_DWARF5 to be selected with CONFIG_DEBUG_INFO_BTF=y by checking the pahole version.

The first four patches add CONFIG_PAHOLE_VERSION and scripts/pahole-version.sh to clean up all the places that pahole's version is transformed into a 3-digit form.

[...]

Here is the summary with links:
- [bpf-next,1/5] MAINTAINERS: Add scripts/pahole-flags.sh to BPF section

    https://git.kernel.org/bpf/bpf-next/c/f67644b4f282
  - [bpf-next,2/5] kbuild: Add CONFIG_PAHOLE_VERSION
    https://git.kernel.org/bpf/bpf-next/c/613fe1692377
  - [bpf-next,3/5] scripts/pahole-flags.sh: Use pahole-version.sh
    https://git.kernel.org/bpf/bpf-next/c/2d6c9810eb89
  - [bpf-next,4/5] lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION
    https://git.kernel.org/bpf/bpf-next/c/6323c81350b7
  - [bpf-next,5/5] lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+
    https://git.kernel.org/bpf/bpf-next/c/42d9b379e3e1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#9 lore raw

cover Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

In reply to Nathan Chancellor

From: Matthias Maennich <[email protected]>

Can we please pick this series up for 5.15? I am particularly interested in the last patch to enable BTF + DWARF5, but the cleanup patches before are a very reasonable choice for stable@ as well as they simplify the pahole version calculation and allow future BTF/pahole related patches to apply cleanly as well. I intentionally kept the config PAHOLE_HAS_BTF_TAG and hence its patch complete, even though there is no user for it.

Cheers,
Matthias

Cc <[email protected]> # v5.15+
Cc Greg Kroah-Hartman <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Andrii Nakryiko <[email protected]>

Nathan Chancellor (5):
MAINTAINERS: Add scripts/pahole-flags.sh to BPF section
kbuild: Add CONFIG_PAHOLE_VERSION scripts/pahole-flags.sh: Use pahole-version.sh lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

 MAINTAINERS               |  2 ++
 init/Kconfig              |  4 ++++
 lib/Kconfig.debug         | 12 ++++++++++--
 scripts/pahole-flags.sh   |  2 +-
 scripts/pahole-version.sh | 13 +++++++++++++
 5 files changed, 30 insertions(+), 3 deletions(-)
 create mode 100755 scripts/pahole-version.sh
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#10 lore raw
Quoted 9 lines · On Wed, Feb 22, 2023 at 11:21:37AM +0000, [email protected] wrote:

From: Matthias Maennich <[email protected]>

Can we please pick this series up for 5.15? I am particularly interested in the last patch to enable BTF + DWARF5, but the cleanup patches before are a very reasonable choice for stable@ as well as they simplify the pahole version calculation and allow future BTF/pahole related patches to apply cleanly as well. I intentionally kept the config PAHOLE_HAS_BTF_TAG and hence its patch complete, even though there is no user for it.

What are the upstream git commit ids for these changes?

thanks,

greg k-h

#11 lore raw
Quoted 12 lines · Greg Kroah-Hartman
Quoted 9 lines · On Wed, Feb 22, 2023 at 11:21:37AM +0000, [email protected] wrote:

From: Matthias Maennich <[email protected]>

Can we please pick this series up for 5.15? I am particularly interested in the last patch to enable BTF + DWARF5, but the cleanup patches before are a very reasonable choice for stable@ as well as they simplify the pahole version calculation and allow future BTF/pahole related patches to apply cleanly as well. I intentionally kept the config PAHOLE_HAS_BTF_TAG and hence its patch complete, even though there is no user for it.

Quoted 1 line

What are the upstream git commit ids for these changes?

Sorry, they should have been part of the commit message ... here they are

f67644b4f282d42acf5ad9b0175ef5671314ab12 ("MAINTAINERS: Add scripts/pahole-flags.sh to BPF section") 613fe169237785a4bb1d06397b52606b2967da53 ("kbuild: Add CONFIG_PAHOLE_VERSION") 2d6c9810eb8915c4ddede707b8e167a1d919e1ca ("scripts/pahole-flags.sh:
Use pahole-version.sh")
6323c81350b73a4569cf52df85f80273faa64071 ("lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION")
42d9b379e3e1790eafb87c799c9edfd0b37a37c7 ("lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+")

Cheers,
Matthias

Quoted 4 lines

thanks,

greg k-h

#12 lore raw

PATCH 1/5 MAINTAINERS: Add scripts/pahole-flags.sh to BPF section

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>

Currently, scripts/pahole-flags.sh has no formal maintainer. Add it to the BPF section so that patches to it can be properly reviewed and picked up.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 4f50a453e18a..176485e625a0 100644
@@ -3407,6 +3407,7 @@ F:	net/sched/act_bpf.c
 F:	net/sched/cls_bpf.c
 F:	samples/bpf/
 F:	scripts/bpf_doc.py
+F:	scripts/pahole-flags.sh
 F:	tools/bpf/
 F:	tools/lib/bpf/
 F:	tools/testing/selftests/bpf/
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#13 lore raw

Re: [PATCH 1/5] MAINTAINERS: Add scripts/pahole-flags.sh to BPF section

FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

Rule: 'Cc: [email protected]' or 'commit <sha1> upstream.'
Subject: [PATCH 1/5] MAINTAINERS: Add scripts/pahole-flags.sh to BPF section

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#14 lore raw

Re: [PATCH 1/5] MAINTAINERS: Add scripts/pahole-flags.sh to BPF section

In reply to [email protected]
Quoted 30 lines · On Wed, Feb 22, 2023 at 11:21:39AM +0000, [email protected] wrote:

From: Nathan Chancellor <[email protected]>

Currently, scripts/pahole-flags.sh has no formal maintainer. Add it to the BPF section so that patches to it can be properly reviewed and picked up.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 4f50a453e18a..176485e625a0 100644
@@ -3407,6 +3407,7 @@ F:	net/sched/act_bpf.c
 F:	net/sched/cls_bpf.c
 F:	samples/bpf/
 F:	scripts/bpf_doc.py
+F:	scripts/pahole-flags.sh
 F:	tools/bpf/
 F:	tools/lib/bpf/
 F:	tools/testing/selftests/bpf/
Signature · 1 line
2.39.2.637.g21b0678d19-goog

No need for MAINTAINERS updates for older kernels as no one should be making new patches against them, right?

thanks,

greg k-h

#15 lore raw

Re: [PATCH 1/5] MAINTAINERS: Add scripts/pahole-flags.sh to BPF section

Quoted 27 lines · Greg Kroah-Hartman
Quoted 25 lines · On Wed, Feb 22, 2023 at 11:21:39AM +0000, [email protected] wrote:

From: Nathan Chancellor <[email protected]>

Currently, scripts/pahole-flags.sh has no formal maintainer. Add it to the BPF section so that patches to it can be properly reviewed and picked up.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 4f50a453e18a..176485e625a0 100644
@@ -3407,6 +3407,7 @@ F:      net/sched/act_bpf.c
 F:   net/sched/cls_bpf.c
 F:   samples/bpf/
 F:   scripts/bpf_doc.py
+F:   scripts/pahole-flags.sh
 F:   tools/bpf/
Quoted 8 lines
Quoted 5 lines
MAINTAINERS +0 -1
 F:   tools/lib/bpf/
 F:   tools/testing/selftests/bpf/
--

2.39.2.637.g21b0678d19-goog

No need for MAINTAINERS updates for older kernels as no one should be making new patches against them, right?

This one is optional, but it makes the next one apply cleanly and I picked the entire series.

Cheers,
Matthias

Quoted 4 lines

thanks,

greg k-h

#16 lore raw

PATCH 2/5 kbuild: Add CONFIG_PAHOLE_VERSION

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>

There are a few different places where pahole's version is turned into a three digit form with the exact same command. Move this command into scripts/pahole-version.sh to reduce the amount of duplication across the tree.

Create CONFIG_PAHOLE_VERSION so the version code can be used in Kconfig to enable and disable configuration options based on the pahole version, which is already done in a couple of places.

---
 MAINTAINERS               |  1 +
 init/Kconfig              |  4 ++++
 scripts/pahole-version.sh | 13 +++++++++++++
 3 files changed, 18 insertions(+)
 create mode 100755 scripts/pahole-version.sh
MAINTAINERS +1 -0
index 176485e625a0..ee8a1b5c28a6 100644
@@ -3408,6 +3408,7 @@ F:	net/sched/cls_bpf.c
 F:	samples/bpf/
 F:	scripts/bpf_doc.py
 F:	scripts/pahole-flags.sh
+F:	scripts/pahole-version.sh
 F:	tools/bpf/
 F:	tools/lib/bpf/
 F:	tools/testing/selftests/bpf/
init/Kconfig +4 -0
index a4144393717b..dafc3ba6fa7a 100644
@@ -91,6 +91,10 @@ config CC_HAS_ASM_INLINE
 config CC_HAS_NO_PROFILE_FN_ATTR
 	def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
 
+config PAHOLE_VERSION
+	int
+	default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
+
 config CONSTRUCTORS
 	bool
 
scripts/pahole-version.sh new file +13 -0
new file mode 100755
index 000000000000..f8a32ab93ad1
@@ -0,0 +1,13 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Usage: $ ./pahole-version.sh pahole
+#
+# Prints pahole's version in a 3-digit form, such as 119 for v1.19.
+
+if [ ! -x "$(command -v "$@")" ]; then
+	echo 0
+	exit 1
+fi
+
+"$@" --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#17 lore raw

PATCH 3/5 scripts/pahole-flags.sh: Use pahole-version.sh

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>

Use pahole-version.sh to get pahole's version code to reduce the amount of duplication across the tree.

---
 scripts/pahole-flags.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/pahole-flags.sh +1 -1
index 7acee326aa6c..d38fa6d84d62 100755
@@ -7,7 +7,7 @@ if ! [ -x "$(command -v ${PAHOLE})" ]; then
 	exit 0
 fi
 
-pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
+pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE})
 
 if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
 	# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#18 lore raw

PATCH 4/5 lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>

Now that CONFIG_PAHOLE_VERSION exists, use it in the definition of CONFIG_PAHOLE_HAS_SPLIT_BTF and CONFIG_PAHOLE_HAS_BTF_TAG to reduce the amount of duplication across the tree.

---
 lib/Kconfig.debug | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
lib/Kconfig.debug +9 -1
index f71db0cc3bf1..0743c9567d7e 100644
@@ -328,7 +328,15 @@ config DEBUG_INFO_BTF
 	  DWARF type info into equivalent deduplicated BTF type info.
 
 config PAHOLE_HAS_SPLIT_BTF
-	def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "119")
+	def_bool PAHOLE_VERSION >= 119
+
+config PAHOLE_HAS_BTF_TAG
+	def_bool PAHOLE_VERSION >= 123
+	depends on CC_IS_CLANG
+	help
+	  Decide whether pahole emits btf_tag attributes (btf_type_tag and
+	  btf_decl_tag) or not. Currently only clang compiler implements
+	  these attributes, so make the config depend on CC_IS_CLANG.
 
 config DEBUG_INFO_BTF_MODULES
 	def_bool y
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#19 lore raw

Re: [PATCH 4/5] lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION

Quoted 23 lines · On Wed, Feb 22, 2023 at 11:21:45AM +0000, [email protected] wrote:

From: Nathan Chancellor <[email protected]>

Now that CONFIG_PAHOLE_VERSION exists, use it in the definition of CONFIG_PAHOLE_HAS_SPLIT_BTF and CONFIG_PAHOLE_HAS_BTF_TAG to reduce the amount of duplication across the tree.

---
 lib/Kconfig.debug | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
lib/Kconfig.debug +0 -0
index f71db0cc3bf1..0743c9567d7e 100644
@@ -328,7 +328,15 @@ config DEBUG_INFO_BTF
 	  DWARF type info into equivalent deduplicated BTF type info.
 
 config PAHOLE_HAS_SPLIT_BTF

lib/Kconfig.debug config DEBUG_INFO_BTF · line 339

Quoted 10 lines
lib/Kconfig.debug +9 -1
-	def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "119")
+	def_bool PAHOLE_VERSION >= 119
+
+config PAHOLE_HAS_BTF_TAG
+	def_bool PAHOLE_VERSION >= 123
+	depends on CC_IS_CLANG
+	help
+	  Decide whether pahole emits btf_tag attributes (btf_type_tag and
+	  btf_decl_tag) or not. Currently only clang compiler implements
+	  these attributes, so make the config depend on CC_IS_CLANG.

Note, this is very different from the original commit, are you sure this is correct?

You took a MAINTAINERS file update in patch 1/5 to make a later patch simpler, but yet you massively changed this commit and included stuff from a different one and did not mention it anywhere?

Please fix this commit up, and resubmit the whole series with the git commit ids in the commits to make it easier for me to review and apply properly.

thanks,

greg k-h

#20 lore raw

PATCH 5/5 lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>

Commit 98cd6f521f10 ("Kconfig: allow explicit opt in to DWARF v5") prevented CONFIG_DEBUG_INFO_DWARF5 from being selected when CONFIG_DEBUG_INFO_BTF is enabled because pahole had issues with clang's DWARF5 info. This was resolved by [1], which is in pahole v1.21.

Allow DEBUG_INFO_DWARF5 to be selected with DEBUG_INFO_BTF when using pahole v1.21 or newer.

[1]: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=7d8e829f636f47aba2e1b6eda57e74d8e31f733c

---
 lib/Kconfig.debug | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
index 0743c9567d7e..dd86de130cdf 100644
@@ -302,7 +302,7 @@ config DEBUG_INFO_DWARF4
 config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
-	depends on !DEBUG_INFO_BTF
+	depends on !DEBUG_INFO_BTF || PAHOLE_VERSION >= 121
 	help
 	  Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
 	  5.0+ accepts the -gdwarf-5 flag but only had partial support for some
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#21 lore raw

v2 cover Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

In reply to Nathan Chancellor

Hi!

Can we please pick up the essential parts of this series for 5.15? I am particularly interested in the last patch to enable BTF + DWARF5, but the cleanup patches before are a very reasonable choice for stable@ as well as they simplify the pahole version calculation and allow future BTF/pahole related patches to apply cleanly as well.

Cheers,
Matthias

Cc <[email protected]> # v5.15+
Cc Greg Kroah-Hartman <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Andrii Nakryiko <[email protected]>

Nathan Chancellor (4):
kbuild: Add CONFIG_PAHOLE_VERSION scripts/pahole-flags.sh: Use pahole-version.sh lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

 MAINTAINERS               |  1 +
 init/Kconfig              |  4 ++++
 lib/Kconfig.debug         |  4 ++--
 scripts/pahole-flags.sh   |  2 +-
 scripts/pahole-version.sh | 13 +++++++++++++
 5 files changed, 21 insertions(+), 3 deletions(-)
 create mode 100755 scripts/pahole-version.sh
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#22 lore raw
Quoted 23 lines · Matthias Maennich

Hi!

Can we please pick up the essential parts of this series for 5.15? I am particularly interested in the last patch to enable BTF + DWARF5, but the cleanup patches before are a very reasonable choice for stable@ as well as they simplify the pahole version calculation and allow future BTF/pahole related patches to apply cleanly as well.

Cheers,
Matthias

Cc <[email protected]> # v5.15+
Cc Greg Kroah-Hartman <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Andrii Nakryiko <[email protected]>

Nathan Chancellor (4):
kbuild: Add CONFIG_PAHOLE_VERSION scripts/pahole-flags.sh: Use pahole-version.sh lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

Quoted 7 lines
 MAINTAINERS               |  1 +
 init/Kconfig              |  4 ++++
 lib/Kconfig.debug         |  4 ++--
 scripts/pahole-flags.sh   |  2 +-
 scripts/pahole-version.sh | 13 +++++++++++++
 5 files changed, 21 insertions(+), 3 deletions(-)
 create mode 100755 scripts/pahole-version.sh

Thanks, all now queued up. Hopefully quilt/git will handle the permission of this file properly, sometimes it gets confused...

greg k-h

#23 lore raw

PATCH v2 1/4 kbuild: Add CONFIG_PAHOLE_VERSION

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>

[ Upstream commit 613fe169237785a4bb1d06397b52606b2967da53 ]

There are a few different places where pahole's version is turned into a three digit form with the exact same command. Move this command into scripts/pahole-version.sh to reduce the amount of duplication across the tree.

Create CONFIG_PAHOLE_VERSION so the version code can be used in Kconfig to enable and disable configuration options based on the pahole version, which is already done in a couple of places.

---
 MAINTAINERS               |  1 +
 init/Kconfig              |  4 ++++
 scripts/pahole-version.sh | 13 +++++++++++++
 3 files changed, 18 insertions(+)
 create mode 100755 scripts/pahole-version.sh
MAINTAINERS +1 -0
index 4f50a453e18a..826e2ba7b09a 100644
@@ -3407,6 +3407,7 @@ F:	net/sched/act_bpf.c
 F:	net/sched/cls_bpf.c
 F:	samples/bpf/
 F:	scripts/bpf_doc.py
+F:	scripts/pahole-version.sh
 F:	tools/bpf/
 F:	tools/lib/bpf/
 F:	tools/testing/selftests/bpf/
init/Kconfig +4 -0
index a4144393717b..dafc3ba6fa7a 100644
@@ -91,6 +91,10 @@ config CC_HAS_ASM_INLINE
 config CC_HAS_NO_PROFILE_FN_ATTR
 	def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
 
+config PAHOLE_VERSION
+	int
+	default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
+
 config CONSTRUCTORS
 	bool
 
scripts/pahole-version.sh new file +13 -0
new file mode 100755
index 000000000000..f8a32ab93ad1
@@ -0,0 +1,13 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Usage: $ ./pahole-version.sh pahole
+#
+# Prints pahole's version in a 3-digit form, such as 119 for v1.19.
+
+if [ ! -x "$(command -v "$@")" ]; then
+	echo 0
+	exit 1
+fi
+
+"$@" --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#24 lore raw

PATCH v2 2/4 scripts/pahole-flags.sh: Use pahole-version.sh

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>

[ Upstream commit 2d6c9810eb8915c4ddede707b8e167a1d919e1ca ]

Use pahole-version.sh to get pahole's version code to reduce the amount of duplication across the tree.

---
 scripts/pahole-flags.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/pahole-flags.sh +1 -1
index 7acee326aa6c..d38fa6d84d62 100755
@@ -7,7 +7,7 @@ if ! [ -x "$(command -v ${PAHOLE})" ]; then
 	exit 0
 fi
 
-pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
+pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE})
 
 if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
 	# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#25 lore raw

PATCH v2 3/4 lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>

[ Upstream commit 6323c81350b73a4569cf52df85f80273faa64071 ]

Now that CONFIG_PAHOLE_VERSION exists, use it in the definition of CONFIG_PAHOLE_HAS_SPLIT_BTF and CONFIG_PAHOLE_HAS_BTF_TAG to reduce the amount of duplication across the tree.

Change-Id Ie5ba17d96688dbcc385a9804ed96a59bda7a40df
[maennich: omitted patching non-existing config PAHOLE_HAS_BTF_TAG]
---
 lib/Kconfig.debug | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
index f71db0cc3bf1..944fd2ae756b 100644
@@ -328,7 +328,7 @@ config DEBUG_INFO_BTF
 	  DWARF type info into equivalent deduplicated BTF type info.
 
 config PAHOLE_HAS_SPLIT_BTF
-	def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "119")
+	def_bool PAHOLE_VERSION >= 119
 
 config DEBUG_INFO_BTF_MODULES
 	def_bool y
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#26 lore raw

PATCH v2 4/4 lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>

[ Upstream commit 42d9b379e3e1790eafb87c799c9edfd0b37a37c7 ]

Commit 98cd6f521f10 ("Kconfig: allow explicit opt in to DWARF v5") prevented CONFIG_DEBUG_INFO_DWARF5 from being selected when CONFIG_DEBUG_INFO_BTF is enabled because pahole had issues with clang's DWARF5 info. This was resolved by [1], which is in pahole v1.21.

Allow DEBUG_INFO_DWARF5 to be selected with DEBUG_INFO_BTF when using pahole v1.21 or newer.

[1]: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=7d8e829f636f47aba2e1b6eda57e74d8e31f733c

---
 lib/Kconfig.debug | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
index 944fd2ae756b..dbbd243c865f 100644
@@ -302,7 +302,7 @@ config DEBUG_INFO_DWARF4
 config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
-	depends on !DEBUG_INFO_BTF
+	depends on !DEBUG_INFO_BTF || PAHOLE_VERSION >= 121
 	help
 	  Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
 	  5.0+ accepts the -gdwarf-5 flag but only had partial support for some
Signature · 1 line
2.39.2.637.g21b0678d19-goog