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_helpers.h"
7 
8 struct {
9 	__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
10 	__uint(key_size, sizeof(int));
11 	__uint(value_size, sizeof(int));
12 } perf_buf_map SEC(".maps");
13 
14 SEC("kprobe/sys_nanosleep")
15 int handle_sys_nanosleep_entry(struct pt_regs *ctx)
16 {
17 	int cpu = bpf_get_smp_processor_id();
18 
19 	bpf_perf_event_output(ctx, &perf_buf_map, BPF_F_CURRENT_CPU,
20 			      &cpu, sizeof(cpu));
21 	return 0;
22 }
23 
24 char _license[] SEC("license") = "GPL";
25 __u32 _version SEC("version") = 1;
26