]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, libbpf: simplify and cleanup perf ring buffer walk
authorDaniel Borkmann <daniel@iogearbox.net>
Sun, 21 Oct 2018 00:09:28 +0000 (02:09 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 21 Oct 2018 06:13:32 +0000 (23:13 -0700)
commit1f2ec07187553f1438becc541485dd8930c3aac9
treeee60aebfc20747a4df2532951263c3f64858f802
parentf422d9f579541c1c5736ed150c9036163c836e17
bpf, libbpf: simplify and cleanup perf ring buffer walk

Simplify bpf_perf_event_read_simple() a bit and fix up some minor
things along the way: the return code in the header is not of type
int but enum bpf_perf_event_ret instead. Once callback indicated
to break the loop walking event data, it also needs to be consumed
in data_tail since it has been processed already.

Moreover, bpf_perf_event_print_t callback should avoid void * as
we actually get a pointer to struct perf_event_header and thus
applications can make use of container_of() to have type checks.
The walk also doesn't have to use modulo op since the ring size is
required to be power of two.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/bpf/bpftool/map_perf_ring.c
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.h
tools/testing/selftests/bpf/trace_helpers.c