diff options
author | Steven Rostedt <srostedt@redhat.com> | 2012-10-11 10:15:05 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2012-10-31 16:45:29 -0400 |
commit | 81698831bc462ff16f76bc11249a1e492424da4c (patch) | |
tree | 7d980745e74be221d0fab8607ac764ee7408edb4 | |
parent | b382ede6b5eb8188926b72a9ef42fd2354342a97 (diff) |
tracing: Enable comm recording if trace_printk() is used
If comm recording is not enabled when trace_printk() is used then
you just get this type of output:
[ adding trace_printk("hello! %d", irq); in do_IRQ ]
<...>-2843 [001] d.h. 80.812300: do_IRQ: hello! 14
<...>-2734 [002] d.h2 80.824664: do_IRQ: hello! 14
<...>-2713 [003] d.h. 80.829971: do_IRQ: hello! 14
<...>-2814 [000] d.h. 80.833026: do_IRQ: hello! 14
By enabling the comm recorder when trace_printk is enabled:
hackbench-6715 [001] d.h. 193.233776: do_IRQ: hello! 21
sshd-2659 [001] d.h. 193.665862: do_IRQ: hello! 21
<idle>-0 [001] d.h1 193.665996: do_IRQ: hello! 21
Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | kernel/trace/trace.c | 36 | ||||
-rw-r--r-- | kernel/trace/trace.h | 1 | ||||
-rw-r--r-- | kernel/trace/trace_events.c | 3 |
3 files changed, 38 insertions, 2 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index a5411b7414b1..b90a827a4641 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -1559,10 +1559,10 @@ static int alloc_percpu_trace_buffer(void) | |||
1559 | return -ENOMEM; | 1559 | return -ENOMEM; |
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | static int buffers_allocated; | ||
1563 | |||
1562 | void trace_printk_init_buffers(void) | 1564 | void trace_printk_init_buffers(void) |
1563 | { | 1565 | { |
1564 | static int buffers_allocated; | ||
1565 | |||
1566 | if (buffers_allocated) | 1566 | if (buffers_allocated) |
1567 | return; | 1567 | return; |
1568 | 1568 | ||
@@ -1575,6 +1575,34 @@ void trace_printk_init_buffers(void) | |||
1575 | tracing_update_buffers(); | 1575 | tracing_update_buffers(); |
1576 | 1576 | ||
1577 | buffers_allocated = 1; | 1577 | buffers_allocated = 1; |
1578 | |||
1579 | /* | ||
1580 | * trace_printk_init_buffers() can be called by modules. | ||
1581 | * If that happens, then we need to start cmdline recording | ||
1582 | * directly here. If the global_trace.buffer is already | ||
1583 | * allocated here, then this was called by module code. | ||
1584 | */ | ||
1585 | if (global_trace.buffer) | ||
1586 | tracing_start_cmdline_record(); | ||
1587 | } | ||
1588 | |||
1589 | void trace_printk_start_comm(void) | ||
1590 | { | ||
1591 | /* Start tracing comms if trace printk is set */ | ||
1592 | if (!buffers_allocated) | ||
1593 | return; | ||
1594 | tracing_start_cmdline_record(); | ||
1595 | } | ||
1596 | |||
1597 | static void trace_printk_start_stop_comm(int enabled) | ||
1598 | { | ||
1599 | if (!buffers_allocated) | ||
1600 | return; | ||
1601 | |||
1602 | if (enabled) | ||
1603 | tracing_start_cmdline_record(); | ||
1604 | else | ||
1605 | tracing_stop_cmdline_record(); | ||
1578 | } | 1606 | } |
1579 | 1607 | ||
1580 | /** | 1608 | /** |
@@ -2797,6 +2825,9 @@ static void set_tracer_flags(unsigned int mask, int enabled) | |||
2797 | 2825 | ||
2798 | if (mask == TRACE_ITER_OVERWRITE) | 2826 | if (mask == TRACE_ITER_OVERWRITE) |
2799 | ring_buffer_change_overwrite(global_trace.buffer, enabled); | 2827 | ring_buffer_change_overwrite(global_trace.buffer, enabled); |
2828 | |||
2829 | if (mask == TRACE_ITER_PRINTK) | ||
2830 | trace_printk_start_stop_comm(enabled); | ||
2800 | } | 2831 | } |
2801 | 2832 | ||
2802 | static ssize_t | 2833 | static ssize_t |
@@ -5099,6 +5130,7 @@ __init static int tracer_alloc_buffers(void) | |||
5099 | 5130 | ||
5100 | /* Only allocate trace_printk buffers if a trace_printk exists */ | 5131 | /* Only allocate trace_printk buffers if a trace_printk exists */ |
5101 | if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt) | 5132 | if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt) |
5133 | /* Must be called before global_trace.buffer is allocated */ | ||
5102 | trace_printk_init_buffers(); | 5134 | trace_printk_init_buffers(); |
5103 | 5135 | ||
5104 | /* To save memory, keep the ring buffer size to its minimum */ | 5136 | /* To save memory, keep the ring buffer size to its minimum */ |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index c56a233c006e..7824a55bd3fc 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -841,6 +841,7 @@ extern const char *__start___trace_bprintk_fmt[]; | |||
841 | extern const char *__stop___trace_bprintk_fmt[]; | 841 | extern const char *__stop___trace_bprintk_fmt[]; |
842 | 842 | ||
843 | void trace_printk_init_buffers(void); | 843 | void trace_printk_init_buffers(void); |
844 | void trace_printk_start_comm(void); | ||
844 | 845 | ||
845 | #undef FTRACE_ENTRY | 846 | #undef FTRACE_ENTRY |
846 | #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \ | 847 | #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \ |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index d608d09d08c0..dec47e70e254 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -1489,6 +1489,9 @@ static __init int event_trace_enable(void) | |||
1489 | if (ret) | 1489 | if (ret) |
1490 | pr_warn("Failed to enable trace event: %s\n", token); | 1490 | pr_warn("Failed to enable trace event: %s\n", token); |
1491 | } | 1491 | } |
1492 | |||
1493 | trace_printk_start_comm(); | ||
1494 | |||
1492 | return 0; | 1495 | return 0; |
1493 | } | 1496 | } |
1494 | 1497 | ||