OSDN Git Service

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)
commit8395f320b407509819cc112f61a1de05780c8cba
tree05f619c306348627204d7c73646b77b64463a174
parent9fc9aad99e5d654bd3ea48861bda57f03b118ca9
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