2022-02-02 08:45:15

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH bpf-next 0/5] 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
--
2.35.1


2022-02-02 13:00:49

by Andrii Nakryiko

[permalink] [raw]
Subject: Re: [PATCH bpf-next 0/5] Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

On Tue, Feb 1, 2022 at 12:56 PM Nathan Chancellor <[email protected]> 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.
>
> 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+
>

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.

Acked-by: Andrii Nakryiko <[email protected]>

> 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
>

2022-02-02 13:17:15

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH bpf-next 4/5] lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION

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.

Signed-off-by: Nathan Chancellor <[email protected]>
---
lib/Kconfig.debug | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 6159859769fa..bd487d480902 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
--
2.35.1

2022-02-02 14:13:03

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH bpf-next 0/5] Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

On 2/2/22 8:05 AM, Andrii Nakryiko wrote:
> On Tue, Feb 1, 2022 at 12:56 PM Nathan Chancellor <[email protected]> wrote:
>>
>> 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+
>>
>
> 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!

2022-02-02 15:54:14

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH bpf-next 5/5] lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

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

Signed-off-by: Nathan Chancellor <[email protected]>
---
lib/Kconfig.debug | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index bd487d480902..1555da672275 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
--
2.35.1

2022-02-02 16:35:45

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH bpf-next 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.

Signed-off-by: Nathan Chancellor <[email protected]>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0d7883977e9b..0d422452c8ff 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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/
--
2.35.1

2022-02-03 01:09:57

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH bpf-next 0/5] Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

Hello:

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

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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


2022-02-03 13:38:31

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH bpf-next 2/5] kbuild: Add CONFIG_PAHOLE_VERSION

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.

Signed-off-by: Nathan Chancellor <[email protected]>
---
MAINTAINERS | 1 +
init/Kconfig | 4 ++++
scripts/pahole-version.sh | 13 +++++++++++++
3 files changed, 18 insertions(+)
create mode 100755 scripts/pahole-version.sh

diff --git a/MAINTAINERS b/MAINTAINERS
index 0d422452c8ff..d8a66d50f224 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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/
diff --git a/init/Kconfig b/init/Kconfig
index e9119bf54b1f..7328d4f25370 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -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

diff --git a/scripts/pahole-version.sh b/scripts/pahole-version.sh
new file mode 100755
index 000000000000..f8a32ab93ad1
--- /dev/null
+++ b/scripts/pahole-version.sh
@@ -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/'
--
2.35.1

2022-02-03 20:37:44

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH bpf-next 3/5] scripts/pahole-flags.sh: Use pahole-version.sh

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

Signed-off-by: Nathan Chancellor <[email protected]>
---
scripts/pahole-flags.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
index e6093adf4c06..c293941612e7 100755
--- a/scripts/pahole-flags.sh
+++ b/scripts/pahole-flags.sh
@@ -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
--
2.35.1

2023-02-22 11:22:29

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH 0/5] Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

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]>
Signed-off-by: Matthias Maennich <[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

--
2.39.2.637.g21b0678d19-goog


2023-02-22 11:22:59

by Matthias Maennich

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

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.

Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Matthias Maennich <[email protected]>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4f50a453e18a..176485e625a0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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/
--
2.39.2.637.g21b0678d19-goog


2023-02-22 11:23:16

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH 2/5] kbuild: Add CONFIG_PAHOLE_VERSION

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.

Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Matthias Maennich <[email protected]>
---
MAINTAINERS | 1 +
init/Kconfig | 4 ++++
scripts/pahole-version.sh | 13 +++++++++++++
3 files changed, 18 insertions(+)
create mode 100755 scripts/pahole-version.sh

diff --git a/MAINTAINERS b/MAINTAINERS
index 176485e625a0..ee8a1b5c28a6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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/
diff --git a/init/Kconfig b/init/Kconfig
index a4144393717b..dafc3ba6fa7a 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -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

diff --git a/scripts/pahole-version.sh b/scripts/pahole-version.sh
new file mode 100755
index 000000000000..f8a32ab93ad1
--- /dev/null
+++ b/scripts/pahole-version.sh
@@ -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/'
--
2.39.2.637.g21b0678d19-goog


2023-02-22 11:23:44

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH 3/5] scripts/pahole-flags.sh: Use pahole-version.sh

From: Nathan Chancellor <[email protected]>

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

Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Matthias Maennich <[email protected]>
---
scripts/pahole-flags.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
index 7acee326aa6c..d38fa6d84d62 100755
--- a/scripts/pahole-flags.sh
+++ b/scripts/pahole-flags.sh
@@ -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
--
2.39.2.637.g21b0678d19-goog


2023-02-22 11:23:48

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH 4/5] lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION

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.

Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Matthias Maennich <[email protected]>
---
lib/Kconfig.debug | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index f71db0cc3bf1..0743c9567d7e 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
--
2.39.2.637.g21b0678d19-goog


2023-02-22 11:24:16

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH 5/5] lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

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

Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Matthias Maennich <[email protected]>
---
lib/Kconfig.debug | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 0743c9567d7e..dd86de130cdf 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
--
2.39.2.637.g21b0678d19-goog


