]> Git Repo - linux.git/blob - tools/testing/selftests/bpf/progs/raw_tp_null.c
Linux 6.14-rc3
[linux.git] / tools / testing / selftests / bpf / progs / raw_tp_null.c
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
3
4 #include <vmlinux.h>
5 #include <bpf/bpf_tracing.h>
6 #include "bpf_misc.h"
7
8 char _license[] SEC("license") = "GPL";
9
10 int tid;
11 int i;
12
13 SEC("tp_btf/bpf_testmod_test_raw_tp_null")
14 int BPF_PROG(test_raw_tp_null, struct sk_buff *skb)
15 {
16         struct task_struct *task = bpf_get_current_task_btf();
17
18         if (task->pid != tid)
19                 return 0;
20
21         /* If dead code elimination kicks in, the increment +=2 will be
22          * removed. For raw_tp programs attaching to tracepoints in kernel
23          * modules, we mark input arguments as PTR_MAYBE_NULL, so branch
24          * prediction should never kick in.
25          */
26         asm volatile ("%[i] += 1; if %[ctx] != 0 goto +1; %[i] += 2;"
27                         : [i]"+r"(i)
28                         : [ctx]"r"(skb)
29                         : "memory");
30         return 0;
31 }
This page took 0.032841 seconds and 4 git commands to generate.