[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-ddd538f3e6a1a4bec2f6942f83a753263e6577b4@git.kernel.org>
Date: Fri, 10 Apr 2009 11:07:01 GMT
From: Lai Jiangshan <laijs@...fujitsu.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, hpa@...or.com, mingo@...hat.com,
fweisbec@...il.com, srostedt@...hat.com, tglx@...utronix.de,
laijs@...fujitsu.com, mingo@...e.hu
Subject: [tip:tracing/core] tracing: allocate page when needed
Commit-ID: ddd538f3e6a1a4bec2f6942f83a753263e6577b4
Gitweb: http://git.kernel.org/tip/ddd538f3e6a1a4bec2f6942f83a753263e6577b4
Author: Lai Jiangshan <laijs@...fujitsu.com>
AuthorDate: Thu, 2 Apr 2009 15:16:59 +0800
Committer: Ingo Molnar <mingo@...e.hu>
CommitDate: Fri, 10 Apr 2009 12:44:43 +0200
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@...fujitsu.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Steven Rostedt <srostedt@...hat.com>
LKML-Reference: <49D4666B.4010608@...fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
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 24b0168..8e189ff 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)
info->tr = &global_trace;
info->cpu = cpu;
- info->spare = ring_buffer_alloc_read_page(info->tr->buffer);
+ info->spare = NULL;
/* Force reading ring buffer for first read */
info->read = (unsigned int)-1;
- if (!info->spare)
- goto out;
filp->private_data = info;
return nonseekable_open(inode, filp);
-
- out:
- kfree(info);
- return -ENOMEM;
}
static ssize_t
@@ -3304,6 +3298,11 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
if (!count)
return 0;
+ if (!info->spare)
+ info->spare = ring_buffer_alloc_read_page(info->tr->buffer);
+ if (!info->spare)
+ return -ENOMEM;
+
/* Do we have previous read data to read? */
if (info->read < PAGE_SIZE)
goto read;
@@ -3342,7 +3341,8 @@ static int tracing_buffers_release(struct inode *inode, struct file *file)
{
struct ftrace_buffer_info *info = file->private_data;
- ring_buffer_free_read_page(info->tr->buffer, info->spare);
+ if (info->spare)
+ ring_buffer_free_read_page(info->tr->buffer, info->spare);
kfree(info);
return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists