blob: 00143f3dd1969425042943e81618d0e2088510ed [file] [log] [blame]
Paul Mundt830fafe2009-11-05 16:20:09 +09001/*
2 * Performance event callchain support - SuperH architecture code
3 *
4 * Copyright (C) 2009 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/kernel.h>
11#include <linux/sched.h>
12#include <linux/perf_event.h>
13#include <linux/percpu.h>
14#include <asm/unwinder.h>
15#include <asm/ptrace.h>
16
Paul Mundt830fafe2009-11-05 16:20:09 +090017
18static void callchain_warning(void *data, char *msg)
19{
20}
21
22static void
23callchain_warning_symbol(void *data, char *msg, unsigned long symbol)
24{
25}
26
27static int callchain_stack(void *data, char *name)
28{
29 return 0;
30}
31
32static void callchain_address(void *data, unsigned long addr, int reliable)
33{
34 struct perf_callchain_entry *entry = data;
35
36 if (reliable)
Frederic Weisbecker70791ce2010-06-29 19:34:05 +020037 perf_callchain_store(entry, addr);
Paul Mundt830fafe2009-11-05 16:20:09 +090038}
39
40static const struct stacktrace_ops callchain_ops = {
41 .warning = callchain_warning,
42 .warning_symbol = callchain_warning_symbol,
43 .stack = callchain_stack,
44 .address = callchain_address,
45};
46
47static void
48perf_callchain_kernel(struct pt_regs *regs, struct perf_callchain_entry *entry)
49{
Frederic Weisbecker70791ce2010-06-29 19:34:05 +020050 perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
51 perf_callchain_store(entry, regs->pc);
Paul Mundt830fafe2009-11-05 16:20:09 +090052
53 unwind_stack(NULL, regs, NULL, &callchain_ops, entry);
54}
55
56static void
57perf_do_callchain(struct pt_regs *regs, struct perf_callchain_entry *entry)
58{
59 int is_user;
60
61 if (!regs)
62 return;
63
64 is_user = user_mode(regs);
65
Paul Mundt830fafe2009-11-05 16:20:09 +090066 /*
67 * Only the kernel side is implemented for now.
68 */
69 if (!is_user)
70 perf_callchain_kernel(regs, entry);
71}
72
73/*
74 * No need for separate IRQ and NMI entries.
75 */
76static DEFINE_PER_CPU(struct perf_callchain_entry, callchain);
77
78struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
79{
80 struct perf_callchain_entry *entry = &__get_cpu_var(callchain);
81
82 entry->nr = 0;
83
84 perf_do_callchain(regs, entry);
85
86 return entry;
87}