aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/perf_counter.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-03-30 13:07:14 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-06 03:30:43 -0400
commit394ee07623cf556c8daae2b3c00cf5fea47f0811 (patch)
treef3568c9d779c282732c7bbeccb75a4bb3041b857 /kernel/perf_counter.c
parent023c54c42288416b4f43c67bfd5049a76926fad6 (diff)
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/perf_counter.c')
-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)
1654} 1654}
1655 1655
1656/* 1656/*
1657 * Callchain support -- arch specific
1658 */
1659
1660struct perf_callchain_entry *
1661__attribute__((weak))
1662perf_callchain(struct pt_regs *regs)
1663{
1664 return NULL;
1665}
1666
1667/*
1657 * Output 1668 * Output
1658 */ 1669 */
1659 1670
@@ -1764,6 +1775,8 @@ static void perf_output_simple(struct perf_counter *counter,
1764 struct { 1775 struct {
1765 u32 pid, tid; 1776 u32 pid, tid;
1766 } tid_entry; 1777 } tid_entry;
1778 struct perf_callchain_entry *callchain = NULL;
1779 int callchain_size = 0;
1767 1780
1768 header.type = PERF_EVENT_OVERFLOW; 1781 header.type = PERF_EVENT_OVERFLOW;
1769 header.size = sizeof(header); 1782 header.size = sizeof(header);
@@ -1781,6 +1794,17 @@ static void perf_output_simple(struct perf_counter *counter,
1781 header.size += sizeof(tid_entry); 1794 header.size += sizeof(tid_entry);
1782 } 1795 }
1783 1796
1797 if (counter->hw_event.callchain) {
1798 callchain = perf_callchain(regs);
1799
1800 if (callchain) {
1801 callchain_size = (1 + callchain->nr) * sizeof(u64);
1802
1803 header.type |= __PERF_EVENT_CALLCHAIN;
1804 header.size += callchain_size;
1805 }
1806 }
1807
1784 ret = perf_output_begin(&handle, counter, header.size, nmi); 1808 ret = perf_output_begin(&handle, counter, header.size, nmi);
1785 if (ret) 1809 if (ret)
1786 return; 1810 return;
@@ -1791,6 +1815,9 @@ static void perf_output_simple(struct perf_counter *counter,
1791 if (counter->hw_event.include_tid) 1815 if (counter->hw_event.include_tid)
1792 perf_output_put(&handle, tid_entry); 1816 perf_output_put(&handle, tid_entry);
1793 1817
1818 if (callchain)
1819 perf_output_copy(&handle, callchain, callchain_size);
1820
1794 perf_output_end(&handle); 1821 perf_output_end(&handle);
1795} 1822}
1796 1823