aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/oprofile/perfmon.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ia64/oprofile/perfmon.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/ia64/oprofile/perfmon.c')
-rw-r--r--arch/ia64/oprofile/perfmon.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/arch/ia64/oprofile/perfmon.c b/arch/ia64/oprofile/perfmon.c
new file mode 100644
index 000000000000..b7975a469fb8
--- /dev/null
+++ b/arch/ia64/oprofile/perfmon.c
@@ -0,0 +1,100 @@
1/**
2 * @file perfmon.c
3 *
4 * @remark Copyright 2003 OProfile authors
5 * @remark Read the file COPYING
6 *
7 * @author John Levon <levon@movementarian.org>
8 */
9
10#include <linux/kernel.h>
11#include <linux/config.h>
12#include <linux/oprofile.h>
13#include <linux/sched.h>
14#include <asm/perfmon.h>
15#include <asm/ptrace.h>
16#include <asm/errno.h>
17
18static int allow_ints;
19
20static int
21perfmon_handler(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg,
22 struct pt_regs *regs, unsigned long stamp)
23{
24 int event = arg->pmd_eventid;
25
26 arg->ovfl_ctrl.bits.reset_ovfl_pmds = 1;
27
28 /* the owner of the oprofile event buffer may have exited
29 * without perfmon being shutdown (e.g. SIGSEGV)
30 */
31 if (allow_ints)
32 oprofile_add_sample(regs, event);
33 return 0;
34}
35
36
37static int perfmon_start(void)
38{
39 allow_ints = 1;
40 return 0;
41}
42
43
44static void perfmon_stop(void)
45{
46 allow_ints = 0;
47}
48
49
50#define OPROFILE_FMT_UUID { \
51 0x77, 0x7a, 0x6e, 0x61, 0x20, 0x65, 0x73, 0x69, 0x74, 0x6e, 0x72, 0x20, 0x61, 0x65, 0x0a, 0x6c }
52
53static pfm_buffer_fmt_t oprofile_fmt = {
54 .fmt_name = "oprofile_format",
55 .fmt_uuid = OPROFILE_FMT_UUID,
56 .fmt_handler = perfmon_handler,
57};
58
59
60static char * get_cpu_type(void)
61{
62 __u8 family = local_cpu_data->family;
63
64 switch (family) {
65 case 0x07:
66 return "ia64/itanium";
67 case 0x1f:
68 return "ia64/itanium2";
69 default:
70 return "ia64/ia64";
71 }
72}
73
74
75/* all the ops are handled via userspace for IA64 perfmon */
76
77static int using_perfmon;
78
79int perfmon_init(struct oprofile_operations * ops)
80{
81 int ret = pfm_register_buffer_fmt(&oprofile_fmt);
82 if (ret)
83 return -ENODEV;
84
85 ops->cpu_type = get_cpu_type();
86 ops->start = perfmon_start;
87 ops->stop = perfmon_stop;
88 using_perfmon = 1;
89 printk(KERN_INFO "oprofile: using perfmon.\n");
90 return 0;
91}
92
93
94void perfmon_exit(void)
95{
96 if (!using_perfmon)
97 return;
98
99 pfm_unregister_buffer_fmt(oprofile_fmt.fmt_uuid);
100}