Enhance and rework logging controls in libbpf
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest11 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/11 | libbpf: add OPTS-based bpf_btf_load() APItools/ tools/ tools/ +1 more | +56 | 0 replies | |
| 2/11 | libbpf: allow passing preallocated log_buf when loading BTF into kerneltools/ tools/ | +56 | 0 replies | |
| 3/11 | libbpf: allow passing user log setting through bpf_object_open_optstools/ tools/ tools/ | +65 | 0 replies | |
| 4/11 | libbpf: improve logging around BPF program loadingtools/ tools/ | +23 | 0 replies | |
| 5/11 | libbpf: preserve kernel error code and remove kprobe prog type guessingtools/ | +2 | 0 replies | |
| 6/11 | libbpf: add per-program log buffer setter and gettertools/ tools/ tools/ | +78 | 2 replies | |
| 7/11 | libbpf: deprecate bpf_object__load_xattr()tools/ tools/ | +11 | 0 replies | |
| 8/11 | selftests/bpf: replace all uses of bpf_load_btf() with bpf_btf_load()tools/ tools/ tools/ | +32 | 0 replies | |
| 9/11 | selftests/bpf: add test for libbpf's custom log_buf behaviortools/ tools/ | +161 | 0 replies | |
| 10/11 | selftests/bpf: remove the only use of deprecated bpf_object__load_xattr()tools/ | +5 | 0 replies | |
| 11/11 | bpftool: switch bpf_object__load_xattr() to bpf_object__load()tools/ tools/ tools/ | +21 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH bpf-next 00/11] Enhance and rework logging controls in libbpf
Add new open options and per-program setters to control BTF and program loading log verboseness and allow providing custom log buffers to capture logs of interest. Note how custom log_buf and log_level are orthogonal, which matches previous (alas less customizable) behavior of libbpf, even though it sort of worked by accident: if someone specified log_level = 1 in bpf_object__load_xattr(), first attempt to load any BPF program resulted in wasted bpf() syscall with -EINVAL due to !!log_buf != !!log_level. Then on retry libbpf would allocated log_buffer and try again, after which prog loading would succeed and libbpf would print verbose program loading log through its print callback.
This behavior is now documented and made more efficient, not wasting unnecessary syscall. But additionally, log_level can be controlled globally on a per-bpf_object level through bpf_object_open_opts, as well as on a per-program basis with bpf_program__set_log_buf() and bpf_program__set_log_level() APIs.
Now that we have a more future-proof way to set log_level, deprecate bpf_object__load_xattr().
Andrii Nakryiko (11):
libbpf: add OPTS-based bpf_btf_load() API
libbpf: allow passing preallocated log_buf when loading BTF into
kernel
libbpf: allow passing user log setting through bpf_object_open_opts
libbpf: improve logging around BPF program loading
libbpf: preserve kernel error code and remove kprobe prog type
guessing
libbpf: add per-program log buffer setter and getter
libbpf: deprecate bpf_object__load_xattr()
selftests/bpf: replace all uses of bpf_load_btf() with bpf_btf_load() selftests/bpf: add test for libbpf's custom log_buf behavior selftests/bpf: remove the only use of deprecated
bpf_object__load_xattr()
bpftool: switch bpf_object__load_xattr() to bpf_object__load()
tools/bpf/bpftool/gen.c | 11 +- tools/bpf/bpftool/prog.c | 24 +-- tools/bpf/bpftool/struct_ops.c | 15 +- tools/lib/bpf/bpf.c | 46 ++++- tools/lib/bpf/bpf.h | 22 +- tools/lib/bpf/btf.c | 78 +++++--- tools/lib/bpf/libbpf.c | 188 ++++++++++++------ tools/lib/bpf/libbpf.h | 49 ++++- tools/lib/bpf/libbpf.map | 3 + tools/lib/bpf/libbpf_internal.h | 1 + tools/lib/bpf/libbpf_probes.c | 2 +- .../selftests/bpf/map_tests/sk_storage_map.c | 2 +- .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 6 +- tools/testing/selftests/bpf/prog_tests/btf.c | 50 +++-- .../selftests/bpf/prog_tests/log_buf.c | 137 +++++++++++++ .../selftests/bpf/progs/test_log_buf.c | 24 +++ tools/testing/selftests/bpf/test_verifier.c | 2 +- tools/testing/selftests/bpf/testing_helpers.c | 10 +- 18 files changed, 509 insertions(+), 161 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/log_buf.c create mode 100644 tools/testing/selftests/bpf/progs/test_log_buf.c
Signature · 1 line
2.30.2