Skip to contentSkip to conversation

ftrace: add nop tracer

PATCH New Steven Noonan 1 participant 1 message Sep 19, 2008 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ftrace: add nop tracer

A no-op tracer which can serve two purposes:
1. A template for development of a new tracer.
2. A convenient way to see ftrace_printk() calls without an irrelevant trace making the output messy.

---
 kernel/trace/Kconfig          |   10 ++++++
 kernel/trace/Makefile         |    1 +
 kernel/trace/trace.h          |    4 ++
 kernel/trace/trace_nop.c      |   66 +++++++++++++++++++++++++++++++++++++++++
 kernel/trace/trace_selftest.c |    9 +++++
 5 files changed, 90 insertions(+), 0 deletions(-)
 create mode 100644 kernel/trace/trace_nop.c
kernel/trace/Kconfig +10 -0
index 16e5bb5..d7b2de7 100644
@@ -101,6 +101,16 @@ config SCHED_TRACER
 	  This tracer tracks the latency of the highest priority task
 	  to be scheduled in, starting from the point it has woken up.
 
+config NOP_TRACER
+	bool "NOP Tracer"
+	depends on HAVE_FTRACE
+	depends on DEBUG_KERNEL
+	select TRACING
+	help
+	  This tracer does nothing. The primary purpose for it is to
+	  politely print the output of ftrace_printk() calls without
+	  the overhead of an irrelevant trace taking place.
+
 config CONTEXT_SWITCH_TRACER
 	bool "Trace process context switches"
 	depends on HAVE_FTRACE
kernel/trace/Makefile +1 -0
index 58ec61c..73ba13f 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_FTRACE) += trace_functions.o
 obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o
 obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o
 obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o
+obj-$(CONFIG_NOP_TRACER) += trace_nop.o
 obj-$(CONFIG_STACK_TRACER) += trace_stack.o
 obj-$(CONFIG_MMIOTRACE) += trace_mmiotrace.o
 
kernel/trace/trace.h +4 -0
index 42f65d0..447d4b9 100644
@@ -339,6 +339,10 @@ extern int trace_selftest_startup_preemptirqsoff(struct tracer *trace,
 extern int trace_selftest_startup_wakeup(struct tracer *trace,
 					 struct trace_array *tr);
 #endif
+#ifdef CONFIG_NOP_TRACER
+extern int trace_selftest_startup_nop(struct tracer *trace,
+					 struct trace_array *tr);
+#endif
 #ifdef CONFIG_CONTEXT_SWITCH_TRACER
 extern int trace_selftest_startup_sched_switch(struct tracer *trace,
 					       struct trace_array *tr);
kernel/trace/trace_nop.c new file +66 -0

66 lines not on this page · raw message

kernel/trace/trace_selftest.c +9 -0
index 630715b..82db910 100644
@@ -418,6 +418,15 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
 }
 #endif /* CONFIG_IRQSOFF_TRACER && CONFIG_PREEMPT_TRACER */
 
+#ifdef CONFIG_NOP_TRACER
+int
+trace_selftest_startup_nop(struct tracer *trace, struct trace_array *tr)
+{
+	/* What could possibly go wrong? */
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_SCHED_TRACER
 static int trace_wakeup_test_thread(void *data)
 {
Signature · 1 line
1.6.0.2