Skip to contentSkip to conversation

perf augmented_raw_syscalls: Use bpf_map()

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

lore
Share & tools
lore
#0 lore raw
Commit-ID:  56d8175a4d05ed31fe9c3053a83a5f8e08a284ee
Gitweb:     https://git.kernel.org/tip/56d8175a4d05ed31fe9c3053a83a5f8e08a284ee
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Thu, 24 Jan 2019 15:17:23 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 25 Jan 2019 15:12:10 +0100

perf augmented_raw_syscalls: Use bpf_map()

To make the code more compact and also paving the way to have the BTF annotation to be done transparently.

Cc Adrian Hunter <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Luis Cláudio Gonçalves <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Cc Yonghong Song <[email protected]>
---
 tools/perf/examples/bpf/augmented_raw_syscalls.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
tools/perf/examples/bpf/augmented_raw_syscalls.c +2 -12
index 9e9d4c66e53c..f9b2161e1ca4 100644
@@ -18,23 +18,13 @@
 #include <pid_filter.h>
 
 /* bpf-output associated map */
-struct bpf_map SEC("maps") __augmented_syscalls__ = {
-	.type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
-	.key_size = sizeof(int),
-	.value_size = sizeof(u32),
-	.max_entries = __NR_CPUS__,
-};
+bpf_map(__augmented_syscalls__, PERF_EVENT_ARRAY, int, u32, __NR_CPUS__);
 
 struct syscall {
 	bool	enabled;
 };
 
-struct bpf_map SEC("maps") syscalls = {
-	.type	     = BPF_MAP_TYPE_ARRAY,
-	.key_size    = sizeof(int),
-	.value_size  = sizeof(struct syscall),
-	.max_entries = 512,
-};
+bpf_map(syscalls, ARRAY, int, struct syscall, 512);
 
 struct syscall_enter_args {
 	unsigned long long common_tp_fields;