FILE
perf_callchain.c
File preview with syntax highlighting.
linux-6.19.14/arch/riscv/kernel/perf_callchain.c
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. */ 3 4#include <linux/perf_event.h> 5#include <linux/uaccess.h> 6 7#include <asm/stacktrace.h> 8 9static bool fill_callchain(void *entry, unsigned long pc) 10{ 11 return perf_callchain_store(entry, pc) == 0; 12} 13 14/* 15 * This will be called when the target is in user mode 16 * This function will only be called when we use 17 * "PERF_SAMPLE_CALLCHAIN" in 18 * kernel/events/core.c:perf_prepare_sample() 19 * 20 * How to trigger perf_callchain_[user/kernel] : 21 * $ perf record -e cpu-clock --call-graph fp ./program 22 * $ perf report --call-graph 23 * 24 * On RISC-V platform, the program being sampled and the C library 25 * need to be compiled with -fno-omit-frame-pointer, otherwise 26 * the user stack will not contain function frame. 27 */ 28void perf_callchain_user(struct perf_callchain_entry_ctx *entry, 29 struct pt_regs *regs) 30{ 31 if (perf_guest_state()) { 32 /* TODO: We don't support guest os callchain now */ 33 return; 34 } 35 36 arch_stack_walk_user(fill_callchain, entry, regs); 37} 38 39void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, 40 struct pt_regs *regs) 41{ 42 if (perf_guest_state()) { 43 /* TODO: We don't support guest os callchain now */ 44 return; 45 } 46 47 walk_stackframe(NULL, regs, fill_callchain, entry); 48}
~/
Read-only file preview.