diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-03-11 14:33:00 -0400 |
---|---|---|
committer | Steven Rostedt <srostedt@redhat.com> | 2009-03-11 22:15:24 -0400 |
commit | 1852fcce181faa237c010a3dbedb473cf9d4555f (patch) | |
tree | 863cd12b573fd36436e7fb042f9bd96a73a9f725 /kernel | |
parent | 73c5162aa362a543793f4a957c6c536dcbaa89ce (diff) |
tracing: expand the ring buffers when an event is activated
To save memory, the tracer ring buffers are set to a minimum.
The activating of a trace expands the ring buffer size. This patch
adds this expanding, when an event is activated.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 20 | ||||
-rw-r--r-- | kernel/trace/trace.h | 3 | ||||
-rw-r--r-- | kernel/trace/trace_events.c | 8 |
3 files changed, 31 insertions, 0 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 0c1dc1850858..35ee63ae4122 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -2357,6 +2357,26 @@ static int tracing_resize_ring_buffer(unsigned long size) | |||
2357 | return ret; | 2357 | return ret; |
2358 | } | 2358 | } |
2359 | 2359 | ||
2360 | /** | ||
2361 | * tracing_update_buffers - used by tracing facility to expand ring buffers | ||
2362 | * | ||
2363 | * To save on memory when the tracing is never used on a system with it | ||
2364 | * configured in. The ring buffers are set to a minimum size. But once | ||
2365 | * a user starts to use the tracing facility, then they need to grow | ||
2366 | * to their default size. | ||
2367 | * | ||
2368 | * This function is to be called when a tracer is about to be used. | ||
2369 | */ | ||
2370 | int tracing_update_buffers(void) | ||
2371 | { | ||
2372 | int ret = 0; | ||
2373 | |||
2374 | if (!ring_buffer_expanded) | ||
2375 | ret = tracing_resize_ring_buffer(trace_buf_size); | ||
2376 | |||
2377 | return ret; | ||
2378 | } | ||
2379 | |||
2360 | struct trace_option_dentry; | 2380 | struct trace_option_dentry; |
2361 | 2381 | ||
2362 | static struct trace_option_dentry * | 2382 | static struct trace_option_dentry * |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index c5e1d8865fe4..336324d717f8 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -737,6 +737,9 @@ static inline void trace_branch_disable(void) | |||
737 | } | 737 | } |
738 | #endif /* CONFIG_BRANCH_TRACER */ | 738 | #endif /* CONFIG_BRANCH_TRACER */ |
739 | 739 | ||
740 | /* set ring buffers to default size if not already done so */ | ||
741 | int tracing_update_buffers(void); | ||
742 | |||
740 | /* trace event type bit fields, not numeric */ | 743 | /* trace event type bit fields, not numeric */ |
741 | enum { | 744 | enum { |
742 | TRACE_EVENT_TYPE_PRINTF = 1, | 745 | TRACE_EVENT_TYPE_PRINTF = 1, |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 769dfd00fc85..ca624df73591 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -141,6 +141,10 @@ ftrace_event_write(struct file *file, const char __user *ubuf, | |||
141 | if (!cnt || cnt < 0) | 141 | if (!cnt || cnt < 0) |
142 | return 0; | 142 | return 0; |
143 | 143 | ||
144 | ret = tracing_update_buffers(); | ||
145 | if (ret < 0) | ||
146 | return ret; | ||
147 | |||
144 | ret = get_user(ch, ubuf++); | 148 | ret = get_user(ch, ubuf++); |
145 | if (ret) | 149 | if (ret) |
146 | return ret; | 150 | return ret; |
@@ -331,6 +335,10 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
331 | if (ret < 0) | 335 | if (ret < 0) |
332 | return ret; | 336 | return ret; |
333 | 337 | ||
338 | ret = tracing_update_buffers(); | ||
339 | if (ret < 0) | ||
340 | return ret; | ||
341 | |||
334 | switch (val) { | 342 | switch (val) { |
335 | case 0: | 343 | case 0: |
336 | case 1: | 344 | case 1: |