Skip to content

Conversation

@kernel-patches-daemon-bpf-rc
Copy link

Pull request for series with
subject: Significantly Improve BTF Type Lookup Performance
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1013472

Donglin Peng added 5 commits October 20, 2025 02:45
Change btf_find_by_name_kind() to search the local BTF first,
then fall back to the base BTF. This can skip traversing the large
vmlinux BTF when the target type resides in a kernel module's BTF,
thereby significantly improving lookup performance.

In a test searching for the btf_type of function ext2_new_inode
located in the ext2 kernel module:

Before: 408631 ns
After:     499 ns

Performance improvement: ~819x faster

Cc: Eduard Zingerman <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Andrii Nakryiko <[email protected]>
Cc: Alan Maguire <[email protected]>
Cc: Song Liu <[email protected]>
Signed-off-by: pengdonglin <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
This patch implements sorting of BTF types by their kind and name,
enabling the use of binary search for type lookups.

To share logic between kernel and libbpf, a new btf_sort.c file is
introduced containing common sorting functionality.

The sorting is performed during btf__dedup() when the new
sort_by_kind_name option in btf_dedup_opts is enabled.

For vmlinux and kernel module BTF, btf_check_sorted() verifies
whether the types are sorted and binary search can be used.

Cc: Eduard Zingerman <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Andrii Nakryiko <[email protected]>
Cc: Alan Maguire <[email protected]>
Cc: Song Liu <[email protected]>
Co-developed-by: Eduard Zingerman <[email protected]>
Signed-off-by: pengdonglin <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
Now that libbpf supports sorted BTF types, add a check to determine
whether binary search can be used for type lookups.

Cc: Eduard Zingerman <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Andrii Nakryiko <[email protected]>
Cc: Alan Maguire <[email protected]>
Cc: Song Liu <[email protected]>
Signed-off-by: pengdonglin <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
Verify that BTF deduplication and sorting functionality works correctly

Cc: Eduard Zingerman <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Andrii Nakryiko <[email protected]>
Cc: Alan Maguire <[email protected]>
Cc: Song Liu <[email protected]>
Signed-off-by: pengdonglin <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
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 <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Andrii Nakryiko <[email protected]>
Cc: Alan Maguire <[email protected]>
Cc: Song Liu <[email protected]>
Signed-off-by: pengdonglin <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 7361c86
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1013472
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1013472 expired. Closing PR.

@kernel-patches-daemon-bpf-rc kernel-patches-daemon-bpf-rc bot deleted the series/1013472=>bpf-next branch October 22, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant