1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. */
4 #include <linux/perf_event.h>
5 #include <linux/uaccess.h>
7 #include <asm/stacktrace.h>
9 static bool fill_callchain(void *entry
, unsigned long pc
)
11 return perf_callchain_store(entry
, pc
) == 0;
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()
20 * How to trigger perf_callchain_[user/kernel] :
21 * $ perf record -e cpu-clock --call-graph fp ./program
22 * $ perf report --call-graph
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.
28 void perf_callchain_user(struct perf_callchain_entry_ctx
*entry
,
31 arch_stack_walk_user(fill_callchain
, entry
, regs
);
34 void perf_callchain_kernel(struct perf_callchain_entry_ctx
*entry
,
37 walk_stackframe(NULL
, regs
, fill_callchain
, entry
);