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("fentry.s/__x64_sys_getpgid") 43 int bench_trigger_fentry_sleep(void *ctx) 44 { 45 __sync_add_and_fetch(&hits, 1); 46 return 0; 47 } 48 49 SEC("fmod_ret/__x64_sys_getpgid") 50 int bench_trigger_fmodret(void *ctx) 51 { 52 __sync_add_and_fetch(&hits, 1); 53 return -22; 54 } 55 56 SEC("uprobe/self/uprobe_target") 57 int bench_trigger_uprobe(void *ctx) 58 { 59 __sync_add_and_fetch(&hits, 1); 60 return 0; 61 } 62