Pahole v1.32 and later supports BTF sorting. Add a new configuration option to control whether to enable this feature for vmlinux and kernel modules. Cc: Eduard Zingerman Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Alan Maguire Cc: Song Liu Signed-off-by: pengdonglin Signed-off-by: Donglin Peng --- kernel/bpf/Kconfig | 8 ++++++++ scripts/Makefile.btf | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/kernel/bpf/Kconfig b/kernel/bpf/Kconfig index eb3de35734f0..08251a250f06 100644 --- a/kernel/bpf/Kconfig +++ b/kernel/bpf/Kconfig @@ -101,4 +101,12 @@ config BPF_LSM If you are unsure how to answer this question, answer N. +config BPF_SORT_BTF_BY_KIND_NAME + bool "Sort BTF types by kind and name" + depends on BPF_SYSCALL + help + This option sorts BTF types in vmlinux and kernel modules by their + kind and name, enabling binary search for btf_find_by_name_kind() + and significantly improving its lookup performance. + endmenu # "BPF subsystem" diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf index db76335dd917..3f1a0b3c3f3f 100644 --- a/scripts/Makefile.btf +++ b/scripts/Makefile.btf @@ -29,6 +29,11 @@ ifneq ($(KBUILD_EXTMOD),) module-pahole-flags-$(call test-ge, $(pahole-ver), 128) += --btf_features=distilled_base endif +ifeq ($(call test-ge, $(pahole-ver), 132),y) +pahole-flags-$(CONFIG_BPF_SORT_BTF_BY_KIND_NAME) += --btf_features=sort +module-pahole-flags-$(CONFIG_BPF_SORT_BTF_BY_KIND_NAME) += --btf_features=sort +endif + endif pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust -- 2.34.1