aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_selftest.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace_selftest.c')
-rw-r--r--kernel/trace/trace_selftest.c60
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
7static inline int trace_valid_entry(struct trace_entry *entry) 8static 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
815static int ksym_selftest_dummy;
816
817int
818trace_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
862ret_path:
863 return ret;
864}
865#endif /* CONFIG_KSYM_TRACER */
866