Skip to contentSkip to conversation

perf bpf: Add bpf_map dumper

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Feb 28, 2019 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  d19f856479feef7c1383f02b87688563a0ef7a14
Gitweb:     https://git.kernel.org/tip/d19f856479feef7c1383f02b87688563a0ef7a14
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Tue, 19 Feb 2019 16:11:56 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 19 Feb 2019 16:11:56 -0300

perf bpf: Add bpf_map dumper

At some point I'll suggest moving this to libbpf, for now I'll experiment with ways to dump BPF maps set by events in 'perf trace', starting with a very basic dumper for the current very limited needs of the augmented_raw_syscalls code: dumping booleans.

Having functions that apply to the map keys and values and do table lookup in things like syscall id to string tables should come next.

Cc Adrian Hunter <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Yonghong Song <[email protected]>
---
 tools/perf/util/Build     |  1 +
 tools/perf/util/bpf_map.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/bpf_map.h | 22 +++++++++++++++
 3 files changed, 95 insertions(+)
tools/perf/util/Build +1 -0
index 3008d49fa587..8dd3102301ea 100644
@@ -115,6 +115,7 @@ perf-y += branch.o
 perf-y += mem2node.o
 
 perf-$(CONFIG_LIBBPF) += bpf-loader.o
+perf-$(CONFIG_LIBBPF) += bpf_map.o
 perf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
 perf-$(CONFIG_LIBELF) += symbol-elf.o
 perf-$(CONFIG_LIBELF) += probe-file.o
tools/perf/util/bpf_map.c new file +72 -0

72 lines not on this page · raw message

tools/perf/util/bpf_map.h new file +22 -0
new file mode 100644
index 000000000000..d6abd5e47af8
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+#ifndef __PERF_BPF_MAP_H
+#define __PERF_BPF_MAP_H 1
+
+#include <stdio.h>
+#include <linux/compiler.h>
+struct bpf_map;
+
+#ifdef HAVE_LIBBPF_SUPPORT
+
+int bpf_map__fprintf(struct bpf_map *map, FILE *fp);
+
+#else
+
+static inline int bpf_map__fprintf(struct bpf_map *map __maybe_unused, FILE *fp __maybe_unused)
+{
+	return 0;
+}
+
+#endif // HAVE_LIBBPF_SUPPORT
+
+#endif // __PERF_BPF_MAP_H