pahole
&
data-type profiling update




Arnaldo Carvalho de Melo
acme@redhat.com

pahole



  • Reproducible builds
  • --btf_features
  • DECL_TAG for kfuncs

Reproducible build



  • kernel patch disabling parallel BTF encoding
  • Need: same BTF generated for a given vmlinux
  • Keep parallel DWARF loading
  • Encode BTF in the same DWARF CU order
  • tests/reproducible_build.sh

Performance diff



  • Minimal
  • TODO: add numbers from cset comments
--btf_features

  • Simplify scripts/Makefile.btf
  • Older pahole ignores unknown features
  • --btf_features_strict while developing
  • Check one last time for pahole version
  • v1.26
scripts/Makefile.btf

# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
ifeq ($(call test-le, $(pahole-ver), 121),y)
pahole-flags-$(call test-ge, $(pahole-ver), 118) += --skip_encoding_btf_vars
endif

pahole-flags-$(call test-ge, $(pahole-ver), 121) += --btf_gen_floats

pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j

pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE)   += --lang_exclude=rust

pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsistent_proto --btf_gen_optimized

export PAHOLE_FLAGS := $(pahole-flags-y)
					
With --btf_features

# Switch to using --btf_features for v1.26 and later.
pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j --btf_features=encode_force,var,float,enum64,
                                                                     decl_tag,type_tag,optimized_func,
                                                                     consistent_func
					
DECL_TAG for kfuncs

  • Stores BTF_KIND_DECL_TAG for kfuncs
  • From .BTF_ids vmlinux ELF section
  • Enables tools to find about kfuncs
  • --btf_features=decl_tag,decl_tag_kfuncs
Example (use a better one)
$ bpftool btf dump file .tmp_vmlinux.btf | rg "DECL_TAG 'bpf_kfunc'" | wc -l
121

$ bpftool btf dump file .tmp_vmlinux.btf | rg 56337
[56337] FUNC 'bpf_ct_change_timeout' type_id=56336 linkage=static
[127861] DECL_TAG 'bpf_kfunc' type_id=56337 component_idx=-1
					
pahole todo

  • Support kfunc decls in pfunct
  • parallel reproducible encoding of BTF

data-type profiling



  • Recap:
  • perf mem
  • perf c2c

Resolving types



  • DWARF location expressions
  • Type info from DWARF

Use BTF?



  • BTF Type info
  • per-cpu variables in BTF
  • kallsyms
  • Kernel functions using registers as args
  • TO BE CONTINUED