diff options
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 36 |
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 | ||
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 */ |