mirror of
https://github.com/torvalds/linux.git
synced 2024-11-30 16:11:38 +00:00
f3c51fe02c
When examining module BTF, it is common to see core kernel structures
such as sk_buff, net_device duplicated in the module. After adding
debug messaging to BTF it turned out that much of the problem
was down to the identical struct test failing during deduplication;
sometimes the compiler adds identical structs. However
it turns out sometimes that type ids of identical struct members
can also differ, even when the containing structs are still identical.
To take an example, for struct sk_buff, debug messaging revealed
that the identical struct matching was failing for the anon
struct "headers"; specifically for the first field:
__u8 __pkt_type_offset[0]; /* 128 0 */
Looking at the code in BTF deduplication, we have code that guards
against the possibility of identical struct definitions, down to
type ids, and identical array definitions. However in this case
we have a struct which is being defined twice but does not have
identical type ids since each duplicate struct has separate type
ids for the above array member. A similar problem (though not
observed) could occur for struct-in-struct.
The solution is to make the "identical struct" test check members
not just for matching ids, but to also check if they in turn are
identical structs or arrays.
The results of doing this are quite dramatic (for some modules
at least); I see the number of type ids drop from around 10000
to just over 1000 in one module for example.
For testing use latest pahole or apply [1], otherwise dedups
can fail for the reasons described there.
Also fix return type of btf_dedup_identical_arrays() as
suggested by Andrii to match boolean return type used
elsewhere.
Fixes:
|
||
---|---|---|
.. | ||
.gitignore | ||
bpf_core_read.h | ||
bpf_endian.h | ||
bpf_gen_internal.h | ||
bpf_helpers.h | ||
bpf_prog_linfo.c | ||
bpf_tracing.h | ||
bpf.c | ||
bpf.h | ||
btf_dump.c | ||
btf.c | ||
btf.h | ||
Build | ||
gen_loader.c | ||
hashmap.c | ||
hashmap.h | ||
libbpf_common.h | ||
libbpf_errno.c | ||
libbpf_internal.h | ||
libbpf_legacy.h | ||
libbpf_probes.c | ||
libbpf_version.h | ||
libbpf.c | ||
libbpf.h | ||
libbpf.map | ||
libbpf.pc.template | ||
linker.c | ||
Makefile | ||
netlink.c | ||
nlattr.c | ||
nlattr.h | ||
relo_core.c | ||
relo_core.h | ||
ringbuf.c | ||
skel_internal.h | ||
str_error.c | ||
str_error.h | ||
strset.c | ||
strset.h | ||
usdt.bpf.h | ||
usdt.c |