diff mbox series

[bpf-next] bpf: Add config for skipping BTF enum64s

Message ID 20220828165124.20261-1-yakoyoku@gmail.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series [bpf-next] bpf: Add config for skipping BTF enum64s | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 8 maintainers not CCed: john.fastabend@gmail.com song@kernel.org haoluo@google.com martin.lau@linux.dev akpm@linux-foundation.org kpsingh@kernel.org keescook@chromium.org sdf@google.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 38 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-4 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-1 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on x86_64 with llvm-16

Commit Message

Martin Rodriguez Reboredo Aug. 28, 2022, 4:51 p.m. UTC
From: Martin Rodriguez Reboredo <yakoyoku@gmail.com>

After the release of pahole 1.24 some people in the dwarves mailing list
notified issues related to building the kernel with the BTF_DEBUG_INFO
option toggled. They seem to be happenning due to the kernel and
resolve_btfids interpreting btf types erroneously. In the dwarves list
I've proposed a change to the scripts that I've written while testing
the Rust kernel, it simply passes the --skip_encoding_btf_enum64 to
pahole if it has version 1.24, but it might be desirable to have the
option to pass said flag.

Signed-off-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
---
 lib/Kconfig.debug       | 14 ++++++++++++++
 scripts/pahole-flags.sh |  7 +++++++
 2 files changed, 21 insertions(+)

Comments

Jiri Olsa Aug. 28, 2022, 5:36 p.m. UTC | #1
On Sun, Aug 28, 2022 at 01:51:24PM -0300, Martin Reboredo wrote:
> From: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
> 
> After the release of pahole 1.24 some people in the dwarves mailing list
> notified issues related to building the kernel with the BTF_DEBUG_INFO
> option toggled. They seem to be happenning due to the kernel and
> resolve_btfids interpreting btf types erroneously. In the dwarves list
> I've proposed a change to the scripts that I've written while testing
> the Rust kernel, it simply passes the --skip_encoding_btf_enum64 to
> pahole if it has version 1.24, but it might be desirable to have the
> option to pass said flag.

as I wrote in the original thread, I think we need to do this just for
stable kernels that don't have enum64 support and use pahole 1.24

I think we should switch it off there by default without config option

jirka

> 
> Signed-off-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
> ---
>  lib/Kconfig.debug       | 14 ++++++++++++++
>  scripts/pahole-flags.sh |  7 +++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 072e4b289c13..638a33cf9e57 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -356,6 +356,20 @@ config PAHOLE_HAS_BTF_TAG
>  	  btf_decl_tag) or not. Currently only clang compiler implements
>  	  these attributes, so make the config depend on CC_IS_CLANG.
>  
> +config PAHOLE_HAS_SKIP_ENCODING_BTF_ENUM64
> +	def_bool PAHOLE_VERSION >= 124
> +	help
> +	  Encoding BTF enum64s can be skipped with the
> +	  --skip_encoding_btf_enum64 pahole option.
> +
> +config DEBUG_INFO_BTF_SKIP_ENCODING_ENUM64
> +	def_bool n
> +	depends on DEBUG_INFO_BTF && PAHOLE_HAS_SKIP_ENCODING_BTF_ENUM64
> +	help
> +	  Omit the encoding of 64 bits enum values with pahole. With certain
> +	  kernel configurations having ENUM64s enabled may result in malformed
> +	  output binaries.
> +
>  config DEBUG_INFO_BTF_MODULES
>  	def_bool y
>  	depends on DEBUG_INFO_BTF && MODULES && PAHOLE_HAS_SPLIT_BTF
> diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
> index 0d99ef17e4a5..e44bc2a947ce 100755
> --- a/scripts/pahole-flags.sh
> +++ b/scripts/pahole-flags.sh
> @@ -9,6 +9,10 @@ fi
>  
>  pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE})
>  
> +is_enabled() {
> +	grep -q "^$1=y" include/config/auto.conf
> +}
> +
>  if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
>  	# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
>  	extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
> @@ -19,5 +23,8 @@ fi
>  if [ "${pahole_ver}" -ge "122" ]; then
>  	extra_paholeopt="${extra_paholeopt} -j"
>  fi
> +if is_enabled DEBUG_INFO_BTF_SKIP_ENCODING_ENUM64; then
> +	extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_enum64"
> +fi
>  
>  echo ${extra_paholeopt}
> -- 
> 2.37.2
>
kernel test robot Aug. 28, 2022, 7:03 p.m. UTC | #2
Hi Martin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Martin-Reboredo/bpf-Add-config-for-skipping-BTF-enum64s/20220829-005156
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: csky-randconfig-r005-20220828 (https://download.01.org/0day-ci/archive/20220829/202208290218.ZY8JJWnv-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/f3a761ad9050394b31ca80192708bea109c5e536
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Martin-Reboredo/bpf-Add-config-for-skipping-BTF-enum64s/20220829-005156
        git checkout f3a761ad9050394b31ca80192708bea109c5e536
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 ARCH=csky 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> grep: include/config/auto.conf: No such file or directory
>> grep: include/config/auto.conf: No such file or directory
>> grep: include/config/auto.conf: No such file or directory
diff mbox series

Patch

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 072e4b289c13..638a33cf9e57 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -356,6 +356,20 @@  config PAHOLE_HAS_BTF_TAG
 	  btf_decl_tag) or not. Currently only clang compiler implements
 	  these attributes, so make the config depend on CC_IS_CLANG.
 
+config PAHOLE_HAS_SKIP_ENCODING_BTF_ENUM64
+	def_bool PAHOLE_VERSION >= 124
+	help
+	  Encoding BTF enum64s can be skipped with the
+	  --skip_encoding_btf_enum64 pahole option.
+
+config DEBUG_INFO_BTF_SKIP_ENCODING_ENUM64
+	def_bool n
+	depends on DEBUG_INFO_BTF && PAHOLE_HAS_SKIP_ENCODING_BTF_ENUM64
+	help
+	  Omit the encoding of 64 bits enum values with pahole. With certain
+	  kernel configurations having ENUM64s enabled may result in malformed
+	  output binaries.
+
 config DEBUG_INFO_BTF_MODULES
 	def_bool y
 	depends on DEBUG_INFO_BTF && MODULES && PAHOLE_HAS_SPLIT_BTF
diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
index 0d99ef17e4a5..e44bc2a947ce 100755
--- a/scripts/pahole-flags.sh
+++ b/scripts/pahole-flags.sh
@@ -9,6 +9,10 @@  fi
 
 pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE})
 
+is_enabled() {
+	grep -q "^$1=y" include/config/auto.conf
+}
+
 if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
 	# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
 	extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars"
@@ -19,5 +23,8 @@  fi
 if [ "${pahole_ver}" -ge "122" ]; then
 	extra_paholeopt="${extra_paholeopt} -j"
 fi
+if is_enabled DEBUG_INFO_BTF_SKIP_ENCODING_ENUM64; then
+	extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_enum64"
+fi
 
 echo ${extra_paholeopt}