.. | .. |
---|
34 | 34 | TRACE_FUNC_OPT_STACK = 0x1, |
---|
35 | 35 | }; |
---|
36 | 36 | |
---|
37 | | -static int allocate_ftrace_ops(struct trace_array *tr) |
---|
| 37 | +int ftrace_allocate_ftrace_ops(struct trace_array *tr) |
---|
38 | 38 | { |
---|
39 | 39 | struct ftrace_ops *ops; |
---|
| 40 | + |
---|
| 41 | + /* The top level array uses the "global_ops" */ |
---|
| 42 | + if (tr->flags & TRACE_ARRAY_FL_GLOBAL) |
---|
| 43 | + return 0; |
---|
40 | 44 | |
---|
41 | 45 | ops = kzalloc(sizeof(*ops), GFP_KERNEL); |
---|
42 | 46 | if (!ops) |
---|
43 | 47 | return -ENOMEM; |
---|
44 | 48 | |
---|
45 | | - /* Currently only the non stack verision is supported */ |
---|
| 49 | + /* Currently only the non stack version is supported */ |
---|
46 | 50 | ops->func = function_trace_call; |
---|
47 | 51 | ops->flags = FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_PID; |
---|
48 | 52 | |
---|
49 | 53 | tr->ops = ops; |
---|
50 | 54 | ops->private = tr; |
---|
| 55 | + |
---|
51 | 56 | return 0; |
---|
52 | 57 | } |
---|
53 | 58 | |
---|
| 59 | +void ftrace_free_ftrace_ops(struct trace_array *tr) |
---|
| 60 | +{ |
---|
| 61 | + kfree(tr->ops); |
---|
| 62 | + tr->ops = NULL; |
---|
| 63 | +} |
---|
54 | 64 | |
---|
55 | 65 | int ftrace_create_function_files(struct trace_array *tr, |
---|
56 | 66 | struct dentry *parent) |
---|
57 | 67 | { |
---|
58 | | - int ret; |
---|
59 | | - |
---|
60 | 68 | /* |
---|
61 | 69 | * The top level array uses the "global_ops", and the files are |
---|
62 | 70 | * created on boot up. |
---|
.. | .. |
---|
64 | 72 | if (tr->flags & TRACE_ARRAY_FL_GLOBAL) |
---|
65 | 73 | return 0; |
---|
66 | 74 | |
---|
67 | | - ret = allocate_ftrace_ops(tr); |
---|
68 | | - if (ret) |
---|
69 | | - return ret; |
---|
| 75 | + if (!tr->ops) |
---|
| 76 | + return -EINVAL; |
---|
70 | 77 | |
---|
71 | 78 | ftrace_create_filter_files(tr->ops, parent); |
---|
72 | 79 | |
---|
.. | .. |
---|
76 | 83 | void ftrace_destroy_function_files(struct trace_array *tr) |
---|
77 | 84 | { |
---|
78 | 85 | ftrace_destroy_filter_files(tr->ops); |
---|
79 | | - kfree(tr->ops); |
---|
80 | | - tr->ops = NULL; |
---|
| 86 | + ftrace_free_ftrace_ops(tr); |
---|
81 | 87 | } |
---|
82 | 88 | |
---|
83 | 89 | static int function_trace_init(struct trace_array *tr) |
---|
.. | .. |
---|
101 | 107 | |
---|
102 | 108 | ftrace_init_array_ops(tr, func); |
---|
103 | 109 | |
---|
104 | | - tr->trace_buffer.cpu = get_cpu(); |
---|
| 110 | + tr->array_buffer.cpu = get_cpu(); |
---|
105 | 111 | put_cpu(); |
---|
106 | 112 | |
---|
107 | 113 | tracing_start_cmdline_record(); |
---|
.. | .. |
---|
118 | 124 | |
---|
119 | 125 | static void function_trace_start(struct trace_array *tr) |
---|
120 | 126 | { |
---|
121 | | - tracing_reset_online_cpus(&tr->trace_buffer); |
---|
| 127 | + tracing_reset_online_cpus(&tr->array_buffer); |
---|
122 | 128 | } |
---|
123 | 129 | |
---|
124 | 130 | static void |
---|
.. | .. |
---|
143 | 149 | goto out; |
---|
144 | 150 | |
---|
145 | 151 | cpu = smp_processor_id(); |
---|
146 | | - data = per_cpu_ptr(tr->trace_buffer.data, cpu); |
---|
| 152 | + data = per_cpu_ptr(tr->array_buffer.data, cpu); |
---|
147 | 153 | if (!atomic_read(&data->disabled)) { |
---|
148 | 154 | local_save_flags(flags); |
---|
149 | 155 | trace_function(tr, ip, parent_ip, flags, pc); |
---|
.. | .. |
---|
192 | 198 | */ |
---|
193 | 199 | local_irq_save(flags); |
---|
194 | 200 | cpu = raw_smp_processor_id(); |
---|
195 | | - data = per_cpu_ptr(tr->trace_buffer.data, cpu); |
---|
| 201 | + data = per_cpu_ptr(tr->array_buffer.data, cpu); |
---|
196 | 202 | disabled = atomic_inc_return(&data->disabled); |
---|
197 | 203 | |
---|
198 | 204 | if (likely(disabled == 1)) { |
---|