-
Notifications
You must be signed in to change notification settings - Fork 111
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
libbpf: BTF field iterator #7145
Conversation
Upstream branch: 49784c7 |
5580482
to
8d70356
Compare
Upstream branch: 49df001 |
853af15
to
d674ca1
Compare
8d70356
to
483d798
Compare
Upstream branch: 49df001 |
d674ca1
to
4ba0b4c
Compare
483d798
to
1eed4b7
Compare
Upstream branch: 61ce0ea |
4ba0b4c
to
30baaae
Compare
1eed4b7
to
af316d1
Compare
Upstream branch: 898ac74 |
30baaae
to
5afee67
Compare
Implement iterator-based type ID and string offset BTF field iterator. This is used extensively in BTF-handling code and BPF linker code for various sanity checks, rewriting IDs/offsets, etc. Currently this is implemented as visitor pattern calling custom callbacks, which makes the logic (especially in simple cases) unnecessarily obscure and harder to follow. Having equivalent functionality using iterator pattern makes for simpler to understand and maintain code. As we add more code for BTF processing logic in libbpf, it's best to switch to iterator pattern before adding more callback-based code. The idea for iterator-based implementation is to record offsets of necessary fields within fixed btf_type parts (which should be iterated just once), and, for kinds that have multiple members (based on vlen field), record where in each member necessary fields are located. Generic iteration code then just keeps track of last offset that was returned and handles N members correctly. Return type is just u32 pointer, where NULL is returned when all relevant fields were already iterated. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Upstream branch: 898ac74 |
Switch all BPF linker code dealing with iterating BTF type ID and string offset fields to new btf_field_iter facilities. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Use new BTF field iterator logic to replace all the callback-based visitor calls. There is still a .BTF.ext callback-based visitor APIs that should be converted, which will happens as a follow up. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Switch bpftool's code which is using libbpf-internal btf_type_visit_type_ids() helper to new btf_field_iter functionality. This makes bpftool code simpler, but also unblocks removing libbpf's btf_type_visit_type_ids() helper completely. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Now that all libbpf/bpftool code switched to btf_field_iter, remove btf_type_visit_type_ids() and btf_type_visit_str_offs() callback-based helpers as not needed anymore. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
5afee67
to
21d3727
Compare
af316d1
to
cf94588
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=858853 irrelevant now. Closing PR. |
Pull request for series with
subject: libbpf: BTF field iterator
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=858458