libbpf: Make perf_buffer__new() use OPTS-based interface
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 11 Nov 2021 05:36:20 +0000 (21:36 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Nov 2021 00:54:05 +0000 (16:54 -0800)
commit4178893465774f91dcd49465ae6f4e3cc036b7b2
tree1cb9eefd63b0d1161a18958a831d97b848092c4b
parent6084f5dc928f2ada4331ba9eda65542e94d86bc6
libbpf: Make perf_buffer__new() use OPTS-based interface

Add new variants of perf_buffer__new() and perf_buffer__new_raw() that
use OPTS-based options for future extensibility ([0]). Given all the
currently used API names are best fits, re-use them and use
___libbpf_override() approach and symbol versioning to preserve ABI and
source code compatibility. struct perf_buffer_opts and struct
perf_buffer_raw_opts are kept as well, but they are restructured such
that they are OPTS-based when used with new APIs. For struct
perf_buffer_raw_opts we keep few fields intact, so we have to also
preserve the memory location of them both when used as OPTS and for
legacy API variants. This is achieved with anonymous padding for OPTS
"incarnation" of the struct.  These pads can be eventually used for new
options.

  [0] Closes: https://github.com/libbpf/libbpf/issues/311

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211111053624.190580-6-andrii@kernel.org
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.h
tools/lib/bpf/libbpf.map