-
Notifications
You must be signed in to change notification settings - Fork 148
BTF performance optimizations with permutation and binary search #10222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bpf-next_base
Are you sure you want to change the base?
Conversation
|
Upstream branch: b54a8e1 |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
|
Forwarding comment 3497313314 via email |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
|
Forwarding comment 3497328259 via email |
|
Forwarding comment 3497335396 via email |
efe6edf to
f6af497
Compare
|
Upstream branch: b54a8e1 |
f685acd to
2bb7665
Compare
f6af497 to
baaa336
Compare
|
Upstream branch: 6f1f4c1 |
2bb7665 to
08c8140
Compare
baaa336 to
b6555d5
Compare
|
Upstream branch: f8c67d8 |
Refactor btf_dedup_remap_types() by extracting its core logic into a new btf_remap_types() helper function. This eliminates code duplication and improves modularity while maintaining the same functionality. The new function encapsulates iteration over BTF types and BTF ext sections, accepting a callback for flexible type ID remapping. This makes the type remapping logic more maintainable and reusable. Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: Alan Maguire <alan.maguire@oracle.com> Cc: Song Liu <song@kernel.org> Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com> Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com> Signed-off-by: Donglin Peng <dolinux.peng@gmail.com> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com>
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. The permutation process involves: 1. Shuffling types into new order based on the provided IDs array 2. Remapping all type ID references to point to new locations 3. Handling BTF extension data if provided via options This is particularly useful for optimizing type locality after BTF deduplication or for meeting specific layout requirements in specialized use cases. Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: Alan Maguire <alan.maguire@oracle.com> Cc: Song Liu <song@kernel.org> Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com> Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com> Signed-off-by: Donglin Peng <dolinux.peng@gmail.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
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 <eddyz87@gmail.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: Alan Maguire <alan.maguire@oracle.com> Cc: Song Liu <song@kernel.org> Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com> Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com> Signed-off-by: Donglin Peng <dolinux.peng@gmail.com>
This patch adds lazy validation of BTF type ordering to determine if types are sorted by name. The check is performed on first access and cached, enabling efficient binary search for sorted BTF while maintaining linear search fallback for unsorted cases. Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: Alan Maguire <alan.maguire@oracle.com> Cc: Song Liu <song@kernel.org> Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com> Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com> Signed-off-by: Donglin Peng <dolinux.peng@gmail.com>
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 <eddyz87@gmail.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: Alan Maguire <alan.maguire@oracle.com> Cc: Song Liu <song@kernel.org> Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com> Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com> Signed-off-by: Donglin Peng <dolinux.peng@gmail.com>
Implement lazy validation of BTF type ordering to enable efficient binary search for sorted BTF while maintaining linear search fallback for unsorted cases. Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: Alan Maguire <alan.maguire@oracle.com> Cc: Song Liu <song@kernel.org> Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com> Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com> Signed-off-by: Donglin Peng <dolinux.peng@gmail.com>
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 Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: Alan Maguire <alan.maguire@oracle.com> Cc: Song Liu <song@kernel.org> Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com> Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com> Signed-off-by: Donglin Peng <dolinux.peng@gmail.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
08c8140 to
26f5d88
Compare
Pull request for series with
subject: BTF performance optimizations with permutation and binary search
version: 5
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1020436