diff options
author | Steven Rostedt <srostedt@redhat.com> | 2008-11-12 15:24:24 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-12 16:28:25 -0500 |
commit | 80e5ea4506791af206266c5921c97f11d3b17866 (patch) | |
tree | 847eb231f1c98377bdd600a801657a338cd1baa1 /kernel | |
parent | 9f029e83e968e5661d7be045bbcb620dbb909938 (diff) |
ftrace: add tracer called branch
Impact: added new branch tracer
Currently the tracing of branch profiling (unlikelys and likelys hit)
is only activated by the iter_ctrl. This patch adds a tracer called
"branch" that will just trace the branch profiling. The advantage
of adding this tracer is that it can be added to the ftrace selftests
on startup.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.h | 2 | ||||
-rw-r--r-- | kernel/trace/trace_selftest.c | 23 | ||||
-rw-r--r-- | kernel/trace/trace_unlikely.c | 42 |
3 files changed, 67 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 7fbf37b27453..9e015f5bea1d 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -420,6 +420,8 @@ extern int trace_selftest_startup_sched_switch(struct tracer *trace, | |||
420 | struct trace_array *tr); | 420 | struct trace_array *tr); |
421 | extern int trace_selftest_startup_sysprof(struct tracer *trace, | 421 | extern int trace_selftest_startup_sysprof(struct tracer *trace, |
422 | struct trace_array *tr); | 422 | struct trace_array *tr); |
423 | extern int trace_selftest_startup_branch(struct tracer *trace, | ||
424 | struct trace_array *tr); | ||
423 | #endif /* CONFIG_FTRACE_STARTUP_TEST */ | 425 | #endif /* CONFIG_FTRACE_STARTUP_TEST */ |
424 | 426 | ||
425 | extern void *head_page(struct trace_array_cpu *data); | 427 | extern void *head_page(struct trace_array_cpu *data); |
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c index 0728a105dcc1..24e6e075e6d6 100644 --- a/kernel/trace/trace_selftest.c +++ b/kernel/trace/trace_selftest.c | |||
@@ -13,6 +13,7 @@ static inline int trace_valid_entry(struct trace_entry *entry) | |||
13 | case TRACE_STACK: | 13 | case TRACE_STACK: |
14 | case TRACE_PRINT: | 14 | case TRACE_PRINT: |
15 | case TRACE_SPECIAL: | 15 | case TRACE_SPECIAL: |
16 | case TRACE_BRANCH: | ||
16 | return 1; | 17 | return 1; |
17 | } | 18 | } |
18 | return 0; | 19 | return 0; |
@@ -544,3 +545,25 @@ trace_selftest_startup_sysprof(struct tracer *trace, struct trace_array *tr) | |||
544 | return ret; | 545 | return ret; |
545 | } | 546 | } |
546 | #endif /* CONFIG_SYSPROF_TRACER */ | 547 | #endif /* CONFIG_SYSPROF_TRACER */ |
548 | |||
549 | #ifdef CONFIG_BRANCH_TRACER | ||
550 | int | ||
551 | trace_selftest_startup_branch(struct tracer *trace, struct trace_array *tr) | ||
552 | { | ||
553 | unsigned long count; | ||
554 | int ret; | ||
555 | |||
556 | /* start the tracing */ | ||
557 | trace->init(tr); | ||
558 | /* Sleep for a 1/10 of a second */ | ||
559 | msleep(100); | ||
560 | /* stop the tracing. */ | ||
561 | tracing_stop(); | ||
562 | /* check the trace buffer */ | ||
563 | ret = trace_test_buffer(tr, &count); | ||
564 | trace->reset(tr); | ||
565 | tracing_start(); | ||
566 | |||
567 | return ret; | ||
568 | } | ||
569 | #endif /* CONFIG_BRANCH_TRACER */ | ||
diff --git a/kernel/trace/trace_unlikely.c b/kernel/trace/trace_unlikely.c index e5d5969853a3..85265553918f 100644 --- a/kernel/trace/trace_unlikely.c +++ b/kernel/trace/trace_unlikely.c | |||
@@ -114,6 +114,48 @@ void disable_branch_tracing(void) | |||
114 | out_unlock: | 114 | out_unlock: |
115 | mutex_unlock(&branch_tracing_mutex); | 115 | mutex_unlock(&branch_tracing_mutex); |
116 | } | 116 | } |
117 | |||
118 | static void start_branch_trace(struct trace_array *tr) | ||
119 | { | ||
120 | enable_branch_tracing(tr); | ||
121 | } | ||
122 | |||
123 | static void stop_branch_trace(struct trace_array *tr) | ||
124 | { | ||
125 | disable_branch_tracing(); | ||
126 | } | ||
127 | |||
128 | static void branch_trace_init(struct trace_array *tr) | ||
129 | { | ||
130 | int cpu; | ||
131 | |||
132 | for_each_online_cpu(cpu) | ||
133 | tracing_reset(tr, cpu); | ||
134 | |||
135 | start_branch_trace(tr); | ||
136 | } | ||
137 | |||
138 | static void branch_trace_reset(struct trace_array *tr) | ||
139 | { | ||
140 | stop_branch_trace(tr); | ||
141 | } | ||
142 | |||
143 | struct tracer branch_trace __read_mostly = | ||
144 | { | ||
145 | .name = "branch", | ||
146 | .init = branch_trace_init, | ||
147 | .reset = branch_trace_reset, | ||
148 | #ifdef CONFIG_FTRACE_SELFTEST | ||
149 | .selftest = trace_selftest_startup_branch, | ||
150 | #endif | ||
151 | }; | ||
152 | |||
153 | __init static int init_branch_trace(void) | ||
154 | { | ||
155 | return register_tracer(&branch_trace); | ||
156 | } | ||
157 | |||
158 | device_initcall(init_branch_trace); | ||
117 | #else | 159 | #else |
118 | static inline | 160 | static inline |
119 | void trace_likely_condition(struct ftrace_branch_data *f, int val, int expect) | 161 | void trace_likely_condition(struct ftrace_branch_data *f, int val, int expect) |