18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// Copyright (c) 2020 Facebook
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#include <linux/bpf.h>
58c2ecf20Sopenharmony_ci#include <asm/unistd.h>
68c2ecf20Sopenharmony_ci#include <bpf/bpf_helpers.h>
78c2ecf20Sopenharmony_ci#include <bpf/bpf_tracing.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cichar _license[] SEC("license") = "GPL";
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cilong hits = 0;
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciSEC("tp/syscalls/sys_enter_getpgid")
148c2ecf20Sopenharmony_ciint bench_trigger_tp(void *ctx)
158c2ecf20Sopenharmony_ci{
168c2ecf20Sopenharmony_ci	__sync_add_and_fetch(&hits, 1);
178c2ecf20Sopenharmony_ci	return 0;
188c2ecf20Sopenharmony_ci}
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciSEC("raw_tp/sys_enter")
218c2ecf20Sopenharmony_ciint BPF_PROG(bench_trigger_raw_tp, struct pt_regs *regs, long id)
228c2ecf20Sopenharmony_ci{
238c2ecf20Sopenharmony_ci	if (id == __NR_getpgid)
248c2ecf20Sopenharmony_ci		__sync_add_and_fetch(&hits, 1);
258c2ecf20Sopenharmony_ci	return 0;
268c2ecf20Sopenharmony_ci}
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciSEC("kprobe/__x64_sys_getpgid")
298c2ecf20Sopenharmony_ciint bench_trigger_kprobe(void *ctx)
308c2ecf20Sopenharmony_ci{
318c2ecf20Sopenharmony_ci	__sync_add_and_fetch(&hits, 1);
328c2ecf20Sopenharmony_ci	return 0;
338c2ecf20Sopenharmony_ci}
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciSEC("fentry/__x64_sys_getpgid")
368c2ecf20Sopenharmony_ciint bench_trigger_fentry(void *ctx)
378c2ecf20Sopenharmony_ci{
388c2ecf20Sopenharmony_ci	__sync_add_and_fetch(&hits, 1);
398c2ecf20Sopenharmony_ci	return 0;
408c2ecf20Sopenharmony_ci}
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ciSEC("fentry.s/__x64_sys_getpgid")
438c2ecf20Sopenharmony_ciint bench_trigger_fentry_sleep(void *ctx)
448c2ecf20Sopenharmony_ci{
458c2ecf20Sopenharmony_ci	__sync_add_and_fetch(&hits, 1);
468c2ecf20Sopenharmony_ci	return 0;
478c2ecf20Sopenharmony_ci}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciSEC("fmod_ret/__x64_sys_getpgid")
508c2ecf20Sopenharmony_ciint bench_trigger_fmodret(void *ctx)
518c2ecf20Sopenharmony_ci{
528c2ecf20Sopenharmony_ci	__sync_add_and_fetch(&hits, 1);
538c2ecf20Sopenharmony_ci	return -22;
548c2ecf20Sopenharmony_ci}
55