diff options
author | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-07-09 20:10:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-07-17 13:07:00 -0400 |
commit | 21f679404a0c28bd5b1b3aff2a7218bbff4cb43d (patch) | |
tree | 9a5f1d0be079dfe225e2993331f9ddfac36cb7fc /kernel | |
parent | 060287b8c467bf49a594d8d669e1986c6d8d76b0 (diff) |
tracing/function: Introduce persistent trace option
This patch introduces 'func_ptrace' option, now available in
/sys/kernel/debug/tracing/options when function tracer
is selected.
The patch also adds some tiny code that calls back to pstore
to record the trace. The callback is no-op when PSTORE=n.
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_functions.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index c7b0c6a7db09..13770abd7a12 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/debugfs.h> | 13 | #include <linux/debugfs.h> |
14 | #include <linux/uaccess.h> | 14 | #include <linux/uaccess.h> |
15 | #include <linux/ftrace.h> | 15 | #include <linux/ftrace.h> |
16 | #include <linux/pstore.h> | ||
16 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
17 | 18 | ||
18 | #include "trace.h" | 19 | #include "trace.h" |
@@ -74,6 +75,14 @@ function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip) | |||
74 | preempt_enable_notrace(); | 75 | preempt_enable_notrace(); |
75 | } | 76 | } |
76 | 77 | ||
78 | /* Our two options */ | ||
79 | enum { | ||
80 | TRACE_FUNC_OPT_STACK = 0x1, | ||
81 | TRACE_FUNC_OPT_PSTORE = 0x2, | ||
82 | }; | ||
83 | |||
84 | static struct tracer_flags func_flags; | ||
85 | |||
77 | static void | 86 | static void |
78 | function_trace_call(unsigned long ip, unsigned long parent_ip) | 87 | function_trace_call(unsigned long ip, unsigned long parent_ip) |
79 | { | 88 | { |
@@ -97,6 +106,12 @@ function_trace_call(unsigned long ip, unsigned long parent_ip) | |||
97 | disabled = atomic_inc_return(&data->disabled); | 106 | disabled = atomic_inc_return(&data->disabled); |
98 | 107 | ||
99 | if (likely(disabled == 1)) { | 108 | if (likely(disabled == 1)) { |
109 | /* | ||
110 | * So far tracing doesn't support multiple buffers, so | ||
111 | * we make an explicit call for now. | ||
112 | */ | ||
113 | if (unlikely(func_flags.val & TRACE_FUNC_OPT_PSTORE)) | ||
114 | pstore_ftrace_call(ip, parent_ip); | ||
100 | pc = preempt_count(); | 115 | pc = preempt_count(); |
101 | trace_function(tr, ip, parent_ip, flags, pc); | 116 | trace_function(tr, ip, parent_ip, flags, pc); |
102 | } | 117 | } |
@@ -158,15 +173,13 @@ static struct ftrace_ops trace_stack_ops __read_mostly = | |||
158 | .flags = FTRACE_OPS_FL_GLOBAL, | 173 | .flags = FTRACE_OPS_FL_GLOBAL, |
159 | }; | 174 | }; |
160 | 175 | ||
161 | /* Our two options */ | ||
162 | enum { | ||
163 | TRACE_FUNC_OPT_STACK = 0x1, | ||
164 | }; | ||
165 | |||
166 | static struct tracer_opt func_opts[] = { | 176 | static struct tracer_opt func_opts[] = { |
167 | #ifdef CONFIG_STACKTRACE | 177 | #ifdef CONFIG_STACKTRACE |
168 | { TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) }, | 178 | { TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) }, |
169 | #endif | 179 | #endif |
180 | #ifdef CONFIG_PSTORE_FTRACE | ||
181 | { TRACER_OPT(func_pstore, TRACE_FUNC_OPT_PSTORE) }, | ||
182 | #endif | ||
170 | { } /* Always set a last empty entry */ | 183 | { } /* Always set a last empty entry */ |
171 | }; | 184 | }; |
172 | 185 | ||
@@ -218,6 +231,8 @@ static int func_set_flag(u32 old_flags, u32 bit, int set) | |||
218 | } | 231 | } |
219 | 232 | ||
220 | return 0; | 233 | return 0; |
234 | } else if (bit == TRACE_FUNC_OPT_PSTORE) { | ||
235 | return 0; | ||
221 | } | 236 | } |
222 | 237 | ||
223 | return -EINVAL; | 238 | return -EINVAL; |