diff options
author | Steven Noonan <steven@uplinklabs.net> | 2008-09-19 06:06:43 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-14 04:37:43 -0400 |
commit | fb1b6d8b5154c692172a424e45fbd0573295cb93 (patch) | |
tree | d9a7ad2c629a6133998402354e77cd721e4962b4 | |
parent | 5bf9a1ee350a10feb94107de32a203d81fbbe706 (diff) |
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.
[ mingo@elte.hu: resolved conflicts ]
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/trace/Kconfig | 10 | ||||
-rw-r--r-- | kernel/trace/Makefile | 1 | ||||
-rw-r--r-- | kernel/trace/trace.h | 4 | ||||
-rw-r--r-- | kernel/trace/trace_nop.c | 65 | ||||
-rw-r--r-- | kernel/trace/trace_selftest.c | 9 |
5 files changed, 89 insertions, 0 deletions
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 16e5bb5daaa5..d7b2de744631 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig | |||
@@ -101,6 +101,16 @@ config SCHED_TRACER | |||
101 | This tracer tracks the latency of the highest priority task | 101 | This tracer tracks the latency of the highest priority task |
102 | to be scheduled in, starting from the point it has woken up. | 102 | to be scheduled in, starting from the point it has woken up. |
103 | 103 | ||
104 | config NOP_TRACER | ||
105 | bool "NOP Tracer" | ||
106 | depends on HAVE_FTRACE | ||
107 | depends on DEBUG_KERNEL | ||
108 | select TRACING | ||
109 | help | ||
110 | This tracer does nothing. The primary purpose for it is to | ||
111 | politely print the output of ftrace_printk() calls without | ||
112 | the overhead of an irrelevant trace taking place. | ||
113 | |||
104 | config CONTEXT_SWITCH_TRACER | 114 | config CONTEXT_SWITCH_TRACER |
105 | bool "Trace process context switches" | 115 | bool "Trace process context switches" |
106 | depends on HAVE_FTRACE | 116 | depends on HAVE_FTRACE |
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index 58ec61c44bd6..73ba13f5a461 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile | |||
@@ -19,6 +19,7 @@ obj-$(CONFIG_FTRACE) += trace_functions.o | |||
19 | obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o | 19 | obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o |
20 | obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o | 20 | obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o |
21 | obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o | 21 | obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o |
22 | obj-$(CONFIG_NOP_TRACER) += trace_nop.o | ||
22 | obj-$(CONFIG_STACK_TRACER) += trace_stack.o | 23 | obj-$(CONFIG_STACK_TRACER) += trace_stack.o |
23 | obj-$(CONFIG_MMIOTRACE) += trace_mmiotrace.o | 24 | obj-$(CONFIG_MMIOTRACE) += trace_mmiotrace.o |
24 | 25 | ||
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 42f65d0097f0..447d4b9b6391 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -339,6 +339,10 @@ extern int trace_selftest_startup_preemptirqsoff(struct tracer *trace, | |||
339 | extern int trace_selftest_startup_wakeup(struct tracer *trace, | 339 | extern int trace_selftest_startup_wakeup(struct tracer *trace, |
340 | struct trace_array *tr); | 340 | struct trace_array *tr); |
341 | #endif | 341 | #endif |
342 | #ifdef CONFIG_NOP_TRACER | ||
343 | extern int trace_selftest_startup_nop(struct tracer *trace, | ||
344 | struct trace_array *tr); | ||
345 | #endif | ||
342 | #ifdef CONFIG_CONTEXT_SWITCH_TRACER | 346 | #ifdef CONFIG_CONTEXT_SWITCH_TRACER |
343 | extern int trace_selftest_startup_sched_switch(struct tracer *trace, | 347 | extern int trace_selftest_startup_sched_switch(struct tracer *trace, |
344 | struct trace_array *tr); | 348 | struct trace_array *tr); |
diff --git a/kernel/trace/trace_nop.c b/kernel/trace/trace_nop.c new file mode 100644 index 000000000000..dafaefb84038 --- /dev/null +++ b/kernel/trace/trace_nop.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * nop tracer | ||
3 | * | ||
4 | * Copyright (C) 2008 Steven Noonan <steven@uplinklabs.net> | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | #include <linux/module.h> | ||
9 | #include <linux/fs.h> | ||
10 | #include <linux/debugfs.h> | ||
11 | #include <linux/ftrace.h> | ||
12 | |||
13 | #include "trace.h" | ||
14 | |||
15 | static struct trace_array *ctx_trace; | ||
16 | |||
17 | static void start_nop_trace(struct trace_array *tr) | ||
18 | { | ||
19 | /* Nothing to do! */ | ||
20 | } | ||
21 | |||
22 | static void stop_nop_trace(struct trace_array *tr) | ||
23 | { | ||
24 | /* Nothing to do! */ | ||
25 | } | ||
26 | |||
27 | static void nop_trace_init(struct trace_array *tr) | ||
28 | { | ||
29 | ctx_trace = tr; | ||
30 | |||
31 | if (tr->ctrl) | ||
32 | start_nop_trace(tr); | ||
33 | } | ||
34 | |||
35 | static void nop_trace_reset(struct trace_array *tr) | ||
36 | { | ||
37 | if (tr->ctrl) | ||
38 | stop_nop_trace(tr); | ||
39 | } | ||
40 | |||
41 | static void nop_trace_ctrl_update(struct trace_array *tr) | ||
42 | { | ||
43 | /* When starting a new trace, reset the buffers */ | ||
44 | if (tr->ctrl) | ||
45 | start_nop_trace(tr); | ||
46 | else | ||
47 | stop_nop_trace(tr); | ||
48 | } | ||
49 | |||
50 | static struct tracer nop_trace __read_mostly = | ||
51 | { | ||
52 | .name = "nop", | ||
53 | .init = nop_trace_init, | ||
54 | .reset = nop_trace_reset, | ||
55 | .ctrl_update = nop_trace_ctrl_update, | ||
56 | #ifdef CONFIG_FTRACE_SELFTEST | ||
57 | .selftest = trace_selftest_startup_nop, | ||
58 | #endif | ||
59 | }; | ||
60 | |||
61 | __init static int init_nop_trace(void) | ||
62 | { | ||
63 | return register_tracer(&nop_trace); | ||
64 | } | ||
65 | device_initcall(init_nop_trace); | ||
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c index 630715bbd572..82db9103b9bc 100644 --- a/kernel/trace/trace_selftest.c +++ b/kernel/trace/trace_selftest.c | |||
@@ -418,6 +418,15 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array * | |||
418 | } | 418 | } |
419 | #endif /* CONFIG_IRQSOFF_TRACER && CONFIG_PREEMPT_TRACER */ | 419 | #endif /* CONFIG_IRQSOFF_TRACER && CONFIG_PREEMPT_TRACER */ |
420 | 420 | ||
421 | #ifdef CONFIG_NOP_TRACER | ||
422 | int | ||
423 | trace_selftest_startup_nop(struct tracer *trace, struct trace_array *tr) | ||
424 | { | ||
425 | /* What could possibly go wrong? */ | ||
426 | return 0; | ||
427 | } | ||
428 | #endif | ||
429 | |||
421 | #ifdef CONFIG_SCHED_TRACER | 430 | #ifdef CONFIG_SCHED_TRACER |
422 | static int trace_wakeup_test_thread(void *data) | 431 | static int trace_wakeup_test_thread(void *data) |
423 | { | 432 | { |