diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2008-12-03 17:45:11 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-04 04:18:39 -0500 |
commit | 1fd8f2a3f9a91b287a876cef830b21baafc8a799 (patch) | |
tree | 2baf0dfb14e3765efa370edafa2ab7f78d654308 /kernel/trace/trace.c | |
parent | b29144c317fb748dae6d72c0f88eda9d43165b8d (diff) |
tracing/function-graph-tracer: handle ftrace_printk entries
Handle the TRACE_PRINT entries from the function grapg tracer
and output them as a C comment just below the function that called
it, as if it was a comment inside this function.
Example with an ftrace_printk inside might_sleep() function:
void __might_sleep(char *file, int line)
{
static unsigned long prev_jiffy; /* ratelimiting */
ftrace_printk("Hi I'm a comment in might_sleep() :-)");
A chunk of a resulting trace:
0) | _reiserfs_free_block() {
0) | reiserfs_read_bitmap_block() {
0) | __bread() {
0) | __getblk() {
0) | __find_get_block() {
0) 0.698 us | mark_page_accessed();
0) 2.267 us | }
0) | __might_sleep() {
0) | /* Hi I'm a comment in might_sleep() :-) */
0) 1.321 us | }
0) 5.872 us | }
0) 7.313 us | }
0) 8.718 us | }
And this patch brings two minor fixes:
- The newline after a switch-out task has disappeared
- The "|" sign just before the cpu number on task-switch has been deleted.
0) 0.616 us | pick_next_task_rt();
0) 1.457 us | _spin_trylock();
0) 0.653 us | _spin_unlock();
0) 0.728 us | _spin_trylock();
0) 0.631 us | _spin_unlock();
0) 0.729 us | native_load_sp0();
0) 0.593 us | native_load_tls();
------------------------------------------
0) cat-2834 => migrati-3
------------------------------------------
0) | finish_task_switch() {
0) 0.841 us | _spin_unlock_irq();
0) 0.616 us | post_schedule_rt();
0) 3.882 us | }
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8b6409a62b54..1ca74c0cee6a 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -3335,7 +3335,7 @@ static int mark_printk(const char *fmt, ...) | |||
3335 | int ret; | 3335 | int ret; |
3336 | va_list args; | 3336 | va_list args; |
3337 | va_start(args, fmt); | 3337 | va_start(args, fmt); |
3338 | ret = trace_vprintk(0, fmt, args); | 3338 | ret = trace_vprintk(0, -1, fmt, args); |
3339 | va_end(args); | 3339 | va_end(args); |
3340 | return ret; | 3340 | return ret; |
3341 | } | 3341 | } |
@@ -3564,9 +3564,16 @@ static __init int tracer_init_debugfs(void) | |||
3564 | return 0; | 3564 | return 0; |
3565 | } | 3565 | } |
3566 | 3566 | ||
3567 | int trace_vprintk(unsigned long ip, const char *fmt, va_list args) | 3567 | int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args) |
3568 | { | 3568 | { |
3569 | static DEFINE_SPINLOCK(trace_buf_lock); | 3569 | /* |
3570 | * Raw Spinlock because a normal spinlock would be traced here | ||
3571 | * and append an irrelevant couple spin_lock_irqsave/ | ||
3572 | * spin_unlock_irqrestore traced by ftrace around this | ||
3573 | * TRACE_PRINTK trace. | ||
3574 | */ | ||
3575 | static raw_spinlock_t trace_buf_lock = | ||
3576 | (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | ||
3570 | static char trace_buf[TRACE_BUF_SIZE]; | 3577 | static char trace_buf[TRACE_BUF_SIZE]; |
3571 | 3578 | ||
3572 | struct ring_buffer_event *event; | 3579 | struct ring_buffer_event *event; |
@@ -3587,7 +3594,8 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args) | |||
3587 | if (unlikely(atomic_read(&data->disabled))) | 3594 | if (unlikely(atomic_read(&data->disabled))) |
3588 | goto out; | 3595 | goto out; |
3589 | 3596 | ||
3590 | spin_lock_irqsave(&trace_buf_lock, flags); | 3597 | local_irq_save(flags); |
3598 | __raw_spin_lock(&trace_buf_lock); | ||
3591 | len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args); | 3599 | len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args); |
3592 | 3600 | ||
3593 | len = min(len, TRACE_BUF_SIZE-1); | 3601 | len = min(len, TRACE_BUF_SIZE-1); |
@@ -3601,13 +3609,15 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args) | |||
3601 | tracing_generic_entry_update(&entry->ent, flags, pc); | 3609 | tracing_generic_entry_update(&entry->ent, flags, pc); |
3602 | entry->ent.type = TRACE_PRINT; | 3610 | entry->ent.type = TRACE_PRINT; |
3603 | entry->ip = ip; | 3611 | entry->ip = ip; |
3612 | entry->depth = depth; | ||
3604 | 3613 | ||
3605 | memcpy(&entry->buf, trace_buf, len); | 3614 | memcpy(&entry->buf, trace_buf, len); |
3606 | entry->buf[len] = 0; | 3615 | entry->buf[len] = 0; |
3607 | ring_buffer_unlock_commit(tr->buffer, event, irq_flags); | 3616 | ring_buffer_unlock_commit(tr->buffer, event, irq_flags); |
3608 | 3617 | ||
3609 | out_unlock: | 3618 | out_unlock: |
3610 | spin_unlock_irqrestore(&trace_buf_lock, flags); | 3619 | __raw_spin_unlock(&trace_buf_lock); |
3620 | local_irq_restore(flags); | ||
3611 | 3621 | ||
3612 | out: | 3622 | out: |
3613 | preempt_enable_notrace(); | 3623 | preempt_enable_notrace(); |
@@ -3625,7 +3635,13 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...) | |||
3625 | return 0; | 3635 | return 0; |
3626 | 3636 | ||
3627 | va_start(ap, fmt); | 3637 | va_start(ap, fmt); |
3628 | ret = trace_vprintk(ip, fmt, ap); | 3638 | |
3639 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | ||
3640 | ret = trace_vprintk(ip, current->curr_ret_stack, fmt, ap); | ||
3641 | #else | ||
3642 | ret = trace_vprintk(ip, -1, fmt, ap); | ||
3643 | #endif | ||
3644 | |||
3629 | va_end(ap); | 3645 | va_end(ap); |
3630 | return ret; | 3646 | return ret; |
3631 | } | 3647 | } |