-
Notifications
You must be signed in to change notification settings - Fork 0
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
Mauricio/btfgen v6 #15
Commits on Feb 9, 2022
-
Configuration menu - View commit details
-
Copy full SHA for dc225d8 - Browse repository at this point
Copy the full SHA dc225d8View commit details -
libbpf: split bpf_core_apply_relo()
BTFGen needs to run the core relocation logic in order to understand what are the types involved in a given relocation. Currently bpf_core_apply_relo() calculates and **applies** a relocation to an instruction. Having both operations in the same function makes it difficult to only calculate the relocation without patching the instruction. This commit splits that logic in two different phases: (1) calculate the relocation and (2) patch the instruction. For the first phase bpf_core_apply_relo() is renamed to bpf_core_calc_relo_insn() who is now only on charge of calculating the relocation, the second phase uses the already existing bpf_core_patch_insn(). bpf_object__relocate_core() uses both of them and the BTFGen will use only bpf_core_calc_relo_insn(). Signed-off-by: Mauricio Vásquez <[email protected]> Signed-off-by: Rafael David Tinoco <[email protected]> Signed-off-by: Lorenzo Fontana <[email protected]> Signed-off-by: Leonardo Di Donato <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b3cdaf7 - Browse repository at this point
Copy the full SHA b3cdaf7View commit details -
libbpf: Expose bpf_core_{add,free}_cands() to bpftool
Expose bpf_core_add_cands() and bpf_core_free_cands() to handle candidates list. Signed-off-by: Mauricio Vásquez <[email protected]> Signed-off-by: Rafael David Tinoco <[email protected]> Signed-off-by: Lorenzo Fontana <[email protected]> Signed-off-by: Leonardo Di Donato <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for acc1b90 - Browse repository at this point
Copy the full SHA acc1b90View commit details -
bpftool: Add gen min_core_btf command
This command is implemented under the "gen" command in bpftool and the syntax is the following: $ bpftool gen min_core_btf INPUT OUTPUT OBJECT [OBJECT...] INPUT is the file that contains all the BTF types for a kernel and OUTPUT is the path of the minimize BTF file that will be created with only the types needed by the objects. Signed-off-by: Mauricio Vásquez <[email protected]> Signed-off-by: Rafael David Tinoco <[email protected]> Signed-off-by: Lorenzo Fontana <[email protected]> Signed-off-by: Leonardo Di Donato <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 1eca98c - Browse repository at this point
Copy the full SHA 1eca98cView commit details -
bpftool: Implement minimize_btf() and relocations recording for BTFGen
minimize_btf() receives the path of a source and destination BTF files and a list of BPF objects. This function records the relocations for all objects and then generates the BTF file by calling btfgen_get_btf() (implemented in the following commit). btfgen_record_obj() loads the BTF and BTF.ext sections of the BPF objects and loops through all CO-RE relocations. It uses bpf_core_calc_relo_insn() from libbpf and passes the target spec to btfgen_record_reloc(), that calls one of the following functions depending on the relocation kind. btfgen_record_field_relo() uses the target specification to mark all the types that are involved in a field-based CO-RE relocation. In this case types resolved and marked recursively using btfgen_mark_type(). Only the struct and union members (and their types) involved in the relocation are marked to optimize the size of the generated BTF file. btfgen_record_type_relo() marks the types involved in a type-based CO-RE relocation. In this case no members for the struct and union types are marked as libbpf doesn't use them while performing this kind of relocation. Pointed types are marked as they are used by libbpf in this case. btfgen_record_enumval_relo() marks the whole enum type for enum-based relocations. Signed-off-by: Mauricio Vásquez <[email protected]> Signed-off-by: Rafael David Tinoco <[email protected]> Signed-off-by: Lorenzo Fontana <[email protected]> Signed-off-by: Leonardo Di Donato <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0d41398 - Browse repository at this point
Copy the full SHA 0d41398View commit details -
bpftool: Implement btfgen_get_btf()
The last part of the BTFGen algorithm is to create a new BTF object with all the types that were recorded in the previous steps. This function performs two different steps: 1. Add the types to the new BTF object by using btf__add_type(). Some special logic around struct and unions is implemented to only add the members that are really used in the field-based relocations. The type ID on the new and old BTF objects is stored on a map. 2. Fix all the type IDs on the new BTF object by using the IDs saved in the previous step. Signed-off-by: Mauricio Vásquez <[email protected]> Signed-off-by: Rafael David Tinoco <[email protected]> Signed-off-by: Lorenzo Fontana <[email protected]> Signed-off-by: Leonardo Di Donato <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 5ace4b5 - Browse repository at this point
Copy the full SHA 5ace4b5View commit details -
bpftool: gen min_core_btf explanation and examples
Add "min_core_btf" feature explanation and one example of how to use it to bpftool-gen man page. Signed-off-by: Mauricio Vásquez <[email protected]> Signed-off-by: Rafael David Tinoco <[email protected]> Signed-off-by: Lorenzo Fontana <[email protected]> Signed-off-by: Leonardo Di Donato <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 7950bf8 - Browse repository at this point
Copy the full SHA 7950bf8View commit details -
selftests/bpf: Test "bpftool gen min_core_btf"
This commit reuses the core_reloc test to check if the BTF files generated with "bpftool gen min_core_btf" are correct. This introduces test_core_btfgen() that runs all the core_reloc tests, but this time the source BTF files are generated by using "bpftool gen min_core_btf". The goal of this test is to check that the generated files are usable, and not to check if the algorithm is creating an optimized BTF file. Signed-off-by: Mauricio Vásquez <[email protected]> Signed-off-by: Rafael David Tinoco <[email protected]> Signed-off-by: Lorenzo Fontana <[email protected]> Signed-off-by: Leonardo Di Donato <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for a9a0204 - Browse repository at this point
Copy the full SHA a9a0204View commit details