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