]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Don't allocate 16M for log buffer by default
authorStanislav Fomichev <sdf@google.com>
Wed, 25 Mar 2020 19:55:21 +0000 (12:55 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 25 Mar 2020 23:13:37 +0000 (00:13 +0100)
commit15242fda8bf7cc91dc4455649c1972c596787598
tree05f619c306348627204d7c73646b77b64463a174
parent0c76af006a70f0376ff3df67c60678b27e72e2ff
libbpf: Don't allocate 16M for log buffer by default

For each prog/btf load we allocate and free 16 megs of verifier buffer.
On production systems it doesn't really make sense because the
programs/btf have gone through extensive testing and (mostly) guaranteed
to successfully load.

Let's assume successful case by default and skip buffer allocation
on the first try. If there is an error, start with BPF_LOG_BUF_SIZE
and double it on each ENOSPC iteration.

v3:
* Return -ENOMEM when can't allocate log buffer (Andrii Nakryiko)

v2:
* Don't allocate the buffer at all on the first try (Andrii Nakryiko)

Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200325195521.112210-1-sdf@google.com
tools/lib/bpf/btf.c
tools/lib/bpf/libbpf.c