aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2012-10-11 10:15:05 -0400
committerSteven Rostedt <rostedt@goodmis.org>2012-10-31 16:45:29 -0400
commit81698831bc462ff16f76bc11249a1e492424da4c (patch)
tree7d980745e74be221d0fab8607ac764ee7408edb4 /kernel/trace/trace.c
parentb382ede6b5eb8188926b72a9ef42fd2354342a97 (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>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c36
1 files changed, 34 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
1562static int buffers_allocated;
1563
1562void trace_printk_init_buffers(void) 1564void 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
1589void 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
1597static 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
2802static ssize_t 2833static 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 */