diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /kernel/trace/trace_selftest.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'kernel/trace/trace_selftest.c')
-rw-r--r-- | kernel/trace/trace_selftest.c | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c index d2cdbabb4ead..81003b4d617f 100644 --- a/kernel/trace/trace_selftest.c +++ b/kernel/trace/trace_selftest.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <linux/stringify.h> | 3 | #include <linux/stringify.h> |
4 | #include <linux/kthread.h> | 4 | #include <linux/kthread.h> |
5 | #include <linux/delay.h> | 5 | #include <linux/delay.h> |
6 | #include <linux/slab.h> | ||
6 | 7 | ||
7 | static inline int trace_valid_entry(struct trace_entry *entry) | 8 | static inline int trace_valid_entry(struct trace_entry *entry) |
8 | { | 9 | { |
@@ -17,6 +18,7 @@ static inline int trace_valid_entry(struct trace_entry *entry) | |||
17 | case TRACE_GRAPH_ENT: | 18 | case TRACE_GRAPH_ENT: |
18 | case TRACE_GRAPH_RET: | 19 | case TRACE_GRAPH_RET: |
19 | case TRACE_HW_BRANCHES: | 20 | case TRACE_HW_BRANCHES: |
21 | case TRACE_KSYM: | ||
20 | return 1; | 22 | return 1; |
21 | } | 23 | } |
22 | return 0; | 24 | return 0; |
@@ -66,7 +68,7 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count) | |||
66 | 68 | ||
67 | /* Don't allow flipping of max traces now */ | 69 | /* Don't allow flipping of max traces now */ |
68 | local_irq_save(flags); | 70 | local_irq_save(flags); |
69 | __raw_spin_lock(&ftrace_max_lock); | 71 | arch_spin_lock(&ftrace_max_lock); |
70 | 72 | ||
71 | cnt = ring_buffer_entries(tr->buffer); | 73 | cnt = ring_buffer_entries(tr->buffer); |
72 | 74 | ||
@@ -84,7 +86,7 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count) | |||
84 | break; | 86 | break; |
85 | } | 87 | } |
86 | tracing_on(); | 88 | tracing_on(); |
87 | __raw_spin_unlock(&ftrace_max_lock); | 89 | arch_spin_unlock(&ftrace_max_lock); |
88 | local_irq_restore(flags); | 90 | local_irq_restore(flags); |
89 | 91 | ||
90 | if (count) | 92 | if (count) |
@@ -808,3 +810,57 @@ trace_selftest_startup_hw_branches(struct tracer *trace, | |||
808 | return ret; | 810 | return ret; |
809 | } | 811 | } |
810 | #endif /* CONFIG_HW_BRANCH_TRACER */ | 812 | #endif /* CONFIG_HW_BRANCH_TRACER */ |
813 | |||
814 | #ifdef CONFIG_KSYM_TRACER | ||
815 | static int ksym_selftest_dummy; | ||
816 | |||
817 | int | ||
818 | trace_selftest_startup_ksym(struct tracer *trace, struct trace_array *tr) | ||
819 | { | ||
820 | unsigned long count; | ||
821 | int ret; | ||
822 | |||
823 | /* start the tracing */ | ||
824 | ret = tracer_init(trace, tr); | ||
825 | if (ret) { | ||
826 | warn_failed_init_tracer(trace, ret); | ||
827 | return ret; | ||
828 | } | ||
829 | |||
830 | ksym_selftest_dummy = 0; | ||
831 | /* Register the read-write tracing request */ | ||
832 | |||
833 | ret = process_new_ksym_entry("ksym_selftest_dummy", | ||
834 | HW_BREAKPOINT_R | HW_BREAKPOINT_W, | ||
835 | (unsigned long)(&ksym_selftest_dummy)); | ||
836 | |||
837 | if (ret < 0) { | ||
838 | printk(KERN_CONT "ksym_trace read-write startup test failed\n"); | ||
839 | goto ret_path; | ||
840 | } | ||
841 | /* Perform a read and a write operation over the dummy variable to | ||
842 | * trigger the tracer | ||
843 | */ | ||
844 | if (ksym_selftest_dummy == 0) | ||
845 | ksym_selftest_dummy++; | ||
846 | |||
847 | /* stop the tracing. */ | ||
848 | tracing_stop(); | ||
849 | /* check the trace buffer */ | ||
850 | ret = trace_test_buffer(tr, &count); | ||
851 | trace->reset(tr); | ||
852 | tracing_start(); | ||
853 | |||
854 | /* read & write operations - one each is performed on the dummy variable | ||
855 | * triggering two entries in the trace buffer | ||
856 | */ | ||
857 | if (!ret && count != 2) { | ||
858 | printk(KERN_CONT "Ksym tracer startup test failed"); | ||
859 | ret = -1; | ||
860 | } | ||
861 | |||
862 | ret_path: | ||
863 | return ret; | ||
864 | } | ||
865 | #endif /* CONFIG_KSYM_TRACER */ | ||
866 | |||