diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2009-04-02 03:16:59 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-10 06:44:43 -0400 |
commit | ddd538f3e6a1a4bec2f6942f83a753263e6577b4 (patch) | |
tree | b28047205b75d7e06ecf3eb0aca08c056ed4f51c /kernel/trace/trace.c | |
parent | d1e7e02f30be672c6f6ee40908be83877a0d49d1 (diff) |
tracing: allocate page when needed
Impact: Cleanup
Sometimes, we open trace_pipe_raw, but we don't read(2) it,
we just splice(2) it, thus, the page is not used.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <srostedt@redhat.com>
LKML-Reference: <49D4666B.4010608@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 24b0168f1a29..8e189ffb899a 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -3277,19 +3277,13 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp) | |||
3277 | 3277 | ||
3278 | info->tr = &global_trace; | 3278 | info->tr = &global_trace; |
3279 | info->cpu = cpu; | 3279 | info->cpu = cpu; |
3280 | info->spare = ring_buffer_alloc_read_page(info->tr->buffer); | 3280 | info->spare = NULL; |
3281 | /* Force reading ring buffer for first read */ | 3281 | /* Force reading ring buffer for first read */ |
3282 | info->read = (unsigned int)-1; | 3282 | info->read = (unsigned int)-1; |
3283 | if (!info->spare) | ||
3284 | goto out; | ||
3285 | 3283 | ||
3286 | filp->private_data = info; | 3284 | filp->private_data = info; |
3287 | 3285 | ||
3288 | return nonseekable_open(inode, filp); | 3286 | return nonseekable_open(inode, filp); |
3289 | |||
3290 | out: | ||
3291 | kfree(info); | ||
3292 | return -ENOMEM; | ||
3293 | } | 3287 | } |
3294 | 3288 | ||
3295 | static ssize_t | 3289 | static ssize_t |
@@ -3304,6 +3298,11 @@ tracing_buffers_read(struct file *filp, char __user *ubuf, | |||
3304 | if (!count) | 3298 | if (!count) |
3305 | return 0; | 3299 | return 0; |
3306 | 3300 | ||
3301 | if (!info->spare) | ||
3302 | info->spare = ring_buffer_alloc_read_page(info->tr->buffer); | ||
3303 | if (!info->spare) | ||
3304 | return -ENOMEM; | ||
3305 | |||
3307 | /* Do we have previous read data to read? */ | 3306 | /* Do we have previous read data to read? */ |
3308 | if (info->read < PAGE_SIZE) | 3307 | if (info->read < PAGE_SIZE) |
3309 | goto read; | 3308 | goto read; |
@@ -3342,7 +3341,8 @@ static int tracing_buffers_release(struct inode *inode, struct file *file) | |||
3342 | { | 3341 | { |
3343 | struct ftrace_buffer_info *info = file->private_data; | 3342 | struct ftrace_buffer_info *info = file->private_data; |
3344 | 3343 | ||
3345 | ring_buffer_free_read_page(info->tr->buffer, info->spare); | 3344 | if (info->spare) |
3345 | ring_buffer_free_read_page(info->tr->buffer, info->spare); | ||
3346 | kfree(info); | 3346 | kfree(info); |
3347 | 3347 | ||
3348 | return 0; | 3348 | return 0; |