2023-02-22 11:27:05

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 0/5] Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

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

2023-02-22 11:27:37

by Greg Kroah-Hartman

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

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.
>
> Signed-off-by: Nathan Chancellor <[email protected]>
> Signed-off-by: Daniel Borkmann <[email protected]>
> Acked-by: Andrii Nakryiko <[email protected]>
> Link: https://lore.kernel.org/bpf/[email protected]
> Signed-off-by: Matthias Maennich <[email protected]>
> ---
> MAINTAINERS | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 4f50a453e18a..176485e625a0 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -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/
> --
> 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

2023-02-22 11:37:24

by Matthias Maennich

[permalink] [raw]
Subject: Re: [PATCH 0/5] Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

On Wed, Feb 22, 2023 at 11:26 AM Greg Kroah-Hartman
<[email protected]> wrote:
>
> 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?

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

>
> thanks,
>
> greg k-h

2023-02-22 11:38:32

by Matthias Maennich

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

On Wed, Feb 22, 2023 at 11:26 AM Greg Kroah-Hartman
<[email protected]> wrote:
>
> 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.
> >
> > Signed-off-by: Nathan Chancellor <[email protected]>
> > Signed-off-by: Daniel Borkmann <[email protected]>
> > Acked-by: Andrii Nakryiko <[email protected]>
> > Link: https://lore.kernel.org/bpf/[email protected]
> > Signed-off-by: Matthias Maennich <[email protected]>
> > ---
> > MAINTAINERS | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 4f50a453e18a..176485e625a0 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -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/
> > --
> > 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

>
> thanks,
>
> greg k-h

2023-02-23 09:18:05

by Greg Kroah-Hartman

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

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.
>
> Signed-off-by: Nathan Chancellor <[email protected]>
> Signed-off-by: Daniel Borkmann <[email protected]>
> Acked-by: Andrii Nakryiko <[email protected]>
> Link: https://lore.kernel.org/bpf/[email protected]
> Signed-off-by: Matthias Maennich <[email protected]>
> ---
> lib/Kconfig.debug | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index f71db0cc3bf1..0743c9567d7e 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -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.

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

2023-02-23 11:54:01

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH v5.15 v2 0/4] Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

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]>
Signed-off-by: Matthias Maennich <[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

--
2.39.2.637.g21b0678d19-goog


2023-02-23 11:54:06

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH v5.15 v2 1/4] kbuild: Add CONFIG_PAHOLE_VERSION

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.

Change-Id: Id18c1808832cead0d32f6992a52eb35b0ec269bb
Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Matthias Maennich <[email protected]>
---
MAINTAINERS | 1 +
init/Kconfig | 4 ++++
scripts/pahole-version.sh | 13 +++++++++++++
3 files changed, 18 insertions(+)
create mode 100755 scripts/pahole-version.sh

diff --git a/MAINTAINERS b/MAINTAINERS
index 4f50a453e18a..826e2ba7b09a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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/
diff --git a/init/Kconfig b/init/Kconfig
index a4144393717b..dafc3ba6fa7a 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -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

diff --git a/scripts/pahole-version.sh b/scripts/pahole-version.sh
new file mode 100755
index 000000000000..f8a32ab93ad1
--- /dev/null
+++ b/scripts/pahole-version.sh
@@ -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/'
--
2.39.2.637.g21b0678d19-goog


2023-02-23 11:54:31

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH v5.15 v2 2/4] scripts/pahole-flags.sh: Use pahole-version.sh

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.

Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Matthias Maennich <[email protected]>
---
scripts/pahole-flags.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
index 7acee326aa6c..d38fa6d84d62 100755
--- a/scripts/pahole-flags.sh
+++ b/scripts/pahole-flags.sh
@@ -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
--
2.39.2.637.g21b0678d19-goog


2023-02-23 11:55:03

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH v5.15 v2 3/4] lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION

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
Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
[maennich: omitted patching non-existing config PAHOLE_HAS_BTF_TAG]
Signed-off-by: Matthias Maennich <[email protected]>
---
lib/Kconfig.debug | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index f71db0cc3bf1..944fd2ae756b 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
--
2.39.2.637.g21b0678d19-goog


2023-02-23 11:55:03

by Matthias Maennich

[permalink] [raw]
Subject: [PATCH v5.15 v2 4/4] lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+

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

Change-Id: I9cc90f12abcc8a809bb263e31ec16766d9384e40
Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Matthias Maennich <[email protected]>
---
lib/Kconfig.debug | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 944fd2ae756b..dbbd243c865f 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
--
2.39.2.637.g21b0678d19-goog


2023-02-23 12:37:21

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v5.15 v2 0/4] Allow CONFIG_DEBUG_INFO_DWARF5=y + CONFIG_DEBUG_INFO_BTF=y

On Thu, Feb 23, 2023 at 11:53:47AM +0000, Matthias Maennich wrote:
> 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]>
> Signed-off-by: Matthias Maennich <[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

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

greg k-h