aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/fexit_sleep.c
diff options
context:
space:
mode:
authorMaxime Ripard <[email protected]>2021-04-26 12:03:09 +0000
committerMaxime Ripard <[email protected]>2021-04-26 12:03:09 +0000
commit355b60296143a090039211c5f0e1463f84aab65a (patch)
treeb74d4ef2aea66252ea9cf77c847de6c6e72a02b7 /tools/testing/selftests/bpf/progs/fexit_sleep.c
parentdrm: Remove DRM_KMS_FB_HELPER Kconfig option (diff)
parentMerge tag 'drm-misc-next-fixes-2021-04-22' of git://anongit.freedesktop.org/d... (diff)
downloadkernel-355b60296143a090039211c5f0e1463f84aab65a.tar.gz
kernel-355b60296143a090039211c5f0e1463f84aab65a.zip
Merge drm/drm-next into drm-misc-next
Christian needs some patches from drm/next Signed-off-by: Maxime Ripard <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/fexit_sleep.c')
-rw-r--r--tools/testing/selftests/bpf/progs/fexit_sleep.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/fexit_sleep.c b/tools/testing/selftests/bpf/progs/fexit_sleep.c
new file mode 100644
index 000000000000..03a672d76353
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/fexit_sleep.c
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2021 Facebook */
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+
+char LICENSE[] SEC("license") = "GPL";
+
+int pid = 0;
+int fentry_cnt = 0;
+int fexit_cnt = 0;
+
+SEC("fentry/__x64_sys_nanosleep")
+int BPF_PROG(nanosleep_fentry, const struct pt_regs *regs)
+{
+ if ((int)bpf_get_current_pid_tgid() != pid)
+ return 0;
+
+ fentry_cnt++;
+ return 0;
+}
+
+SEC("fexit/__x64_sys_nanosleep")
+int BPF_PROG(nanosleep_fexit, const struct pt_regs *regs, int ret)
+{
+ if ((int)bpf_get_current_pid_tgid() != pid)
+ return 0;
+
+ fexit_cnt++;
+ return 0;
+}