Skip to content

Conversation

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

Pull request for series with
subject: Improve the performance of BTF type lookups with binary search
version: 7
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1025100

Donglin Peng added 7 commits November 18, 2025 19:27
Introduce btf__permute() API to allow in-place rearrangement of BTF types.
This function reorganizes BTF type order according to a provided array of
type IDs, updating all type references to maintain consistency.

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]>
Cc: Xiaoqin Zhang <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
This patch introduces test cases for the btf__permute function to ensure
it works correctly with both base BTF and split BTF scenarios.

The test suite includes:
- test_permute_base: Validates permutation on base BTF
- test_permute_split: Tests permutation on split BTF
- test_permute_drop_base: Validates type dropping on base BTF
- test_permute_drop_split: Tests type dropping on split BTF
- test_permute_drop_dedup: Tests type dropping and deduping

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]>
Cc: Xiaoqin Zhang <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
This patch introduces a new --btf_sort option that leverages libbpf's
btf__permute interface to reorganize BTF layout. The implementation
sorts BTF types by name in ascending order, placing anonymous types at
the end to enable efficient binary search lookup.

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]>
Cc: Xiaoqin Zhang <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
This patch introduces binary search optimization for BTF type lookups
when the BTF instance contains sorted types.

The optimization significantly improves performance when searching for
types in large BTF instances with sorted type names. For unsorted BTF
or when nr_sorted_types is zero, the implementation falls back to
the original linear search algorithm.

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]>
Cc: Xiaoqin Zhang <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
…ization

This patch adds validation to verify BTF type name sorting, enabling
binary search optimization for 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]>
Cc: Xiaoqin Zhang <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
Improve btf_find_by_name_kind() performance by adding binary search
support for sorted types. Falls back to linear search for compatibility.

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]>
Cc: Xiaoqin Zhang <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
Implement validation of BTF type ordering to enable efficient binary
search for sorted BTF.

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]>
Cc: Xiaoqin Zhang <[email protected]>
Signed-off-by: Donglin Peng <[email protected]>
@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d6ec090
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1025100
version: 7

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

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

@kernel-patches-daemon-bpf-rc kernel-patches-daemon-bpf-rc bot deleted the series/1025100=>bpf-next branch November 21, 2025 12:26
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