diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2022-04-18 17:24:50 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-04-19 13:48:20 -0700 |
commit | a3820c48111247f4ec2ca2949597f8fa57d2c424 (patch) | |
tree | 852f76001abe06f021577659783644818071a7a7 /kernel/bpf/btf.c | |
parent | 44df171a10f8969d1456e0a5af7fbac142d7fa18 (diff) | |
download | linux-a3820c48111247f4ec2ca2949597f8fa57d2c424.tar.gz linux-a3820c48111247f4ec2ca2949597f8fa57d2c424.tar.bz2 linux-a3820c48111247f4ec2ca2949597f8fa57d2c424.zip |
libbpf: Support opting out from autoloading BPF programs declaratively
Establish SEC("?abc") naming convention (i.e., adding question mark in
front of otherwise normal section name) that allows to set corresponding
program's autoload property to false. This is effectively just
a declarative way to do bpf_program__set_autoload(prog, false).
Having a way to do this declaratively in BPF code itself is useful and
convenient for various scenarios. E.g., for testing, when BPF object
consists of multiple independent BPF programs that each needs to be
tested separately. Opting out all of them by default and then setting
autoload to true for just one of them at a time simplifies testing code
(see next patch for few conversions in BPF selftests taking advantage of
this new feature).
Another real-world use case is in libbpf-tools for cases when different
BPF programs have to be picked depending on particulars of the host
kernel due to various incompatible changes (like kernel function renames
or signature change, or to pick kprobe vs fentry depending on
corresponding kernel support for the latter). Marking all the different
BPF program candidates as non-autoloaded declaratively makes this more
obvious in BPF source code and allows simpler code in user-space code.
When BPF program marked as SEC("?abc") it is otherwise treated just like
SEC("abc") and bpf_program__section_name() reported will be "abc".
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220419002452.632125-1-andrii@kernel.org
Diffstat (limited to 'kernel/bpf/btf.c')
0 files changed, 0 insertions, 0 deletions