]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
tracing: expand the ring buffers when an event is activated
authorSteven Rostedt <srostedt@redhat.com>
Wed, 11 Mar 2009 18:33:00 +0000 (14:33 -0400)
committerSteven Rostedt <srostedt@redhat.com>
Thu, 12 Mar 2009 02:15:24 +0000 (22:15 -0400)
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
kernel/trace/trace.h
kernel/trace/trace_events.c

index 0c1dc1850858b444e39c7368c399c2ccc2a119f5..35ee63ae41224627bee4a5bcd4cee8e4a8c67fa5 100644 (file)
@@ -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 *
index c5e1d8865fe4d2d4036dd886f447cbf737b45de7..336324d717f88d633466062b35f55af8883e69fd 100644 (file)
@@ -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,
index 769dfd00fc859a1b4ba78b7e30696c651d5b904e..ca624df735916d3264d6d2a7f3f273f8972d265c 100644 (file)
@@ -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: