aboutsummaryrefslogtreecommitdiff
path: root/tools/bpf/bpftool/map_perf_ring.c
AgeCommit message (Collapse)AuthorFilesLines
2020-05-11tools, bpftool: Poison and replace kernel integer typedefsQuentin Monnet1-1/+1
Replace the use of kernel-only integer typedefs (u8, u32, etc.) by their user space counterpart (__u8, __u32, etc.). Similarly to what libbpf does, poison the typedefs to avoid introducing them again in the future. Signed-off-by: Quentin Monnet <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
2020-01-20bpftool: Use consistent include paths for libbpfToke Høiland-Jørgensen1-2/+2
Fix bpftool to include libbpf header files with the bpf/ prefix, to be consistent with external users of the library. Also ensure that all includes of exported libbpf header files (those that are exported on 'make install' of the library) use bracketed includes instead of quoted. To make sure no new files are introduced that doesn't include the bpf/ prefix in its include, remove tools/lib/bpf from the include path entirely, and use tools/lib instead. Fixes: 6910d7d3867a ("selftests/bpf: Ensure bpf_helper_defs.h are taken from selftests dir") Signed-off-by: Toke Høiland-Jørgensen <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
2019-08-15tools: bpftool: fix arguments for p_err() in do_event_pipe()Quentin Monnet1-2/+2
The last argument passed to some calls to the p_err() functions is not correct, it should be "*argv" instead of "**argv". This may lead to a segmentation fault error if CPU IDs or indices from the command line cannot be parsed correctly. Let's fix this. Fixes: f412eed9dfde ("tools: bpftool: add simple perf event output reader") Signed-off-by: Quentin Monnet <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]>
2019-07-08tools/bpftool: switch map event_pipe to libbpf's perf_bufferAndrii Nakryiko1-137/+64
Switch event_pipe implementation to rely on new libbpf perf buffer API (it's raw low-level variant). Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Acked-by: Yonghong Song <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
2018-12-13tools: bpftool: dual license all filesJakub Kicinski1-1/+1
Currently bpftool contains a mix of GPL-only and GPL or BSD2 licensed files. Make sure all files are dual licensed under GPLv2 and BSD-2-Clause. Signed-off-by: Jakub Kicinski <[email protected]> Acked-by: Roman Gushchin <[email protected]> Acked-by: YueHaibing <[email protected]> Acked-by: Yonghong Song <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Acked-by: Sean Young <[email protected]> Acked-by: Jiri Benc <[email protected]> Acked-by: David Calavera <[email protected]> Acked-by: Andrey Ignatov <[email protected]> Acked-by: Joe Stringer <[email protected]> Acked-by: David Ahern <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Acked-by: Petar Penkov <[email protected]> Acked-by: Sandipan Das <[email protected]> Acked-by: Prashant Bhole <[email protected]> Acked-by: Stephen Hemminger <[email protected]> Acked-by: John Fastabend <[email protected]> Acked-by: Taeung Song <[email protected]> Acked-by: Jiri Olsa <[email protected]> Acked-by: Daniel Borkmann <[email protected]> CC: [email protected] Signed-off-by: Daniel Borkmann <[email protected]>
2018-10-20bpf, libbpf: simplify and cleanup perf ring buffer walkDaniel Borkmann1-4/+6
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 <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]>
2018-08-23tools: bpftool: return from do_event_pipe() on bad argumentsQuentin Monnet1-1/+4
When command line parsing fails in the while loop in do_event_pipe() because the number of arguments is incorrect or because the keyword is unknown, an error message is displayed, but bpftool remains stuck in the loop. Make sure we exit the loop upon failure. Fixes: f412eed9dfde ("tools: bpftool: add simple perf event output reader") Signed-off-by: Quentin Monnet <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
2018-05-11tools: bpf: move the event reading loop to libbpfJakub Kicinski1-51/+15
There are two copies of event reading loop - in bpftool and trace_helpers "library". Consolidate them and move the code to libbpf. Return codes from trace_helpers are kept, but renamed to include LIBBPF prefix. Suggested-by: Alexei Starovoitov <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
2018-05-11tools: bpftool: use PERF_SAMPLE_TIME instead of reading the clockJakub Kicinski1-11/+6
Ask the kernel to include sample time in each even instead of reading the clock. This is also more accurate because our clock reading was done when user space would dump the buffer, not when sample was produced. Suggested-by: Daniel Borkmann <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
2018-05-04tools: bpftool: add simple perf event output readerJakub Kicinski1-0/+347
Users of BPF sooner or later discover perf_event_output() helpers and BPF_MAP_TYPE_PERF_EVENT_ARRAY. Dumping this array type is not possible, however, we can add simple reading of perf events. Create a new event_pipe subcommand for maps, this sub command will only work with BPF_MAP_TYPE_PERF_EVENT_ARRAY maps. Parts of the code from samples/bpf/trace_output_user.c. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>