diff options
Diffstat (limited to 'kernel/trace/trace_functions.c')
| -rw-r--r-- | kernel/trace/trace_functions.c | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index ffd56351b521..57f0ec962d2c 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c | |||
| @@ -26,8 +26,6 @@ function_trace_call(unsigned long ip, unsigned long parent_ip, | |||
| 26 | static void | 26 | static void |
| 27 | function_stack_trace_call(unsigned long ip, unsigned long parent_ip, | 27 | function_stack_trace_call(unsigned long ip, unsigned long parent_ip, |
| 28 | struct ftrace_ops *op, struct pt_regs *pt_regs); | 28 | struct ftrace_ops *op, struct pt_regs *pt_regs); |
| 29 | static struct ftrace_ops trace_ops; | ||
| 30 | static struct ftrace_ops trace_stack_ops; | ||
| 31 | static struct tracer_flags func_flags; | 29 | static struct tracer_flags func_flags; |
| 32 | 30 | ||
| 33 | /* Our option */ | 31 | /* Our option */ |
| @@ -83,28 +81,24 @@ void ftrace_destroy_function_files(struct trace_array *tr) | |||
| 83 | 81 | ||
| 84 | static int function_trace_init(struct trace_array *tr) | 82 | static int function_trace_init(struct trace_array *tr) |
| 85 | { | 83 | { |
| 86 | struct ftrace_ops *ops; | 84 | ftrace_func_t func; |
| 87 | |||
| 88 | if (tr->flags & TRACE_ARRAY_FL_GLOBAL) { | ||
| 89 | /* There's only one global tr */ | ||
| 90 | if (!trace_ops.private) { | ||
| 91 | trace_ops.private = tr; | ||
| 92 | trace_stack_ops.private = tr; | ||
| 93 | } | ||
| 94 | 85 | ||
| 95 | if (func_flags.val & TRACE_FUNC_OPT_STACK) | 86 | /* |
| 96 | ops = &trace_stack_ops; | 87 | * Instance trace_arrays get their ops allocated |
| 97 | else | 88 | * at instance creation. Unless it failed |
| 98 | ops = &trace_ops; | 89 | * the allocation. |
| 99 | tr->ops = ops; | 90 | */ |
| 100 | } else if (!tr->ops) { | 91 | if (!tr->ops) |
| 101 | /* | ||
| 102 | * Instance trace_arrays get their ops allocated | ||
| 103 | * at instance creation. Unless it failed | ||
| 104 | * the allocation. | ||
| 105 | */ | ||
| 106 | return -ENOMEM; | 92 | return -ENOMEM; |
| 107 | } | 93 | |
| 94 | /* Currently only the global instance can do stack tracing */ | ||
| 95 | if (tr->flags & TRACE_ARRAY_FL_GLOBAL && | ||
| 96 | func_flags.val & TRACE_FUNC_OPT_STACK) | ||
| 97 | func = function_stack_trace_call; | ||
| 98 | else | ||
| 99 | func = function_trace_call; | ||
| 100 | |||
| 101 | ftrace_init_array_ops(tr, func); | ||
| 108 | 102 | ||
| 109 | tr->trace_buffer.cpu = get_cpu(); | 103 | tr->trace_buffer.cpu = get_cpu(); |
| 110 | put_cpu(); | 104 | put_cpu(); |
| @@ -118,6 +112,7 @@ static void function_trace_reset(struct trace_array *tr) | |||
| 118 | { | 112 | { |
| 119 | tracing_stop_function_trace(tr); | 113 | tracing_stop_function_trace(tr); |
| 120 | tracing_stop_cmdline_record(); | 114 | tracing_stop_cmdline_record(); |
| 115 | ftrace_reset_array_ops(tr); | ||
| 121 | } | 116 | } |
| 122 | 117 | ||
| 123 | static void function_trace_start(struct trace_array *tr) | 118 | static void function_trace_start(struct trace_array *tr) |
| @@ -199,18 +194,6 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip, | |||
| 199 | local_irq_restore(flags); | 194 | local_irq_restore(flags); |
| 200 | } | 195 | } |
| 201 | 196 | ||
| 202 | static struct ftrace_ops trace_ops __read_mostly = | ||
| 203 | { | ||
| 204 | .func = function_trace_call, | ||
| 205 | .flags = FTRACE_OPS_FL_GLOBAL | FTRACE_OPS_FL_RECURSION_SAFE, | ||
| 206 | }; | ||
| 207 | |||
| 208 | static struct ftrace_ops trace_stack_ops __read_mostly = | ||
| 209 | { | ||
| 210 | .func = function_stack_trace_call, | ||
| 211 | .flags = FTRACE_OPS_FL_GLOBAL | FTRACE_OPS_FL_RECURSION_SAFE, | ||
| 212 | }; | ||
| 213 | |||
| 214 | static struct tracer_opt func_opts[] = { | 197 | static struct tracer_opt func_opts[] = { |
| 215 | #ifdef CONFIG_STACKTRACE | 198 | #ifdef CONFIG_STACKTRACE |
| 216 | { TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) }, | 199 | { TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) }, |
| @@ -248,10 +231,10 @@ func_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set) | |||
| 248 | unregister_ftrace_function(tr->ops); | 231 | unregister_ftrace_function(tr->ops); |
| 249 | 232 | ||
| 250 | if (set) { | 233 | if (set) { |
| 251 | tr->ops = &trace_stack_ops; | 234 | tr->ops->func = function_stack_trace_call; |
| 252 | register_ftrace_function(tr->ops); | 235 | register_ftrace_function(tr->ops); |
| 253 | } else { | 236 | } else { |
| 254 | tr->ops = &trace_ops; | 237 | tr->ops->func = function_trace_call; |
| 255 | register_ftrace_function(tr->ops); | 238 | register_ftrace_function(tr->ops); |
| 256 | } | 239 | } |
| 257 | 240 | ||
| @@ -269,7 +252,6 @@ static struct tracer function_trace __tracer_data = | |||
| 269 | .init = function_trace_init, | 252 | .init = function_trace_init, |
| 270 | .reset = function_trace_reset, | 253 | .reset = function_trace_reset, |
| 271 | .start = function_trace_start, | 254 | .start = function_trace_start, |
| 272 | .wait_pipe = poll_wait_pipe, | ||
| 273 | .flags = &func_flags, | 255 | .flags = &func_flags, |
| 274 | .set_flag = func_set_flag, | 256 | .set_flag = func_set_flag, |
| 275 | .allow_instances = true, | 257 | .allow_instances = true, |
