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 | #include "bpf_misc.h" |
9 | |
10 | char _license[] SEC("license" ) = "GPL" ; |
11 | |
12 | long hits = 0; |
13 | |
14 | SEC("tp/syscalls/sys_enter_getpgid" ) |
15 | int bench_trigger_tp(void *ctx) |
16 | { |
17 | __sync_add_and_fetch(&hits, 1); |
18 | return 0; |
19 | } |
20 | |
21 | SEC("raw_tp/sys_enter" ) |
22 | int BPF_PROG(bench_trigger_raw_tp, struct pt_regs *regs, long id) |
23 | { |
24 | if (id == __NR_getpgid) |
25 | __sync_add_and_fetch(&hits, 1); |
26 | return 0; |
27 | } |
28 | |
29 | SEC("kprobe/" SYS_PREFIX "sys_getpgid" ) |
30 | int bench_trigger_kprobe(void *ctx) |
31 | { |
32 | __sync_add_and_fetch(&hits, 1); |
33 | return 0; |
34 | } |
35 | |
36 | SEC("kretprobe/" SYS_PREFIX "sys_getpgid" ) |
37 | int bench_trigger_kretprobe(void *ctx) |
38 | { |
39 | __sync_add_and_fetch(&hits, 1); |
40 | return 0; |
41 | } |
42 | |
43 | SEC("kprobe.multi/" SYS_PREFIX "sys_getpgid" ) |
44 | int bench_trigger_kprobe_multi(void *ctx) |
45 | { |
46 | __sync_add_and_fetch(&hits, 1); |
47 | return 0; |
48 | } |
49 | |
50 | SEC("kretprobe.multi/" SYS_PREFIX "sys_getpgid" ) |
51 | int bench_trigger_kretprobe_multi(void *ctx) |
52 | { |
53 | __sync_add_and_fetch(&hits, 1); |
54 | return 0; |
55 | } |
56 | |
57 | SEC("fentry/" SYS_PREFIX "sys_getpgid" ) |
58 | int bench_trigger_fentry(void *ctx) |
59 | { |
60 | __sync_add_and_fetch(&hits, 1); |
61 | return 0; |
62 | } |
63 | |
64 | SEC("fexit/" SYS_PREFIX "sys_getpgid" ) |
65 | int bench_trigger_fexit(void *ctx) |
66 | { |
67 | __sync_add_and_fetch(&hits, 1); |
68 | return 0; |
69 | } |
70 | |
71 | SEC("fentry.s/" SYS_PREFIX "sys_getpgid" ) |
72 | int bench_trigger_fentry_sleep(void *ctx) |
73 | { |
74 | __sync_add_and_fetch(&hits, 1); |
75 | return 0; |
76 | } |
77 | |
78 | SEC("fmod_ret/" SYS_PREFIX "sys_getpgid" ) |
79 | int bench_trigger_fmodret(void *ctx) |
80 | { |
81 | __sync_add_and_fetch(&hits, 1); |
82 | return -22; |
83 | } |
84 | |
85 | SEC("uprobe" ) |
86 | int bench_trigger_uprobe(void *ctx) |
87 | { |
88 | __sync_add_and_fetch(&hits, 1); |
89 | return 0; |
90 | } |
91 | |