summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-03-30 19:07:14 +0200
committerIngo Molnar <mingo@elte.hu>2009-04-06 09:30:43 +0200
commit394ee07623cf556c8daae2b3c00cf5fea47f0811 (patch)
treef3568c9d779c282732c7bbeccb75a4bb3041b857 /kernel
parent023c54c42288416b4f43c67bfd5049a76926fad6 (diff)
downloadlinux-394ee07623cf556c8daae2b3c00cf5fea47f0811.tar.gz
linux-394ee07623cf556c8daae2b3c00cf5fea47f0811.tar.bz2
linux-394ee07623cf556c8daae2b3c00cf5fea47f0811.zip
perf_counter: provide generic callchain bits
Provide the generic callchain support bits. If hw_event->callchain is set the arch specific perf_callchain() function is called upon to provide a perf_callchain_entry structure filled with the current callchain. If it does so, it is added to the overflow output event. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Acked-by: Paul Mackerras <paulus@samba.org> Orig-LKML-Reference: <20090330171024.254266860@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/perf_counter.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index d93e9ddf7848..860cdc26bd7a 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -1654,6 +1654,17 @@ void perf_counter_do_pending(void)
}
/*
+ * Callchain support -- arch specific
+ */
+
+struct perf_callchain_entry *
+__attribute__((weak))
+perf_callchain(struct pt_regs *regs)
+{
+ return NULL;
+}
+
+/*
* Output
*/
@@ -1764,6 +1775,8 @@ static void perf_output_simple(struct perf_counter *counter,
struct {
u32 pid, tid;
} tid_entry;
+ struct perf_callchain_entry *callchain = NULL;
+ int callchain_size = 0;
header.type = PERF_EVENT_OVERFLOW;
header.size = sizeof(header);
@@ -1781,6 +1794,17 @@ static void perf_output_simple(struct perf_counter *counter,
header.size += sizeof(tid_entry);
}
+ if (counter->hw_event.callchain) {
+ callchain = perf_callchain(regs);
+
+ if (callchain) {
+ callchain_size = (1 + callchain->nr) * sizeof(u64);
+
+ header.type |= __PERF_EVENT_CALLCHAIN;
+ header.size += callchain_size;
+ }
+ }
+
ret = perf_output_begin(&handle, counter, header.size, nmi);
if (ret)
return;
@@ -1791,6 +1815,9 @@ static void perf_output_simple(struct perf_counter *counter,
if (counter->hw_event.include_tid)
perf_output_put(&handle, tid_entry);
+ if (callchain)
+ perf_output_copy(&handle, callchain, callchain_size);
+
perf_output_end(&handle);
}