aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_selftest.c
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2009-03-13 05:50:27 -0400
committerIngo Molnar <mingo@elte.hu>2009-03-13 06:57:21 -0400
commit321bb5e1ac461c04b6a93f795010d6eb01d8c5ca (patch)
tree409e0c0b867e2cb24abeec4bd8905d9cf1089cb6 /kernel/trace/trace_selftest.c
parentba9372a8f306c4e53a5f61dcbcd6c1e4a8c2e9ac (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/trace_selftest.c')
-rw-r--r--kernel/trace/trace_selftest.c53
1 files changed, 53 insertions, 0 deletions
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
697int
698trace_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 */