1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
3 
4 #include <linux/ptrace.h>
5 #include <linux/bpf.h>
6 #include <bpf/bpf_helpers.h>
7 #include <bpf/bpf_tracing.h>
8 
9 struct {
10 	__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
11 	__uint(key_size, sizeof(int));
12 	__uint(value_size, sizeof(int));
13 } perf_buf_map SEC(".maps");
14 
15 SEC("tp/raw_syscalls/sys_enter")
handle_sys_enter(void * ctx)16 int handle_sys_enter(void *ctx)
17 {
18 	int cpu = bpf_get_smp_processor_id();
19 
20 	bpf_perf_event_output(ctx, &perf_buf_map, BPF_F_CURRENT_CPU,
21 			      &cpu, sizeof(cpu));
22 	return 0;
23 }
24 
25 char _license[] SEC("license") = "GPL";
26