aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_branch.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-01-08 13:03:56 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-10 22:00:44 -0500
commit034939b65ad5ff64b9709210b3469a95153c51a3 (patch)
tree14fc36bdcabc9c76ac179e4b39b7af11fcbdfb35 /kernel/trace/trace_branch.c
parent67d347245f76a149c45bffb1a10145d31d61d1da (diff)
tracing/ftrace: handle more than one stat file per tracer
Impact: new API for tracers Make the stat tracing API reentrant. And also provide the new directory /debugfs/tracing/trace_stat which will contain all the stat files for the current active tracer. Now a tracer will, if desired, want to provide a zero terminated array of tracer_stat structures. Each one contains the callbacks necessary for one stat file. It have to provide at least a name for its stat file, an iterator with stat_start/start_next callback and an output callback for one stat entry. Also adapt the branch tracer to this new API. We create two files "all" and "annotated" inside the /debugfs/tracing/trace_stat directory, making the both stats simultaneously available instead of needing to change an option to switch from one stat file to another. The output of these stats haven't changed. Changes in v2: _ Apply the previous memory leak fix (rebase against tip/master) Changes in v3: _ Merge the patch that adapted the branch tracer to this Api in this patch to not break the kernel build. 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.c69
1 files changed, 28 insertions, 41 deletions
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index 4785a3b9bc4a..da5cf3e5581b 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -306,19 +306,6 @@ static int annotated_branch_stat_cmp(void *p1, void *p2)
306} 306}
307 307
308#ifdef CONFIG_PROFILE_ALL_BRANCHES 308#ifdef CONFIG_PROFILE_ALL_BRANCHES
309enum {
310 TRACE_BRANCH_OPT_ALL = 0x1
311};
312
313static struct tracer_opt branch_opts[] = {
314 { TRACER_OPT(stat_all_branch, TRACE_BRANCH_OPT_ALL) },
315 { }
316};
317
318static struct tracer_flags branch_flags = {
319 .val = 0,
320 .opts = branch_opts
321};
322 309
323extern unsigned long __start_branch_profile[]; 310extern unsigned long __start_branch_profile[];
324extern unsigned long __stop_branch_profile[]; 311extern unsigned long __stop_branch_profile[];
@@ -352,28 +339,36 @@ all_branch_stat_next(void *v, int idx)
352 return p; 339 return p;
353} 340}
354 341
355static int branch_set_flag(u32 old_flags, u32 bit, int set) 342static struct tracer_stat branch_stats[] = {
356{ 343 {.name = "annotated",
357 if (bit == TRACE_BRANCH_OPT_ALL) { 344 .stat_start = annotated_branch_stat_start,
358 if (set) { 345 .stat_next = annotated_branch_stat_next,
359 branch_trace.stat_headers = all_branch_stat_headers; 346 .stat_cmp = annotated_branch_stat_cmp,
360 branch_trace.stat_start = all_branch_stat_start; 347 .stat_headers = annotated_branch_stat_headers,
361 branch_trace.stat_next = all_branch_stat_next; 348 .stat_show = branch_stat_show},
362 branch_trace.stat_cmp = NULL;
363 } else {
364 branch_trace.stat_headers =
365 annotated_branch_stat_headers;
366 branch_trace.stat_start = annotated_branch_stat_start;
367 branch_trace.stat_next = annotated_branch_stat_next;
368 branch_trace.stat_cmp = annotated_branch_stat_cmp;
369 }
370 init_tracer_stat(&branch_trace);
371 }
372 return 0;
373}
374 349
350 {.name = "all",
351 .stat_start = all_branch_stat_start,
352 .stat_next = all_branch_stat_next,
353 .stat_headers = all_branch_stat_headers,
354 .stat_show = branch_stat_show},
355
356 { }
357};
358#else
359static 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};
375#endif /* CONFIG_PROFILE_ALL_BRANCHES */ 369#endif /* CONFIG_PROFILE_ALL_BRANCHES */
376 370
371
377static struct tracer branch_trace __read_mostly = 372static struct tracer branch_trace __read_mostly =
378{ 373{
379 .name = "branch", 374 .name = "branch",
@@ -383,16 +378,8 @@ static struct tracer branch_trace __read_mostly =
383#ifdef CONFIG_FTRACE_SELFTEST 378#ifdef CONFIG_FTRACE_SELFTEST
384 .selftest = trace_selftest_startup_branch, 379 .selftest = trace_selftest_startup_branch,
385#endif /* CONFIG_FTRACE_SELFTEST */ 380#endif /* CONFIG_FTRACE_SELFTEST */
386#endif /* CONFIG_BRANCH_TRACER */
387 .stat_start = annotated_branch_stat_start,
388 .stat_next = annotated_branch_stat_next,
389 .stat_show = branch_stat_show,
390 .stat_headers = annotated_branch_stat_headers,
391 .stat_cmp = annotated_branch_stat_cmp,
392#ifdef CONFIG_PROFILE_ALL_BRANCHES
393 .flags = &branch_flags,
394 .set_flag = branch_set_flag,
395#endif 381#endif
382 .stats = branch_stats
396}; 383};
397 384
398__init static int init_branch_trace(void) 385__init static int init_branch_trace(void)