]> git.baikalelectronics.ru Git - kernel.git/commit
Merge branch 'Enhance and rework logging controls in libbpf'
authorAlexei Starovoitov <ast@kernel.org>
Thu, 9 Dec 2021 23:40:34 +0000 (15:40 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 10 Dec 2021 23:35:14 +0000 (15:35 -0800)
commit5110926448a57e1c3a20b4984e8fa497b35f1e26
tree0e92aea9d74a32c822d7232e3293fb51a1cc4e87
parent8d3bb5519c6365b369786d6210db83ffe6ba0868
parentda3b5cc75048e8e5e20ddb64ea33356a871d6d4b
Merge branch 'Enhance and rework logging controls in libbpf'

Andrii Nakryiko says:

====================

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().

v2->v3:
  - added log_buf selftests for bpf_prog_load() and bpf_btf_load();
  - fix !log_buf in bpf_prog_load (John);
  - fix log_level==0 in bpf_btf_load (thanks selftest!);

v1->v2:
  - fix log_level == 0 handling of bpf_prog_load, add as patch #1 (Alexei);
  - add comments explaining log_buf_size overflow prevention (Alexei).
====================

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>