1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2021 Facebook */
3 #include "vmlinux.h"
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
6 
7 char LICENSE[] SEC("license") = "GPL";
8 
9 int pid = 0;
10 int fentry_cnt = 0;
11 int fexit_cnt = 0;
12 
13 SEC("fentry/__x64_sys_nanosleep")
14 int BPF_PROG(nanosleep_fentry, const struct pt_regs *regs)
15 {
16 	if (bpf_get_current_pid_tgid() >> 32 != pid)
17 		return 0;
18 
19 	fentry_cnt++;
20 	return 0;
21 }
22 
23 SEC("fexit/__x64_sys_nanosleep")
24 int BPF_PROG(nanosleep_fexit, const struct pt_regs *regs, int ret)
25 {
26 	if (bpf_get_current_pid_tgid() >> 32 != pid)
27 		return 0;
28 
29 	fexit_cnt++;
30 	return 0;
31 }
32