diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2021-08-15 09:06:02 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2021-08-17 00:45:08 +0200 |
commit | 668ace0ea5ab5acdb33cff0b66fcd8f41c16a0b0 (patch) | |
tree | 3931bd0dc283f65780b202d19fe891ee3ef107cc /tools/lib/bpf/bpf.c | |
parent | libbpf: Remove unused bpf_link's destroy operation, but add dealloc (diff) | |
download | linux-668ace0ea5ab5acdb33cff0b66fcd8f41c16a0b0.tar.xz linux-668ace0ea5ab5acdb33cff0b66fcd8f41c16a0b0.zip |
libbpf: Use BPF perf link when supported by kernel
Detect kernel support for BPF perf link and prefer it when attaching to
perf_event, tracepoint, kprobe/uprobe. Underlying perf_event FD will be kept
open until BPF link is destroyed, at which point both perf_event FD and BPF
link FD will be closed.
This preserves current behavior in which perf_event FD is open for the
duration of bpf_link's lifetime and user is able to "disconnect" bpf_link from
underlying FD (with bpf_link__disconnect()), so that bpf_link__destroy()
doesn't close underlying perf_event FD.When BPF perf link is used, disconnect
will keep both perf_event and bpf_link FDs open, so it will be up to
(advanced) user to close them. This approach is demonstrated in bpf_cookie.c
selftests, added in this patch set.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210815070609.987780-10-andrii@kernel.org
Diffstat (limited to 'tools/lib/bpf/bpf.c')
0 files changed, 0 insertions, 0 deletions