WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / trigger_bench.c
blob9a4d09590b3dcd997aff34d6cabf9fbe3ac84e40
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Facebook
4 #include <linux/bpf.h>
5 #include <asm/unistd.h>
6 #include <bpf/bpf_helpers.h>
7 #include <bpf/bpf_tracing.h>
9 char _license[] SEC("license") = "GPL";
11 long hits = 0;
13 SEC("tp/syscalls/sys_enter_getpgid")
14 int bench_trigger_tp(void *ctx)
16 __sync_add_and_fetch(&hits, 1);
17 return 0;
20 SEC("raw_tp/sys_enter")
21 int BPF_PROG(bench_trigger_raw_tp, struct pt_regs *regs, long id)
23 if (id == __NR_getpgid)
24 __sync_add_and_fetch(&hits, 1);
25 return 0;
28 SEC("kprobe/__x64_sys_getpgid")
29 int bench_trigger_kprobe(void *ctx)
31 __sync_add_and_fetch(&hits, 1);
32 return 0;
35 SEC("fentry/__x64_sys_getpgid")
36 int bench_trigger_fentry(void *ctx)
38 __sync_add_and_fetch(&hits, 1);
39 return 0;
42 SEC("fentry.s/__x64_sys_getpgid")
43 int bench_trigger_fentry_sleep(void *ctx)
45 __sync_add_and_fetch(&hits, 1);
46 return 0;
49 SEC("fmod_ret/__x64_sys_getpgid")
50 int bench_trigger_fmodret(void *ctx)
52 __sync_add_and_fetch(&hits, 1);
53 return -22;