Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 76 lines 1.6 kB view raw
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") 35int kprobe_test(struct pt_regs *ctx) 36{ 37 stack_key = bpf_get_stackid(ctx, &stackmap, 0); 38 return 0; 39} 40 41SEC("kprobe.multi") 42int kprobe_multi_test(struct pt_regs *ctx) 43{ 44 stack_key = bpf_get_stackid(ctx, &stackmap, 0); 45 return 0; 46} 47 48SEC("raw_tp/bpf_testmod_test_read") 49int rawtp_test(void *ctx) 50{ 51 /* Skip ebpf program entry in the stack. */ 52 stack_key = bpf_get_stackid(ctx, &stackmap, 0); 53 return 0; 54} 55 56SEC("fentry/bpf_testmod_stacktrace_test") 57int fentry_test(struct pt_regs *ctx) 58{ 59 /* 60 * Skip 2 bpf_program/trampoline stack entries: 61 * - bpf_prog_bd1f7a949f55fb03_fentry_test 62 * - bpf_trampoline_182536277701 63 */ 64 stack_key = bpf_get_stackid(ctx, &stackmap, 2); 65 return 0; 66} 67 68SEC("fexit/bpf_testmod_stacktrace_test") 69int fexit_test(struct pt_regs *ctx) 70{ 71 /* Skip 2 bpf_program/trampoline stack entries, check fentry_test. */ 72 stack_key = bpf_get_stackid(ctx, &stackmap, 2); 73 return 0; 74} 75 76char _license[] SEC("license") = "GPL";