1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Facebook
4 #include <bpf/bpf_helpers.h>
6 #ifndef PERF_MAX_STACK_DEPTH
7 #define PERF_MAX_STACK_DEPTH 127
10 typedef __u64 stack_trace_t[PERF_MAX_STACK_DEPTH];
12 __uint(type, BPF_MAP_TYPE_STACK_TRACE);
13 __uint(max_entries, 16384);
15 __type(value, stack_trace_t);
16 } stackmap SEC(".maps");
19 __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
20 __uint(max_entries, 1);
22 __type(value, stack_trace_t);
23 } stackdata_map SEC(".maps");
25 long stackid_kernel = 1;
26 long stackid_user = 1;
27 long stack_kernel = 1;
37 val = bpf_get_stackid(ctx, &stackmap, 0);
40 val = bpf_get_stackid(ctx, &stackmap, BPF_F_USER_STACK);
44 trace = bpf_map_lookup_elem(&stackdata_map, &key);
48 val = bpf_get_stack(ctx, trace, sizeof(stack_trace_t), 0);
52 val = bpf_get_stack(ctx, trace, sizeof(stack_trace_t), BPF_F_USER_STACK);
59 char LICENSE[] SEC("license") = "GPL";