Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (c) 2018 Facebook
3
4#include <vmlinux.h>
5#include <bpf/bpf_helpers.h>
6#include <bpf/bpf_tracing.h>
7
8#ifndef PERF_MAX_STACK_DEPTH
9#define PERF_MAX_STACK_DEPTH 127
10#endif
11
12typedef __u64 stack_trace_t[PERF_MAX_STACK_DEPTH];
13
14struct {
15 __uint(type, BPF_MAP_TYPE_STACK_TRACE);
16 __uint(max_entries, 16384);
17 __type(key, __u32);
18 __type(value, stack_trace_t);
19} stackmap SEC(".maps");
20
21extern bool CONFIG_UNWINDER_ORC __kconfig __weak;
22
23/*
24 * This function is here to have CONFIG_UNWINDER_ORC
25 * used and added to object BTF.
26 */
27int unused(void)
28{
29 return CONFIG_UNWINDER_ORC ? 0 : 1;
30}
31
32__u32 stack_key;
33
34SEC("kprobe.multi")
35int kprobe_multi_test(struct pt_regs *ctx)
36{
37 stack_key = bpf_get_stackid(ctx, &stackmap, 0);
38 return 0;
39}
40
41SEC("raw_tp/bpf_testmod_test_read")
42int rawtp_test(void *ctx)
43{
44 /* Skip ebpf program entry in the stack. */
45 stack_key = bpf_get_stackid(ctx, &stackmap, 0);
46 return 0;
47}
48
49char _license[] SEC("license") = "GPL";