1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef OPROFILE_H
14#define OPROFILE_H
15
16#include <linux/types.h>
17#include <linux/spinlock.h>
18#include <asm/atomic.h>
19
20
21
22
23
24
25
26#define ESCAPE_CODE ~0UL
27#define CTX_SWITCH_CODE 1
28#define CPU_SWITCH_CODE 2
29#define COOKIE_SWITCH_CODE 3
30#define KERNEL_ENTER_SWITCH_CODE 4
31#define KERNEL_EXIT_SWITCH_CODE 5
32#define MODULE_LOADED_CODE 6
33#define CTX_TGID_CODE 7
34#define TRACE_BEGIN_CODE 8
35#define TRACE_END_CODE 9
36#define XEN_ENTER_SWITCH_CODE 10
37#define SPU_PROFILING_CODE 11
38#define SPU_CTX_SWITCH_CODE 12
39#define IBS_FETCH_CODE 13
40#define IBS_OP_CODE 14
41
42struct super_block;
43struct dentry;
44struct file_operations;
45struct pt_regs;
46
47
48struct oprofile_operations {
49
50
51 int (*create_files)(struct super_block * sb, struct dentry * root);
52
53 int (*setup)(void);
54
55 void (*shutdown)(void);
56
57 int (*start)(void);
58
59 void (*stop)(void);
60
61
62
63
64
65 int (*sync_start)(void);
66 int (*sync_stop)(void);
67
68
69 void (*backtrace)(struct pt_regs * const regs, unsigned int depth);
70
71
72 int (*switch_events)(void);
73
74 char * cpu_type;
75};
76
77
78
79
80
81
82
83
84int oprofile_arch_init(struct oprofile_operations * ops);
85
86
87
88
89void oprofile_arch_exit(void);
90
91
92
93
94void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
95
96
97
98
99
100
101
102
103void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
104 unsigned long event, int is_kernel);
105
106
107
108void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event);
109
110
111void oprofile_add_trace(unsigned long eip);
112
113
114
115
116
117
118int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
119 char const * name, const struct file_operations * fops);
120
121int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
122 char const * name, const struct file_operations * fops, int perm);
123
124
125int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
126 char const * name, ulong * val);
127
128
129int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
130 char const * name, ulong * val);
131
132
133int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
134 char const * name, atomic_t * val);
135
136
137struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
138 char const * name);
139
140
141
142
143
144ssize_t oprofilefs_str_to_user(char const * str, char __user * buf, size_t count, loff_t * offset);
145
146
147
148
149
150ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t count, loff_t * offset);
151
152
153
154
155
156int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count);
157
158
159extern spinlock_t oprofilefs_lock;
160
161
162
163
164void oprofile_put_buff(unsigned long *buf, unsigned int start,
165 unsigned int stop, unsigned int max);
166
167unsigned long oprofile_get_cpu_buffer_size(void);
168void oprofile_cpu_buffer_inc_smpl_lost(void);
169
170
171
172struct op_sample;
173
174struct op_entry {
175 struct ring_buffer_event *event;
176 struct op_sample *sample;
177 unsigned long size;
178 unsigned long *data;
179};
180
181void oprofile_write_reserve(struct op_entry *entry,
182 struct pt_regs * const regs,
183 unsigned long pc, int code, int size);
184int oprofile_add_data(struct op_entry *entry, unsigned long val);
185int oprofile_add_data64(struct op_entry *entry, u64 val);
186int oprofile_write_commit(struct op_entry *entry);
187
188#endif
189