diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2014-06-10 12:06:30 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-06-10 12:06:30 -0400 |
commit | f0b70cc48cc282cb326a4d71b3d1dda7d8fafd2a (patch) | |
tree | a473fffec9136b96c542b0b8f6334f7e545aee51 /kernel | |
parent | a6af8fbf17989e41fef5cacf3988a724fb687d78 (diff) |
tracing: Fix leak of per cpu max data in instances
The freeing of an instance, if max data is configured, there will be
per cpu data structures created. But these are not freed when the instance
is deleted, which causes a memory leak.
A new helper function is added that frees the individual buffers within a
trace array, instead of duplicating the code. This way changes made for one
are applied to the other (normal buffer vs max buffer).
Link: http://lkml.kernel.org/r/87k38pbake.fsf@sejong.aot.lge.com
Reported-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 2b458c60e0da..384ede311717 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -6242,22 +6242,25 @@ static int allocate_trace_buffers(struct trace_array *tr, int size) | |||
6242 | return 0; | 6242 | return 0; |
6243 | } | 6243 | } |
6244 | 6244 | ||
6245 | static void free_trace_buffer(struct trace_buffer *buf) | ||
6246 | { | ||
6247 | if (buf->buffer) { | ||
6248 | ring_buffer_free(buf->buffer); | ||
6249 | buf->buffer = NULL; | ||
6250 | free_percpu(buf->data); | ||
6251 | buf->data = NULL; | ||
6252 | } | ||
6253 | } | ||
6254 | |||
6245 | static void free_trace_buffers(struct trace_array *tr) | 6255 | static void free_trace_buffers(struct trace_array *tr) |
6246 | { | 6256 | { |
6247 | if (!tr) | 6257 | if (!tr) |
6248 | return; | 6258 | return; |
6249 | 6259 | ||
6250 | if (tr->trace_buffer.buffer) { | 6260 | free_trace_buffer(&tr->trace_buffer); |
6251 | ring_buffer_free(tr->trace_buffer.buffer); | ||
6252 | tr->trace_buffer.buffer = NULL; | ||
6253 | free_percpu(tr->trace_buffer.data); | ||
6254 | } | ||
6255 | 6261 | ||
6256 | #ifdef CONFIG_TRACER_MAX_TRACE | 6262 | #ifdef CONFIG_TRACER_MAX_TRACE |
6257 | if (tr->max_buffer.buffer) { | 6263 | free_trace_buffer(&tr->max_buffer); |
6258 | ring_buffer_free(tr->max_buffer.buffer); | ||
6259 | tr->max_buffer.buffer = NULL; | ||
6260 | } | ||
6261 | #endif | 6264 | #endif |
6262 | } | 6265 | } |
6263 | 6266 | ||