Searched hist:"082108 fd6932772deb7e329f118687b4c03fc6a5" (Results 1 – 1 of 1) sorted by relevance
/openbmc/linux/tools/lib/bpf/ |
H A D | btf.c | diff 082108fd6932772deb7e329f118687b4c03fc6a5 Wed Nov 09 08:26:10 CST 2022 Eduard Zingerman <eddyz87@gmail.com> libbpf: Resolve unambigous forward declarations
Resolve forward declarations that don't take part in type graphs comparisons if declaration name is unambiguous. Example:
CU #1:
struct foo; // standalone forward declaration struct foo *some_global;
CU #2:
struct foo { int x; }; struct foo *another_global;
The `struct foo` from CU #1 is not a part of any definition that is compared against another definition while `btf_dedup_struct_types` processes structural types. The the BTF after `btf_dedup_struct_types` the BTF looks as follows:
[1] STRUCT 'foo' size=4 vlen=1 ... [2] INT 'int' size=4 ... [3] PTR '(anon)' type_id=1 [4] FWD 'foo' fwd_kind=struct [5] PTR '(anon)' type_id=4
This commit adds a new pass `btf_dedup_resolve_fwds`, that maps such forward declarations to structs or unions with identical name in case if the name is not ambiguous.
The pass is positioned before `btf_dedup_ref_types` so that types [3] and [5] could be merged as a same type after [1] and [4] are merged. The final result for the example above looks as follows:
[1] STRUCT 'foo' size=4 vlen=1 'x' type_id=2 bits_offset=0 [2] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [3] PTR '(anon)' type_id=1
For defconfig kernel with BTF enabled this removes 63 forward declarations. Examples of removed declarations: `pt_regs`, `in6_addr`. The running time of `btf__dedup` function is increased by about 3%.
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Alan Maguire <alan.maguire@oracle.com> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20221109142611.879983-3-eddyz87@gmail.com
|