FILE
raw_tp_null.c
File preview with syntax highlighting.
linux-6.19.14/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 8char _license[] SEC("license") = "GPL"; 9 10int tid; 11int i; 12 13SEC("tp_btf/bpf_testmod_test_raw_tp_null_tp") 14int 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}
~/
Read-only file preview.