public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Wu Fengguang <fengguang.wu@intel.com>,
	Pierre Ossman <drzeus@drzeus.cx>, Pekka Paalanen <pq@iki.fi>,
	Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 2/4] tracing: expand the ring buffers when an event is activated
Date: Wed, 11 Mar 2009 22:37:22 -0400	[thread overview]
Message-ID: <20090312023936.262487851@goodmis.org> (raw)
In-Reply-To: 20090312023720.144716747@goodmis.org

[-- Attachment #1: 0002-tracing-expand-the-ring-buffers-when-an-event-is-ac.patch --]
[-- Type: text/plain, Size: 2441 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

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>
---
 kernel/trace/trace.c        |   20 ++++++++++++++++++++
 kernel/trace/trace.h        |    3 +++
 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 0c1dc18..35ee63a 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2357,6 +2357,26 @@ static int tracing_resize_ring_buffer(unsigned long size)
 	return ret;
 }
 
+/**
+ * tracing_update_buffers - used by tracing facility to expand ring buffers
+ *
+ * To save on memory when the tracing is never used on a system with it
+ * configured in. The ring buffers are set to a minimum size. But once
+ * a user starts to use the tracing facility, then they need to grow
+ * to their default size.
+ *
+ * This function is to be called when a tracer is about to be used.
+ */
+int tracing_update_buffers(void)
+{
+	int ret = 0;
+
+	if (!ring_buffer_expanded)
+		ret = tracing_resize_ring_buffer(trace_buf_size);
+
+	return ret;
+}
+
 struct trace_option_dentry;
 
 static struct trace_option_dentry *
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index c5e1d88..336324d 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -737,6 +737,9 @@ static inline void trace_branch_disable(void)
 }
 #endif /* CONFIG_BRANCH_TRACER */
 
+/* set ring buffers to default size if not already done so */
+int tracing_update_buffers(void);
+
 /* trace event type bit fields, not numeric */
 enum {
 	TRACE_EVENT_TYPE_PRINTF		= 1,
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 769dfd0..ca624df 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,
 	if (!cnt || cnt < 0)
 		return 0;
 
+	ret = tracing_update_buffers();
+	if (ret < 0)
+		return ret;
+
 	ret = get_user(ch, ubuf++);
 	if (ret)
 		return ret;
@@ -331,6 +335,10 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	if (ret < 0)
 		return ret;
 
+	ret = tracing_update_buffers();
+	if (ret < 0)
+		return ret;
+
 	switch (val) {
 	case 0:
 	case 1:
-- 
1.6.1.3

-- 

  parent reply	other threads:[~2009-03-12  2:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-12  2:37 [PATCH 0/4] [GIT PULL] memory saving ring buffer for tip/tracing/ftrace Steven Rostedt
2009-03-12  2:37 ` [PATCH 1/4] tracing: keep ring buffer to minimum size till used Steven Rostedt
2009-03-12  3:26   ` Andrew Morton
2009-03-12 13:25     ` Steven Rostedt
2009-03-12 15:01   ` Frederic Weisbecker
2009-03-12 15:14     ` Steven Rostedt
2009-03-12  2:37 ` Steven Rostedt [this message]
2009-03-12  2:37 ` [PATCH 3/4] tracing: fix trace_wait to know to wait on all cpus or just one Steven Rostedt
2009-03-12  2:37 ` [PATCH 4/4] ring-buffer: only allocate buffers for online cpus Steven Rostedt
2009-03-12  3:32   ` Andrew Morton
2009-03-12 13:29     ` Steven Rostedt
2009-03-12  7:31   ` KOSAKI Motohiro
2009-03-12 13:38     ` Steven Rostedt
2009-03-12 23:47       ` KOSAKI Motohiro
2009-03-12  7:07 ` [PATCH 0/4] [GIT PULL] memory saving ring buffer for tip/tracing/ftrace Pierre Ossman
2009-03-12  7:34   ` KOSAKI Motohiro
2009-03-12  9:20     ` Pierre Ossman
2009-03-12 13:39       ` Steven Rostedt
2009-03-12 10:47   ` Neil Horman
2009-03-12 12:12     ` Pierre Ossman
2009-03-12 13:12       ` Neil Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090312023936.262487851@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=drzeus@drzeus.cx \
    --cc=fengguang.wu@intel.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=pq@iki.fi \
    --cc=srostedt@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox