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 #include "bpf_misc.h" 7 8 char LICENSE[] SEC("license") = "GPL"; 9 10 int pid = 0; 11 int fentry_cnt = 0; 12 int fexit_cnt = 0; 13 14 SEC("fentry/" SYS_PREFIX "sys_nanosleep") nanosleep_fentry(void * ctx)15int nanosleep_fentry(void *ctx) 16 { 17 if (bpf_get_current_pid_tgid() >> 32 != pid) 18 return 0; 19 20 fentry_cnt++; 21 return 0; 22 } 23 24 SEC("fexit/" SYS_PREFIX "sys_nanosleep") nanosleep_fexit(void * ctx)25int nanosleep_fexit(void *ctx) 26 { 27 if (bpf_get_current_pid_tgid() >> 32 != pid) 28 return 0; 29 30 fexit_cnt++; 31 return 0; 32 } 33