diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-01-10 14:34:13 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-14 06:11:37 -0500 |
commit | 002bb86d8d42f18937aef396c3ecd65c7e02e21a (patch) | |
tree | ce8e81f6dc2515f6442198bbd4b527d900982f8e /kernel/trace/trace_branch.c | |
parent | a14a07b8018b714e03a39ff2180c66e307ef4238 (diff) |
tracing/ftrace: separate events tracing and stats tracing engine
Impact: tracing's Api change
Currently, the stat tracing depends on the events tracing.
When you switch to a new tracer, the stats files of the previous tracer
will disappear. But it's more scalable to separate those two engines.
This way, we can keep the stat files of one or several tracers when we
want, without bothering of multiple tracer stat files or tracer switching.
To build/destroys its stats files, a tracer just have to call
register_stat_tracer/unregister_stat_tracer everytimes it wants to.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_branch.c')
-rw-r--r-- | kernel/trace/trace_branch.c | 108 |
1 files changed, 60 insertions, 48 deletions
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c index da5cf3e5581b..ca017e0a9a27 100644 --- a/kernel/trace/trace_branch.c +++ b/kernel/trace/trace_branch.c | |||
@@ -16,12 +16,12 @@ | |||
16 | #include <asm/local.h> | 16 | #include <asm/local.h> |
17 | 17 | ||
18 | #include "trace.h" | 18 | #include "trace.h" |
19 | #include "trace_stat.h" | ||
19 | #include "trace_output.h" | 20 | #include "trace_output.h" |
20 | 21 | ||
21 | static struct tracer branch_trace; | ||
22 | |||
23 | #ifdef CONFIG_BRANCH_TRACER | 22 | #ifdef CONFIG_BRANCH_TRACER |
24 | 23 | ||
24 | static struct tracer branch_trace; | ||
25 | static int branch_tracing_enabled __read_mostly; | 25 | static int branch_tracing_enabled __read_mostly; |
26 | static DEFINE_MUTEX(branch_tracing_mutex); | 26 | static DEFINE_MUTEX(branch_tracing_mutex); |
27 | 27 | ||
@@ -191,6 +191,30 @@ static struct trace_event trace_branch_event = { | |||
191 | .binary = trace_nop_print, | 191 | .binary = trace_nop_print, |
192 | }; | 192 | }; |
193 | 193 | ||
194 | static struct tracer branch_trace __read_mostly = | ||
195 | { | ||
196 | .name = "branch", | ||
197 | .init = branch_trace_init, | ||
198 | .reset = branch_trace_reset, | ||
199 | #ifdef CONFIG_FTRACE_SELFTEST | ||
200 | .selftest = trace_selftest_startup_branch, | ||
201 | #endif /* CONFIG_FTRACE_SELFTEST */ | ||
202 | }; | ||
203 | |||
204 | __init static int init_branch_tracer(void) | ||
205 | { | ||
206 | int ret; | ||
207 | |||
208 | ret = register_ftrace_event(&trace_branch_event); | ||
209 | if (!ret) { | ||
210 | printk(KERN_WARNING "Warning: could not register " | ||
211 | "branch events\n"); | ||
212 | return 1; | ||
213 | } | ||
214 | return register_tracer(&branch_trace); | ||
215 | } | ||
216 | device_initcall(init_branch_tracer); | ||
217 | |||
194 | #else | 218 | #else |
195 | static inline | 219 | static inline |
196 | void trace_likely_condition(struct ftrace_branch_data *f, int val, int expect) | 220 | void trace_likely_condition(struct ftrace_branch_data *f, int val, int expect) |
@@ -305,6 +329,29 @@ static int annotated_branch_stat_cmp(void *p1, void *p2) | |||
305 | return 0; | 329 | return 0; |
306 | } | 330 | } |
307 | 331 | ||
332 | static struct tracer_stat annotated_branch_stats = { | ||
333 | .name = "branch_annotated", | ||
334 | .stat_start = annotated_branch_stat_start, | ||
335 | .stat_next = annotated_branch_stat_next, | ||
336 | .stat_cmp = annotated_branch_stat_cmp, | ||
337 | .stat_headers = annotated_branch_stat_headers, | ||
338 | .stat_show = branch_stat_show | ||
339 | }; | ||
340 | |||
341 | __init static int init_annotated_branch_stats(void) | ||
342 | { | ||
343 | int ret; | ||
344 | |||
345 | ret = register_stat_tracer(&annotated_branch_stats); | ||
346 | if (!ret) { | ||
347 | printk(KERN_WARNING "Warning: could not register " | ||
348 | "annotated branches stats\n"); | ||
349 | return 1; | ||
350 | } | ||
351 | return 0; | ||
352 | } | ||
353 | fs_initcall(init_annotated_branch_stats); | ||
354 | |||
308 | #ifdef CONFIG_PROFILE_ALL_BRANCHES | 355 | #ifdef CONFIG_PROFILE_ALL_BRANCHES |
309 | 356 | ||
310 | extern unsigned long __start_branch_profile[]; | 357 | extern unsigned long __start_branch_profile[]; |
@@ -339,60 +386,25 @@ all_branch_stat_next(void *v, int idx) | |||
339 | return p; | 386 | return p; |
340 | } | 387 | } |
341 | 388 | ||
342 | static struct tracer_stat branch_stats[] = { | 389 | static struct tracer_stat all_branch_stats = { |
343 | {.name = "annotated", | 390 | .name = "branch_all", |
344 | .stat_start = annotated_branch_stat_start, | ||
345 | .stat_next = annotated_branch_stat_next, | ||
346 | .stat_cmp = annotated_branch_stat_cmp, | ||
347 | .stat_headers = annotated_branch_stat_headers, | ||
348 | .stat_show = branch_stat_show}, | ||
349 | |||
350 | {.name = "all", | ||
351 | .stat_start = all_branch_stat_start, | 391 | .stat_start = all_branch_stat_start, |
352 | .stat_next = all_branch_stat_next, | 392 | .stat_next = all_branch_stat_next, |
353 | .stat_headers = all_branch_stat_headers, | 393 | .stat_headers = all_branch_stat_headers, |
354 | .stat_show = branch_stat_show}, | 394 | .stat_show = branch_stat_show |
355 | |||
356 | { } | ||
357 | }; | ||
358 | #else | ||
359 | static struct tracer_stat branch_stats[] = { | ||
360 | {.name = "annotated", | ||
361 | .stat_start = annotated_branch_stat_start, | ||
362 | .stat_next = annotated_branch_stat_next, | ||
363 | .stat_cmp = annotated_branch_stat_cmp, | ||
364 | .stat_headers = annotated_branch_stat_headers, | ||
365 | .stat_show = branch_stat_show}, | ||
366 | |||
367 | { } | ||
368 | }; | 395 | }; |
369 | #endif /* CONFIG_PROFILE_ALL_BRANCHES */ | ||
370 | 396 | ||
371 | 397 | __init static int all_annotated_branch_stats(void) | |
372 | static struct tracer branch_trace __read_mostly = | ||
373 | { | 398 | { |
374 | .name = "branch", | ||
375 | #ifdef CONFIG_BRANCH_TRACER | ||
376 | .init = branch_trace_init, | ||
377 | .reset = branch_trace_reset, | ||
378 | #ifdef CONFIG_FTRACE_SELFTEST | ||
379 | .selftest = trace_selftest_startup_branch, | ||
380 | #endif /* CONFIG_FTRACE_SELFTEST */ | ||
381 | #endif | ||
382 | .stats = branch_stats | ||
383 | }; | ||
384 | |||
385 | __init static int init_branch_trace(void) | ||
386 | { | ||
387 | #ifdef CONFIG_BRANCH_TRACER | ||
388 | int ret; | 399 | int ret; |
389 | ret = register_ftrace_event(&trace_branch_event); | 400 | |
401 | ret = register_stat_tracer(&all_branch_stats); | ||
390 | if (!ret) { | 402 | if (!ret) { |
391 | printk(KERN_WARNING "Warning: could not register branch events\n"); | 403 | printk(KERN_WARNING "Warning: could not register " |
404 | "all branches stats\n"); | ||
392 | return 1; | 405 | return 1; |
393 | } | 406 | } |
394 | #endif | 407 | return 0; |
395 | |||
396 | return register_tracer(&branch_trace); | ||
397 | } | 408 | } |
398 | device_initcall(init_branch_trace); | 409 | fs_initcall(all_annotated_branch_stats); |
410 | #endif /* CONFIG_PROFILE_ALL_BRANCHES */ | ||