diff options
author | Heinz Graalfs <graalfs@linux.vnet.ibm.com> | 2011-01-21 05:06:54 -0500 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2011-02-15 05:07:07 -0500 |
commit | 54ebbe7ba51d97a28a9a406203d171d61858e4b9 (patch) | |
tree | 529982f17aa0aba84a310261be0773f68f4337b1 /drivers/oprofile/cpu_buffer.c | |
parent | d14dd7e20d5e526557f5d3cfef4046a642f80924 (diff) |
oprofile: Introduce new oprofile sample add function (oprofile_add_ext_hw_sample)
This patch introduces a new oprofile sample add function
(oprofile_add_ext_hw_sample) that can also take task_struct as an
argument, which is used by the hwsampler kernel module when copying
hardware samples to OProfile buffers.
Applied with following changes:
* removed #include <linux/module.h>
* whitespace changes
* removed conditional compilation (CONFIG_HAVE_HWSAMPLER)
* modified order of functions
* fix missing function definition in header file
Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Maran Pakkirisamy <maranp@linux.vnet.ibm.com>
Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'drivers/oprofile/cpu_buffer.c')
-rw-r--r-- | drivers/oprofile/cpu_buffer.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c index 59f55441e075..b8ef8ddcc292 100644 --- a/drivers/oprofile/cpu_buffer.c +++ b/drivers/oprofile/cpu_buffer.c | |||
@@ -258,8 +258,10 @@ op_add_sample(struct oprofile_cpu_buffer *cpu_buf, | |||
258 | */ | 258 | */ |
259 | static int | 259 | static int |
260 | log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc, | 260 | log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc, |
261 | unsigned long backtrace, int is_kernel, unsigned long event) | 261 | unsigned long backtrace, int is_kernel, unsigned long event, |
262 | struct task_struct *task) | ||
262 | { | 263 | { |
264 | struct task_struct *tsk = task ? task : current; | ||
263 | cpu_buf->sample_received++; | 265 | cpu_buf->sample_received++; |
264 | 266 | ||
265 | if (pc == ESCAPE_CODE) { | 267 | if (pc == ESCAPE_CODE) { |
@@ -267,7 +269,7 @@ log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc, | |||
267 | return 0; | 269 | return 0; |
268 | } | 270 | } |
269 | 271 | ||
270 | if (op_add_code(cpu_buf, backtrace, is_kernel, current)) | 272 | if (op_add_code(cpu_buf, backtrace, is_kernel, tsk)) |
271 | goto fail; | 273 | goto fail; |
272 | 274 | ||
273 | if (op_add_sample(cpu_buf, pc, event)) | 275 | if (op_add_sample(cpu_buf, pc, event)) |
@@ -292,7 +294,8 @@ static inline void oprofile_end_trace(struct oprofile_cpu_buffer *cpu_buf) | |||
292 | 294 | ||
293 | static inline void | 295 | static inline void |
294 | __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, |
295 | unsigned long event, int is_kernel) | 297 | unsigned long event, int is_kernel, |
298 | struct task_struct *task) | ||
296 | { | 299 | { |
297 | 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); |
298 | unsigned long backtrace = oprofile_backtrace_depth; | 301 | unsigned long backtrace = oprofile_backtrace_depth; |
@@ -301,7 +304,7 @@ __oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, | |||
301 | * 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 |
302 | * source of this event | 305 | * source of this event |
303 | */ | 306 | */ |
304 | if (!log_sample(cpu_buf, pc, backtrace, is_kernel, event)) | 307 | if (!log_sample(cpu_buf, pc, backtrace, is_kernel, event, task)) |
305 | /* failed */ | 308 | /* failed */ |
306 | return; | 309 | return; |
307 | 310 | ||
@@ -313,10 +316,17 @@ __oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, | |||
313 | oprofile_end_trace(cpu_buf); | 316 | oprofile_end_trace(cpu_buf); |
314 | } | 317 | } |
315 | 318 | ||
319 | void 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 | |||
316 | void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, | 326 | void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, |
317 | unsigned long event, int is_kernel) | 327 | unsigned long event, int is_kernel) |
318 | { | 328 | { |
319 | __oprofile_add_ext_sample(pc, regs, event, is_kernel); | 329 | __oprofile_add_ext_sample(pc, regs, event, is_kernel, NULL); |
320 | } | 330 | } |
321 | 331 | ||
322 | void oprofile_add_sample(struct pt_regs * const regs, unsigned long event) | 332 | void oprofile_add_sample(struct pt_regs * const regs, unsigned long event) |
@@ -332,7 +342,7 @@ void oprofile_add_sample(struct pt_regs * const regs, unsigned long event) | |||
332 | pc = ESCAPE_CODE; /* as this causes an early return. */ | 342 | pc = ESCAPE_CODE; /* as this causes an early return. */ |
333 | } | 343 | } |
334 | 344 | ||
335 | __oprofile_add_ext_sample(pc, regs, event, is_kernel); | 345 | __oprofile_add_ext_sample(pc, regs, event, is_kernel, NULL); |
336 | } | 346 | } |
337 | 347 | ||
338 | /* | 348 | /* |
@@ -403,7 +413,7 @@ int oprofile_write_commit(struct op_entry *entry) | |||
403 | void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event) | 413 | void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event) |
404 | { | 414 | { |
405 | 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); |
406 | log_sample(cpu_buf, pc, 0, is_kernel, event); | 416 | log_sample(cpu_buf, pc, 0, is_kernel, event, NULL); |
407 | } | 417 | } |
408 | 418 | ||
409 | void oprofile_add_trace(unsigned long pc) | 419 | void oprofile_add_trace(unsigned long pc) |