Skip to content

Commit b382ede

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: Expand ring buffer when trace_printk() is used
Since tracing is not used by 99% of Linux users, even though tracing may be configured in, it does not make sense to allocate 1.4 Megs per CPU for the ring buffers if they are not used. Thus, on boot up the ring buffers are set to a minimal size until something needs the and they are expanded. This works well for events and tracers (function, etc), but for the asynchronous use of trace_printk() which can write to the ring buffer at any time, does not expand the buffers. On boot up a check is made to see if any trace_printk() is used to see if the trace_printk() temp buffer pages should be allocated. This same code can be used to expand the buffers as well. Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 884bfe8 commit b382ede

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,9 @@ void trace_printk_init_buffers(void)
15711571

15721572
pr_info("ftrace: Allocated trace_printk buffers\n");
15731573

1574+
/* Expand the buffers to set size */
1575+
tracing_update_buffers();
1576+
15741577
buffers_allocated = 1;
15751578
}
15761579

@@ -3030,6 +3033,10 @@ static int __tracing_resize_ring_buffer(unsigned long size, int cpu)
30303033
*/
30313034
ring_buffer_expanded = 1;
30323035

3036+
/* May be called before buffers are initialized */
3037+
if (!global_trace.buffer)
3038+
return 0;
3039+
30333040
ret = ring_buffer_resize(global_trace.buffer, size, cpu);
30343041
if (ret < 0)
30353042
return ret;

0 commit comments

Comments
 (0)