From: Vineet Gupta Date: Tue, 12 Nov 2013 10:00:03 +0000 (+0100) Subject: ARC: perf: Add kernel callchain support X-Git-Tag: firefly_0821_release~176^2~1874^2~3 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=389e3160b9b0002f8e7c95e9c0af5da6da311892;p=firefly-linux-kernel-4.4.55.git ARC: perf: Add kernel callchain support Signed-off-by: Mischa Jonker Signed-off-by: Vineet Gupta --- diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c index 181baeed4495..a6ad1e09e4be 100644 --- a/arch/arc/kernel/perf_event.c +++ b/arch/arc/kernel/perf_event.c @@ -16,6 +16,7 @@ #include #include #include +#include struct arc_pmu { struct pmu pmu; @@ -25,6 +26,34 @@ struct arc_pmu { int ev_hw_idx[PERF_COUNT_ARC_HW_MAX]; }; +struct arc_callchain_trace { + int depth; + void *perf_stuff; +}; + +static int callchain_trace(unsigned int addr, void *data) +{ + struct arc_callchain_trace *ctrl = data; + struct perf_callchain_entry *entry = ctrl->perf_stuff; + perf_callchain_store(entry, addr); + + if (ctrl->depth++ < 3) + return 0; + + return -1; +} + +void +perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs) +{ + struct arc_callchain_trace ctrl = { + .depth = 0, + .perf_stuff = entry, + }; + + arc_unwind_core(NULL, regs, callchain_trace, &ctrl); +} + static struct arc_pmu *arc_pmu; /* read counter #idx; note that counter# != event# on ARC! */