diff options
author | K.Prasad <prasad@linux.vnet.ibm.com> | 2009-06-01 14:16:40 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2009-06-02 16:47:00 -0400 |
commit | 0722db015c246204044299eae3b02d18d3ca4faf (patch) | |
tree | cc9a6b21961d62e1788ee2b9cbd0ae23b43f11a0 /kernel/trace/trace_selftest.c | |
parent | 432039933a16b8227b7b267f46ac1c1b9b3adf14 (diff) |
hw-breakpoints: ftrace plugin for kernel symbol tracing using HW Breakpoint interfaces
This patch adds an ftrace plugin to detect and profile memory access over kernel
variables. It uses HW Breakpoint interfaces to 'watch memory addresses.
Signed-off-by: K.Prasad <prasad@linux.vnet.ibm.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'kernel/trace/trace_selftest.c')
-rw-r--r-- | kernel/trace/trace_selftest.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c index 00dd6485bdd7..71f2edb0fd84 100644 --- a/kernel/trace/trace_selftest.c +++ b/kernel/trace/trace_selftest.c | |||
@@ -17,6 +17,7 @@ static inline int trace_valid_entry(struct trace_entry *entry) | |||
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 | case TRACE_HW_BRANCHES: |
20 | case TRACE_KSYM: | ||
20 | return 1; | 21 | return 1; |
21 | } | 22 | } |
22 | return 0; | 23 | return 0; |
@@ -807,3 +808,55 @@ trace_selftest_startup_hw_branches(struct tracer *trace, | |||
807 | return ret; | 808 | return ret; |
808 | } | 809 | } |
809 | #endif /* CONFIG_HW_BRANCH_TRACER */ | 810 | #endif /* CONFIG_HW_BRANCH_TRACER */ |
811 | |||
812 | #ifdef CONFIG_KSYM_TRACER | ||
813 | static int ksym_selftest_dummy; | ||
814 | |||
815 | int | ||
816 | trace_selftest_startup_ksym(struct tracer *trace, struct trace_array *tr) | ||
817 | { | ||
818 | unsigned long count; | ||
819 | int ret; | ||
820 | |||
821 | /* start the tracing */ | ||
822 | ret = tracer_init(trace, tr); | ||
823 | if (ret) { | ||
824 | warn_failed_init_tracer(trace, ret); | ||
825 | return ret; | ||
826 | } | ||
827 | |||
828 | ksym_selftest_dummy = 0; | ||
829 | /* Register the read-write tracing request */ | ||
830 | ret = process_new_ksym_entry(KSYM_SELFTEST_ENTRY, HW_BREAKPOINT_RW, | ||
831 | (unsigned long)(&ksym_selftest_dummy)); | ||
832 | |||
833 | if (ret < 0) { | ||
834 | printk(KERN_CONT "ksym_trace read-write startup test failed\n"); | ||
835 | goto ret_path; | ||
836 | } | ||
837 | /* Perform a read and a write operation over the dummy variable to | ||
838 | * trigger the tracer | ||
839 | */ | ||
840 | if (ksym_selftest_dummy == 0) | ||
841 | ksym_selftest_dummy++; | ||
842 | |||
843 | /* stop the tracing. */ | ||
844 | tracing_stop(); | ||
845 | /* check the trace buffer */ | ||
846 | ret = trace_test_buffer(tr, &count); | ||
847 | trace->reset(tr); | ||
848 | tracing_start(); | ||
849 | |||
850 | /* read & write operations - one each is performed on the dummy variable | ||
851 | * triggering two entries in the trace buffer | ||
852 | */ | ||
853 | if (!ret && count != 2) { | ||
854 | printk(KERN_CONT "Ksym tracer startup test failed"); | ||
855 | ret = -1; | ||
856 | } | ||
857 | |||
858 | ret_path: | ||
859 | return ret; | ||
860 | } | ||
861 | #endif /* CONFIG_KSYM_TRACER */ | ||
862 | |||