]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ring-buffer: only enable ring_buffer_swap_cpu when needed
authorSteven Rostedt <srostedt@redhat.com>
Fri, 4 Sep 2009 18:24:40 +0000 (14:24 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 4 Sep 2009 23:42:22 +0000 (19:42 -0400)
Since the ability to swap the cpu buffers adds a small overhead to
the recording of a trace, we only want to add it when needed.

Only the irqsoff and preemptoff tracers use this feature, and both are
not recommended for production kernels. This patch disables its use
when neither irqsoff nor preemptoff is configured.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/ring_buffer.h
kernel/trace/Kconfig
kernel/trace/ring_buffer.c

index e061b4ecdc3abe343c156bbe2848b9743fa20c72..5fcc31ed5771358b625eb24434e656e28f016cd8 100644 (file)
@@ -140,8 +140,17 @@ unsigned long ring_buffer_size(struct ring_buffer *buffer);
 void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu);
 void ring_buffer_reset(struct ring_buffer *buffer);
 
+#ifdef CONFIG_RING_BUFFER_ALLOW_SWAP
 int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
                         struct ring_buffer *buffer_b, int cpu);
+#else
+static inline int
+ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
+                    struct ring_buffer *buffer_b, int cpu)
+{
+       return -ENODEV;
+}
+#endif
 
 int ring_buffer_empty(struct ring_buffer *buffer);
 int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu);
index 163fbfc2f39fff1a29a2bb4a604ffecc5206aa08..1ea0d1234f4a36cb2b0fcb6769ddef83def4d35e 100644 (file)
@@ -62,6 +62,12 @@ config EVENT_TRACING
 config CONTEXT_SWITCH_TRACER
        bool
 
+config RING_BUFFER_ALLOW_SWAP
+       bool
+       help
+        Allow the use of ring_buffer_swap_cpu.
+        Adds a very slight overhead to tracing when enabled.
+
 # All tracer options should select GENERIC_TRACER. For those options that are
 # enabled by all tracers (context switch and event tracer) they select TRACING.
 # This allows those options to appear when no other tracer is selected. But the
@@ -146,6 +152,7 @@ config IRQSOFF_TRACER
        select TRACE_IRQFLAGS
        select GENERIC_TRACER
        select TRACER_MAX_TRACE
+       select RING_BUFFER_ALLOW_SWAP
        help
          This option measures the time spent in irqs-off critical
          sections, with microsecond accuracy.
@@ -167,6 +174,7 @@ config PREEMPT_TRACER
        depends on PREEMPT
        select GENERIC_TRACER
        select TRACER_MAX_TRACE
+       select RING_BUFFER_ALLOW_SWAP
        help
          This option measures the time spent in preemption off critical
          sections, with microsecond accuracy.
index 1766c0e8db5a81b777e06eabb20487b68630d6b8..454e74e718cfb77b4b2b0824acc93b0ce3f90aa8 100644 (file)
@@ -2084,6 +2084,7 @@ rb_reserve_next_event(struct ring_buffer *buffer,
 
        rb_start_commit(cpu_buffer);
 
+#ifdef CONFIG_RING_BUFFER_ALLOW_SWAP
        /*
         * Due to the ability to swap a cpu buffer from a buffer
         * it is possible it was swapped before we committed.
@@ -2096,6 +2097,7 @@ rb_reserve_next_event(struct ring_buffer *buffer,
                local_dec(&cpu_buffer->commits);
                return NULL;
        }
+#endif
 
        length = rb_calculate_event_length(length);
  again:
@@ -3498,6 +3500,7 @@ int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu)
 }
 EXPORT_SYMBOL_GPL(ring_buffer_empty_cpu);
 
+#ifdef CONFIG_RING_BUFFER_ALLOW_SWAP
 /**
  * ring_buffer_swap_cpu - swap a CPU buffer between two ring buffers
  * @buffer_a: One buffer to swap with
@@ -3573,6 +3576,7 @@ out:
        return ret;
 }
 EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
+#endif /* CONFIG_RING_BUFFER_ALLOW_SWAP */
 
 /**
  * ring_buffer_alloc_read_page - allocate a page to read from buffer