Donglin Peng
8a090ef1e5
btf: Refactor the code by calling str_is_empty
...
Calling the str_is_empty function to clarify the code and
no functional changes are introduced.
Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Acked-by: Eduard Zingerman <eddyz87@gmail.com >
Link: https://lore.kernel.org/bpf/20260109130003.3313716-12-dolinux.peng@gmail.com
2026-01-29 14:10:19 -08:00
Donglin Peng
ad9c763445
libbpf: Verify BTF sorting
...
This patch checks whether the BTF is sorted by name in ascending
order. If sorted, binary search will be used when looking up types.
Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Acked-by: Eduard Zingerman <eddyz87@gmail.com >
Link: https://lore.kernel.org/bpf/20260109130003.3313716-6-dolinux.peng@gmail.com
2026-01-29 14:10:19 -08:00
Donglin Peng
1c96b72cb0
libbpf: Optimize type lookup with binary search for sorted BTF
...
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 types. For unsorted BTF, the
implementation falls back to the original linear search.
Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20260109130003.3313716-5-dolinux.peng@gmail.com
2026-01-29 14:10:19 -08:00
Donglin Peng
b7c6c02b5f
libbpf: Add BTF permutation support for type reordering
...
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.
Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Acked-by: Eduard Zingerman <eddyz87@gmail.com >
Link: https://lore.kernel.org/bpf/20260109130003.3313716-2-dolinux.peng@gmail.com
2026-01-29 14:10:19 -08:00