diff options
| author | Andrii Nakryiko <[email protected]> | 2021-08-15 07:06:02 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2021-08-16 22:45:08 +0000 |
| commit | 668ace0ea5ab5acdb33cff0b66fcd8f41c16a0b0 (patch) | |
| tree | 3931bd0dc283f65780b202d19fe891ee3ef107cc /tools/lib/bpf/bpf.c | |
| parent | libbpf: Remove unused bpf_link's destroy operation, but add dealloc (diff) | |
| download | kernel-668ace0ea5ab5acdb33cff0b66fcd8f41c16a0b0.tar.gz kernel-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 <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/bpf.c')
0 files changed, 0 insertions, 0 deletions
