aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/cpu_buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/oprofile/cpu_buffer.c')
-rw-r--r--drivers/oprofile/cpu_buffer.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index f179ac2ea801..b8ef8ddcc292 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -111,14 +111,18 @@ void start_cpu_work(void)
111 111
112void end_cpu_work(void) 112void end_cpu_work(void)
113{ 113{
114 int i;
115
116 work_enabled = 0; 114 work_enabled = 0;
115}
116
117void flush_cpu_work(void)
118{
119 int i;
117 120
118 for_each_online_cpu(i) { 121 for_each_online_cpu(i) {
119 struct oprofile_cpu_buffer *b = &per_cpu(op_cpu_buffer, i); 122 struct oprofile_cpu_buffer *b = &per_cpu(op_cpu_buffer, i);
120 123
121 cancel_delayed_work(&b->work); 124 /* these works are per-cpu, no need for flush_sync */
125 flush_delayed_work(&b->work);
122 } 126 }
123} 127}
124 128
@@ -254,8 +258,10 @@ op_add_sample(struct oprofile_cpu_buffer *cpu_buf,
254 */ 258 */
255static int 259static int
256log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc, 260log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc,
257 unsigned long backtrace, int is_kernel, unsigned long event) 261 unsigned long backtrace, int is_kernel, unsigned long event,
262 struct task_struct *task)
258{ 263{
264 struct task_struct *tsk = task ? task : current;
259 cpu_buf->sample_received++; 265 cpu_buf->sample_received++;
260 266
261 if (pc == ESCAPE_CODE) { 267 if (pc == ESCAPE_CODE) {
@@ -263,7 +269,7 @@ log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc,
263 return 0; 269 return 0;
264 } 270 }
265 271
266 if (op_add_code(cpu_buf, backtrace, is_kernel, current)) 272 if (op_add_code(cpu_buf, backtrace, is_kernel, tsk))
267 goto fail; 273 goto fail;
268 274
269 if (op_add_sample(cpu_buf, pc, event)) 275 if (op_add_sample(cpu_buf, pc, event))
@@ -288,7 +294,8 @@ static inline void oprofile_end_trace(struct oprofile_cpu_buffer *cpu_buf)
288 294
289static inline void 295static inline void
290__oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, 296__oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
291 unsigned long event, int is_kernel) 297 unsigned long event, int is_kernel,
298 struct task_struct *task)
292{ 299{
293 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer); 300 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
294 unsigned long backtrace = oprofile_backtrace_depth; 301 unsigned long backtrace = oprofile_backtrace_depth;
@@ -297,7 +304,7 @@ __oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
297 * if log_sample() fail we can't backtrace since we lost the 304 * if log_sample() fail we can't backtrace since we lost the
298 * source of this event 305 * source of this event
299 */ 306 */
300 if (!log_sample(cpu_buf, pc, backtrace, is_kernel, event)) 307 if (!log_sample(cpu_buf, pc, backtrace, is_kernel, event, task))
301 /* failed */ 308 /* failed */
302 return; 309 return;
303 310
@@ -309,10 +316,17 @@ __oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
309 oprofile_end_trace(cpu_buf); 316 oprofile_end_trace(cpu_buf);
310} 317}
311 318
319void oprofile_add_ext_hw_sample(unsigned long pc, struct pt_regs * const regs,
320 unsigned long event, int is_kernel,
321 struct task_struct *task)
322{
323 __oprofile_add_ext_sample(pc, regs, event, is_kernel, task);
324}
325
312void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, 326void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
313 unsigned long event, int is_kernel) 327 unsigned long event, int is_kernel)
314{ 328{
315 __oprofile_add_ext_sample(pc, regs, event, is_kernel); 329 __oprofile_add_ext_sample(pc, regs, event, is_kernel, NULL);
316} 330}
317 331
318void oprofile_add_sample(struct pt_regs * const regs, unsigned long event) 332void oprofile_add_sample(struct pt_regs * const regs, unsigned long event)
@@ -328,7 +342,7 @@ void oprofile_add_sample(struct pt_regs * const regs, unsigned long event)
328 pc = ESCAPE_CODE; /* as this causes an early return. */ 342 pc = ESCAPE_CODE; /* as this causes an early return. */
329 } 343 }
330 344
331 __oprofile_add_ext_sample(pc, regs, event, is_kernel); 345 __oprofile_add_ext_sample(pc, regs, event, is_kernel, NULL);
332} 346}
333 347
334/* 348/*
@@ -399,7 +413,7 @@ int oprofile_write_commit(struct op_entry *entry)
399void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event) 413void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event)
400{ 414{
401 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer); 415 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
402 log_sample(cpu_buf, pc, 0, is_kernel, event); 416 log_sample(cpu_buf, pc, 0, is_kernel, event, NULL);
403} 417}
404 418
405void oprofile_add_trace(unsigned long pc) 419void oprofile_add_trace(unsigned long pc)