diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2009-03-13 05:50:27 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-13 06:57:21 -0400 |
commit | 321bb5e1ac461c04b6a93f795010d6eb01d8c5ca (patch) | |
tree | 409e0c0b867e2cb24abeec4bd8905d9cf1089cb6 /kernel/trace | |
parent | ba9372a8f306c4e53a5f61dcbcd6c1e4a8c2e9ac (diff) |
x86, hw-branch-tracer: add selftest
Add a selftest for the hw-branch-tracer.
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
LKML-Reference: <20090313105027.A30183@sedona.ch.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace.h | 2 | ||||
-rw-r--r-- | kernel/trace/trace_hw_branches.c | 5 | ||||
-rw-r--r-- | kernel/trace/trace_selftest.c | 53 |
3 files changed, 59 insertions, 1 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 56ce34d90b03..e7fbc826f1e9 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -576,6 +576,8 @@ extern int trace_selftest_startup_sysprof(struct tracer *trace, | |||
576 | struct trace_array *tr); | 576 | struct trace_array *tr); |
577 | extern int trace_selftest_startup_branch(struct tracer *trace, | 577 | extern int trace_selftest_startup_branch(struct tracer *trace, |
578 | struct trace_array *tr); | 578 | struct trace_array *tr); |
579 | extern int trace_selftest_startup_hw_branches(struct tracer *trace, | ||
580 | struct trace_array *tr); | ||
579 | #endif /* CONFIG_FTRACE_STARTUP_TEST */ | 581 | #endif /* CONFIG_FTRACE_STARTUP_TEST */ |
580 | 582 | ||
581 | extern void *head_page(struct trace_array_cpu *data); | 583 | extern void *head_page(struct trace_array_cpu *data); |
diff --git a/kernel/trace/trace_hw_branches.c b/kernel/trace/trace_hw_branches.c index a99a04c5e9cd..4ca82700c04e 100644 --- a/kernel/trace/trace_hw_branches.c +++ b/kernel/trace/trace_hw_branches.c | |||
@@ -342,7 +342,10 @@ struct tracer bts_tracer __read_mostly = | |||
342 | .start = bts_trace_start, | 342 | .start = bts_trace_start, |
343 | .stop = bts_trace_stop, | 343 | .stop = bts_trace_stop, |
344 | .open = trace_bts_prepare, | 344 | .open = trace_bts_prepare, |
345 | .close = trace_bts_close | 345 | .close = trace_bts_close, |
346 | #ifdef CONFIG_FTRACE_SELFTEST | ||
347 | .selftest = trace_selftest_startup_hw_branches, | ||
348 | #endif /* CONFIG_FTRACE_SELFTEST */ | ||
346 | }; | 349 | }; |
347 | 350 | ||
348 | __init static int init_bts_trace(void) | 351 | __init static int init_bts_trace(void) |
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c index f907a2b29028..3c7b797d0d28 100644 --- a/kernel/trace/trace_selftest.c +++ b/kernel/trace/trace_selftest.c | |||
@@ -16,6 +16,7 @@ static inline int trace_valid_entry(struct trace_entry *entry) | |||
16 | case TRACE_BRANCH: | 16 | case TRACE_BRANCH: |
17 | case TRACE_GRAPH_ENT: | 17 | case TRACE_GRAPH_ENT: |
18 | case TRACE_GRAPH_RET: | 18 | case TRACE_GRAPH_RET: |
19 | case TRACE_HW_BRANCHES: | ||
19 | return 1; | 20 | return 1; |
20 | } | 21 | } |
21 | return 0; | 22 | return 0; |
@@ -691,3 +692,55 @@ trace_selftest_startup_branch(struct tracer *trace, struct trace_array *tr) | |||
691 | return ret; | 692 | return ret; |
692 | } | 693 | } |
693 | #endif /* CONFIG_BRANCH_TRACER */ | 694 | #endif /* CONFIG_BRANCH_TRACER */ |
695 | |||
696 | #ifdef CONFIG_HW_BRANCH_TRACER | ||
697 | int | ||
698 | trace_selftest_startup_hw_branches(struct tracer *trace, | ||
699 | struct trace_array *tr) | ||
700 | { | ||
701 | unsigned long count; | ||
702 | int ret; | ||
703 | struct trace_iterator iter; | ||
704 | struct tracer tracer; | ||
705 | |||
706 | if (!trace->open) { | ||
707 | printk(KERN_CONT "missing open function..."); | ||
708 | return -1; | ||
709 | } | ||
710 | |||
711 | ret = tracer_init(trace, tr); | ||
712 | if (ret) { | ||
713 | warn_failed_init_tracer(trace, ret); | ||
714 | return ret; | ||
715 | } | ||
716 | |||
717 | /* | ||
718 | * The hw-branch tracer needs to collect the trace from the various | ||
719 | * cpu trace buffers - before tracing is stopped. | ||
720 | */ | ||
721 | memset(&iter, 0, sizeof(iter)); | ||
722 | memcpy(&tracer, trace, sizeof(tracer)); | ||
723 | |||
724 | iter.trace = &tracer; | ||
725 | iter.tr = tr; | ||
726 | iter.pos = -1; | ||
727 | mutex_init(&iter.mutex); | ||
728 | |||
729 | trace->open(&iter); | ||
730 | |||
731 | mutex_destroy(&iter.mutex); | ||
732 | |||
733 | tracing_stop(); | ||
734 | |||
735 | ret = trace_test_buffer(tr, &count); | ||
736 | trace->reset(tr); | ||
737 | tracing_start(); | ||
738 | |||
739 | if (!ret && !count) { | ||
740 | printk(KERN_CONT "no entries found.."); | ||
741 | ret = -1; | ||
742 | } | ||
743 | |||
744 | return ret; | ||
745 | } | ||
746 | #endif /* CONFIG_HW_BRANCH_TRACER */ | ||