diff options
-rw-r--r-- | kernel/trace/trace_functions.c | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index 2dce3c7370d1..61d0b73dabf5 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c | |||
@@ -133,6 +133,7 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip) | |||
133 | 133 | ||
134 | if (likely(disabled == 1)) { | 134 | if (likely(disabled == 1)) { |
135 | pc = preempt_count(); | 135 | pc = preempt_count(); |
136 | trace_function(tr, data, ip, parent_ip, flags, pc); | ||
136 | /* | 137 | /* |
137 | * skip over 5 funcs: | 138 | * skip over 5 funcs: |
138 | * __ftrace_trace_stack, | 139 | * __ftrace_trace_stack, |
@@ -154,24 +155,6 @@ static struct ftrace_ops trace_ops __read_mostly = | |||
154 | .func = function_trace_call, | 155 | .func = function_trace_call, |
155 | }; | 156 | }; |
156 | 157 | ||
157 | void tracing_start_function_trace(void) | ||
158 | { | ||
159 | ftrace_function_enabled = 0; | ||
160 | |||
161 | if (trace_flags & TRACE_ITER_PREEMPTONLY) | ||
162 | trace_ops.func = function_trace_call_preempt_only; | ||
163 | else | ||
164 | trace_ops.func = function_trace_call; | ||
165 | |||
166 | register_ftrace_function(&trace_ops); | ||
167 | ftrace_function_enabled = 1; | ||
168 | } | ||
169 | |||
170 | void tracing_stop_function_trace(void) | ||
171 | { | ||
172 | ftrace_function_enabled = 0; | ||
173 | unregister_ftrace_function(&trace_ops); | ||
174 | } | ||
175 | static struct ftrace_ops trace_stack_ops __read_mostly = | 158 | static struct ftrace_ops trace_stack_ops __read_mostly = |
176 | { | 159 | { |
177 | .func = function_stack_trace_call, | 160 | .func = function_stack_trace_call, |
@@ -194,6 +177,31 @@ static struct tracer_flags func_flags = { | |||
194 | .opts = func_opts | 177 | .opts = func_opts |
195 | }; | 178 | }; |
196 | 179 | ||
180 | void tracing_start_function_trace(void) | ||
181 | { | ||
182 | ftrace_function_enabled = 0; | ||
183 | |||
184 | if (trace_flags & TRACE_ITER_PREEMPTONLY) | ||
185 | trace_ops.func = function_trace_call_preempt_only; | ||
186 | else | ||
187 | trace_ops.func = function_trace_call; | ||
188 | |||
189 | if (func_flags.val & TRACE_FUNC_OPT_STACK) | ||
190 | register_ftrace_function(&trace_stack_ops); | ||
191 | else | ||
192 | register_ftrace_function(&trace_ops); | ||
193 | |||
194 | ftrace_function_enabled = 1; | ||
195 | } | ||
196 | |||
197 | void tracing_stop_function_trace(void) | ||
198 | { | ||
199 | ftrace_function_enabled = 0; | ||
200 | /* OK if they are not registered */ | ||
201 | unregister_ftrace_function(&trace_stack_ops); | ||
202 | unregister_ftrace_function(&trace_ops); | ||
203 | } | ||
204 | |||
197 | static int func_set_flag(u32 old_flags, u32 bit, int set) | 205 | static int func_set_flag(u32 old_flags, u32 bit, int set) |
198 | { | 206 | { |
199 | if (bit == TRACE_FUNC_OPT_STACK) { | 207 | if (bit == TRACE_FUNC_OPT_STACK) { |
@@ -201,10 +209,13 @@ static int func_set_flag(u32 old_flags, u32 bit, int set) | |||
201 | if (!!set == !!(func_flags.val & TRACE_FUNC_OPT_STACK)) | 209 | if (!!set == !!(func_flags.val & TRACE_FUNC_OPT_STACK)) |
202 | return 0; | 210 | return 0; |
203 | 211 | ||
204 | if (set) | 212 | if (set) { |
213 | unregister_ftrace_function(&trace_ops); | ||
205 | register_ftrace_function(&trace_stack_ops); | 214 | register_ftrace_function(&trace_stack_ops); |
206 | else | 215 | } else { |
207 | unregister_ftrace_function(&trace_stack_ops); | 216 | unregister_ftrace_function(&trace_stack_ops); |
217 | register_ftrace_function(&trace_ops); | ||
218 | } | ||
208 | 219 | ||
209 | return 0; | 220 | return 0; |
210 | } | 221 | } |
@@ -214,14 +225,14 @@ static int func_set_flag(u32 old_flags, u32 bit, int set) | |||
214 | 225 | ||
215 | static struct tracer function_trace __read_mostly = | 226 | static struct tracer function_trace __read_mostly = |
216 | { | 227 | { |
217 | .name = "function", | 228 | .name = "function", |
218 | .init = function_trace_init, | 229 | .init = function_trace_init, |
219 | .reset = function_trace_reset, | 230 | .reset = function_trace_reset, |
220 | .start = function_trace_start, | 231 | .start = function_trace_start, |
221 | .flags = &func_flags, | 232 | .flags = &func_flags, |
222 | .set_flag = func_set_flag, | 233 | .set_flag = func_set_flag, |
223 | #ifdef CONFIG_FTRACE_SELFTEST | 234 | #ifdef CONFIG_FTRACE_SELFTEST |
224 | .selftest = trace_selftest_startup_function, | 235 | .selftest = trace_selftest_startup_function, |
225 | #endif | 236 | #endif |
226 | }; | 237 | }; |
227 | 238 | ||