1 // SPDX-License-Identifier: GPL-2.0 2 // Copyright (c) 2020 Facebook 3 4 #include <linux/bpf.h> 5 #include <asm/unistd.h> 6 #include <bpf/bpf_helpers.h> 7 #include <bpf/bpf_tracing.h> 8 9 char _license[] SEC("license") = "GPL"; 10 11 long hits = 0; 12 13 SEC("tp/syscalls/sys_enter_getpgid") 14 int bench_trigger_tp(void *ctx) 15 { 16 __sync_add_and_fetch(&hits, 1); 17 return 0; 18 } 19 20 SEC("raw_tp/sys_enter") 21 int BPF_PROG(bench_trigger_raw_tp, struct pt_regs *regs, long id) 22 { 23 if (id == __NR_getpgid) 24 __sync_add_and_fetch(&hits, 1); 25 return 0; 26 } 27 28 SEC("kprobe/__x64_sys_getpgid") 29 int bench_trigger_kprobe(void *ctx) 30 { 31 __sync_add_and_fetch(&hits, 1); 32 return 0; 33 } 34 35 SEC("fentry/__x64_sys_getpgid") 36 int bench_trigger_fentry(void *ctx) 37 { 38 __sync_add_and_fetch(&hits, 1); 39 return 0; 40 } 41 42 SEC("fmod_ret/__x64_sys_getpgid") 43 int bench_trigger_fmodret(void *ctx) 44 { 45 __sync_add_and_fetch(&hits, 1); 46 return -22; 47 } 48