Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * ring buffer based function tracer |
| 3 | * |
| 4 | * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> |
| 5 | * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com> |
| 6 | * |
| 7 | * Based on code from the latency_tracer, that is: |
| 8 | * |
| 9 | * Copyright (C) 2004-2006 Ingo Molnar |
| 10 | * Copyright (C) 2004 William Lee Irwin III |
| 11 | */ |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 12 | #include <linux/ring_buffer.h> |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 13 | #include <linux/debugfs.h> |
| 14 | #include <linux/uaccess.h> |
| 15 | #include <linux/ftrace.h> |
Ingo Molnar | 2e0f576 | 2008-05-12 21:20:49 +0200 | [diff] [blame] | 16 | #include <linux/fs.h> |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 17 | |
| 18 | #include "trace.h" |
| 19 | |
Steven Rostedt | a225cdd | 2009-01-15 23:06:03 -0500 | [diff] [blame] | 20 | /* function tracing enabled */ |
| 21 | static int ftrace_function_enabled; |
| 22 | |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 23 | static struct trace_array *func_trace; |
| 24 | |
Steven Rostedt | a225cdd | 2009-01-15 23:06:03 -0500 | [diff] [blame] | 25 | static void tracing_start_function_trace(void); |
| 26 | static void tracing_stop_function_trace(void); |
| 27 | |
Arnaldo Carvalho de Melo | b6f11df | 2009-02-05 18:02:00 -0200 | [diff] [blame] | 28 | static int function_trace_init(struct trace_array *tr) |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 29 | { |
Steven Rostedt | bb3c3c9 | 2009-01-15 20:40:23 -0500 | [diff] [blame] | 30 | func_trace = tr; |
Steven Rostedt | 26bc83f | 2008-07-10 20:58:14 -0400 | [diff] [blame] | 31 | tr->cpu = get_cpu(); |
Steven Rostedt | 26bc83f | 2008-07-10 20:58:14 -0400 | [diff] [blame] | 32 | put_cpu(); |
| 33 | |
Steven Rostedt | 41bc814 | 2008-05-22 11:49:22 -0400 | [diff] [blame] | 34 | tracing_start_cmdline_record(); |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 35 | tracing_start_function_trace(); |
Frederic Weisbecker | 1c80025 | 2008-11-16 05:57:26 +0100 | [diff] [blame] | 36 | return 0; |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 37 | } |
| 38 | |
Ingo Molnar | e309b41 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 39 | static void function_trace_reset(struct trace_array *tr) |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 40 | { |
Arnaldo Carvalho de Melo | b6f11df | 2009-02-05 18:02:00 -0200 | [diff] [blame] | 41 | tracing_stop_function_trace(); |
| 42 | tracing_stop_cmdline_record(); |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 43 | } |
| 44 | |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 45 | static void function_trace_start(struct trace_array *tr) |
| 46 | { |
Pekka J Enberg | 213cc06 | 2008-12-19 12:08:39 +0200 | [diff] [blame] | 47 | tracing_reset_online_cpus(tr); |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 48 | } |
| 49 | |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 50 | static void |
Steven Rostedt | bb3c3c9 | 2009-01-15 20:40:23 -0500 | [diff] [blame] | 51 | function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip) |
| 52 | { |
| 53 | struct trace_array *tr = func_trace; |
| 54 | struct trace_array_cpu *data; |
| 55 | unsigned long flags; |
| 56 | long disabled; |
| 57 | int cpu, resched; |
| 58 | int pc; |
| 59 | |
| 60 | if (unlikely(!ftrace_function_enabled)) |
| 61 | return; |
| 62 | |
| 63 | pc = preempt_count(); |
| 64 | resched = ftrace_preempt_disable(); |
| 65 | local_save_flags(flags); |
| 66 | cpu = raw_smp_processor_id(); |
| 67 | data = tr->data[cpu]; |
| 68 | disabled = atomic_inc_return(&data->disabled); |
| 69 | |
| 70 | if (likely(disabled == 1)) |
Arnaldo Carvalho de Melo | 7be4215 | 2009-02-05 01:13:37 -0500 | [diff] [blame] | 71 | trace_function(tr, ip, parent_ip, flags, pc); |
Steven Rostedt | bb3c3c9 | 2009-01-15 20:40:23 -0500 | [diff] [blame] | 72 | |
| 73 | atomic_dec(&data->disabled); |
| 74 | ftrace_preempt_enable(resched); |
| 75 | } |
| 76 | |
| 77 | static void |
| 78 | function_trace_call(unsigned long ip, unsigned long parent_ip) |
| 79 | { |
| 80 | struct trace_array *tr = func_trace; |
| 81 | struct trace_array_cpu *data; |
| 82 | unsigned long flags; |
| 83 | long disabled; |
| 84 | int cpu; |
| 85 | int pc; |
| 86 | |
| 87 | if (unlikely(!ftrace_function_enabled)) |
| 88 | return; |
| 89 | |
| 90 | /* |
| 91 | * Need to use raw, since this must be called before the |
| 92 | * recursive protection is performed. |
| 93 | */ |
| 94 | local_irq_save(flags); |
| 95 | cpu = raw_smp_processor_id(); |
| 96 | data = tr->data[cpu]; |
| 97 | disabled = atomic_inc_return(&data->disabled); |
| 98 | |
| 99 | if (likely(disabled == 1)) { |
| 100 | pc = preempt_count(); |
Arnaldo Carvalho de Melo | 7be4215 | 2009-02-05 01:13:37 -0500 | [diff] [blame] | 101 | trace_function(tr, ip, parent_ip, flags, pc); |
Steven Rostedt | bb3c3c9 | 2009-01-15 20:40:23 -0500 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | atomic_dec(&data->disabled); |
| 105 | local_irq_restore(flags); |
| 106 | } |
| 107 | |
| 108 | static void |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 109 | function_stack_trace_call(unsigned long ip, unsigned long parent_ip) |
| 110 | { |
| 111 | struct trace_array *tr = func_trace; |
| 112 | struct trace_array_cpu *data; |
| 113 | unsigned long flags; |
| 114 | long disabled; |
| 115 | int cpu; |
| 116 | int pc; |
| 117 | |
| 118 | if (unlikely(!ftrace_function_enabled)) |
| 119 | return; |
| 120 | |
| 121 | /* |
| 122 | * Need to use raw, since this must be called before the |
| 123 | * recursive protection is performed. |
| 124 | */ |
| 125 | local_irq_save(flags); |
| 126 | cpu = raw_smp_processor_id(); |
| 127 | data = tr->data[cpu]; |
| 128 | disabled = atomic_inc_return(&data->disabled); |
| 129 | |
| 130 | if (likely(disabled == 1)) { |
| 131 | pc = preempt_count(); |
Arnaldo Carvalho de Melo | 7be4215 | 2009-02-05 01:13:37 -0500 | [diff] [blame] | 132 | trace_function(tr, ip, parent_ip, flags, pc); |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 133 | /* |
| 134 | * skip over 5 funcs: |
| 135 | * __ftrace_trace_stack, |
| 136 | * __trace_stack, |
| 137 | * function_stack_trace_call |
| 138 | * ftrace_list_func |
| 139 | * ftrace_call |
| 140 | */ |
Arnaldo Carvalho de Melo | 7be4215 | 2009-02-05 01:13:37 -0500 | [diff] [blame] | 141 | __trace_stack(tr, flags, 5, pc); |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | atomic_dec(&data->disabled); |
| 145 | local_irq_restore(flags); |
| 146 | } |
| 147 | |
Steven Rostedt | bb3c3c9 | 2009-01-15 20:40:23 -0500 | [diff] [blame] | 148 | |
| 149 | static struct ftrace_ops trace_ops __read_mostly = |
| 150 | { |
| 151 | .func = function_trace_call, |
| 152 | }; |
| 153 | |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 154 | static struct ftrace_ops trace_stack_ops __read_mostly = |
| 155 | { |
| 156 | .func = function_stack_trace_call, |
| 157 | }; |
| 158 | |
| 159 | /* Our two options */ |
| 160 | enum { |
| 161 | TRACE_FUNC_OPT_STACK = 0x1, |
| 162 | }; |
| 163 | |
| 164 | static struct tracer_opt func_opts[] = { |
| 165 | #ifdef CONFIG_STACKTRACE |
| 166 | { TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) }, |
| 167 | #endif |
| 168 | { } /* Always set a last empty entry */ |
| 169 | }; |
| 170 | |
| 171 | static struct tracer_flags func_flags = { |
| 172 | .val = 0, /* By default: all flags disabled */ |
| 173 | .opts = func_opts |
| 174 | }; |
| 175 | |
Steven Rostedt | a225cdd | 2009-01-15 23:06:03 -0500 | [diff] [blame] | 176 | static void tracing_start_function_trace(void) |
Steven Rostedt | 3eb36aa | 2009-01-15 22:21:43 -0500 | [diff] [blame] | 177 | { |
| 178 | ftrace_function_enabled = 0; |
| 179 | |
| 180 | if (trace_flags & TRACE_ITER_PREEMPTONLY) |
| 181 | trace_ops.func = function_trace_call_preempt_only; |
| 182 | else |
| 183 | trace_ops.func = function_trace_call; |
| 184 | |
| 185 | if (func_flags.val & TRACE_FUNC_OPT_STACK) |
| 186 | register_ftrace_function(&trace_stack_ops); |
| 187 | else |
| 188 | register_ftrace_function(&trace_ops); |
| 189 | |
| 190 | ftrace_function_enabled = 1; |
| 191 | } |
| 192 | |
Steven Rostedt | a225cdd | 2009-01-15 23:06:03 -0500 | [diff] [blame] | 193 | static void tracing_stop_function_trace(void) |
Steven Rostedt | 3eb36aa | 2009-01-15 22:21:43 -0500 | [diff] [blame] | 194 | { |
| 195 | ftrace_function_enabled = 0; |
Frederic Weisbecker | c85a17e | 2009-06-20 05:45:14 +0200 | [diff] [blame] | 196 | |
| 197 | if (func_flags.val & TRACE_FUNC_OPT_STACK) |
| 198 | unregister_ftrace_function(&trace_stack_ops); |
| 199 | else |
| 200 | unregister_ftrace_function(&trace_ops); |
Steven Rostedt | 3eb36aa | 2009-01-15 22:21:43 -0500 | [diff] [blame] | 201 | } |
| 202 | |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 203 | static int func_set_flag(u32 old_flags, u32 bit, int set) |
| 204 | { |
| 205 | if (bit == TRACE_FUNC_OPT_STACK) { |
| 206 | /* do nothing if already set */ |
| 207 | if (!!set == !!(func_flags.val & TRACE_FUNC_OPT_STACK)) |
| 208 | return 0; |
| 209 | |
Steven Rostedt | 3eb36aa | 2009-01-15 22:21:43 -0500 | [diff] [blame] | 210 | if (set) { |
| 211 | unregister_ftrace_function(&trace_ops); |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 212 | register_ftrace_function(&trace_stack_ops); |
Steven Rostedt | 3eb36aa | 2009-01-15 22:21:43 -0500 | [diff] [blame] | 213 | } else { |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 214 | unregister_ftrace_function(&trace_stack_ops); |
Steven Rostedt | 3eb36aa | 2009-01-15 22:21:43 -0500 | [diff] [blame] | 215 | register_ftrace_function(&trace_ops); |
| 216 | } |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 217 | |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | return -EINVAL; |
| 222 | } |
| 223 | |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 224 | static struct tracer function_trace __read_mostly = |
| 225 | { |
Steven Rostedt | 3eb36aa | 2009-01-15 22:21:43 -0500 | [diff] [blame] | 226 | .name = "function", |
| 227 | .init = function_trace_init, |
| 228 | .reset = function_trace_reset, |
| 229 | .start = function_trace_start, |
Frederic Weisbecker | 6eaaa5d | 2009-02-11 02:25:00 +0100 | [diff] [blame] | 230 | .wait_pipe = poll_wait_pipe, |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 231 | .flags = &func_flags, |
| 232 | .set_flag = func_set_flag, |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 233 | #ifdef CONFIG_FTRACE_SELFTEST |
Steven Rostedt | 3eb36aa | 2009-01-15 22:21:43 -0500 | [diff] [blame] | 234 | .selftest = trace_selftest_startup_function, |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 235 | #endif |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 236 | }; |
| 237 | |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 238 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 239 | static void |
| 240 | ftrace_traceon(unsigned long ip, unsigned long parent_ip, void **data) |
| 241 | { |
| 242 | long *count = (long *)data; |
| 243 | |
| 244 | if (tracing_is_on()) |
| 245 | return; |
| 246 | |
| 247 | if (!*count) |
| 248 | return; |
| 249 | |
| 250 | if (*count != -1) |
| 251 | (*count)--; |
| 252 | |
| 253 | tracing_on(); |
| 254 | } |
| 255 | |
| 256 | static void |
| 257 | ftrace_traceoff(unsigned long ip, unsigned long parent_ip, void **data) |
| 258 | { |
| 259 | long *count = (long *)data; |
| 260 | |
| 261 | if (!tracing_is_on()) |
| 262 | return; |
| 263 | |
| 264 | if (!*count) |
| 265 | return; |
| 266 | |
| 267 | if (*count != -1) |
| 268 | (*count)--; |
| 269 | |
| 270 | tracing_off(); |
| 271 | } |
| 272 | |
Steven Rostedt | e110e3d | 2009-02-16 23:38:13 -0500 | [diff] [blame] | 273 | static int |
| 274 | ftrace_trace_onoff_print(struct seq_file *m, unsigned long ip, |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 275 | struct ftrace_probe_ops *ops, void *data); |
Steven Rostedt | e110e3d | 2009-02-16 23:38:13 -0500 | [diff] [blame] | 276 | |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 277 | static struct ftrace_probe_ops traceon_probe_ops = { |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 278 | .func = ftrace_traceon, |
Steven Rostedt | e110e3d | 2009-02-16 23:38:13 -0500 | [diff] [blame] | 279 | .print = ftrace_trace_onoff_print, |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 280 | }; |
| 281 | |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 282 | static struct ftrace_probe_ops traceoff_probe_ops = { |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 283 | .func = ftrace_traceoff, |
Steven Rostedt | e110e3d | 2009-02-16 23:38:13 -0500 | [diff] [blame] | 284 | .print = ftrace_trace_onoff_print, |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 285 | }; |
| 286 | |
| 287 | static int |
Steven Rostedt | e110e3d | 2009-02-16 23:38:13 -0500 | [diff] [blame] | 288 | ftrace_trace_onoff_print(struct seq_file *m, unsigned long ip, |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 289 | struct ftrace_probe_ops *ops, void *data) |
Steven Rostedt | e110e3d | 2009-02-16 23:38:13 -0500 | [diff] [blame] | 290 | { |
| 291 | char str[KSYM_SYMBOL_LEN]; |
| 292 | long count = (long)data; |
| 293 | |
| 294 | kallsyms_lookup(ip, NULL, NULL, NULL, str); |
| 295 | seq_printf(m, "%s:", str); |
| 296 | |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 297 | if (ops == &traceon_probe_ops) |
Steven Rostedt | e110e3d | 2009-02-16 23:38:13 -0500 | [diff] [blame] | 298 | seq_printf(m, "traceon"); |
| 299 | else |
| 300 | seq_printf(m, "traceoff"); |
| 301 | |
Steven Rostedt | 35ebf1c | 2009-02-17 13:12:12 -0500 | [diff] [blame] | 302 | if (count == -1) |
| 303 | seq_printf(m, ":unlimited\n"); |
| 304 | else |
Li Zefan | 00e54d0 | 2009-06-25 14:05:27 +0800 | [diff] [blame^] | 305 | seq_printf(m, ":count=%ld\n", count); |
Steven Rostedt | e110e3d | 2009-02-16 23:38:13 -0500 | [diff] [blame] | 306 | |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | static int |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 311 | ftrace_trace_onoff_unreg(char *glob, char *cmd, char *param) |
| 312 | { |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 313 | struct ftrace_probe_ops *ops; |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 314 | |
| 315 | /* we register both traceon and traceoff to this callback */ |
| 316 | if (strcmp(cmd, "traceon") == 0) |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 317 | ops = &traceon_probe_ops; |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 318 | else |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 319 | ops = &traceoff_probe_ops; |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 320 | |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 321 | unregister_ftrace_function_probe_func(glob, ops); |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 322 | |
| 323 | return 0; |
| 324 | } |
| 325 | |
| 326 | static int |
| 327 | ftrace_trace_onoff_callback(char *glob, char *cmd, char *param, int enable) |
| 328 | { |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 329 | struct ftrace_probe_ops *ops; |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 330 | void *count = (void *)-1; |
| 331 | char *number; |
| 332 | int ret; |
| 333 | |
| 334 | /* hash funcs only work with set_ftrace_filter */ |
| 335 | if (!enable) |
| 336 | return -EINVAL; |
| 337 | |
| 338 | if (glob[0] == '!') |
| 339 | return ftrace_trace_onoff_unreg(glob+1, cmd, param); |
| 340 | |
| 341 | /* we register both traceon and traceoff to this callback */ |
| 342 | if (strcmp(cmd, "traceon") == 0) |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 343 | ops = &traceon_probe_ops; |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 344 | else |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 345 | ops = &traceoff_probe_ops; |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 346 | |
| 347 | if (!param) |
| 348 | goto out_reg; |
| 349 | |
| 350 | number = strsep(¶m, ":"); |
| 351 | |
| 352 | if (!strlen(number)) |
| 353 | goto out_reg; |
| 354 | |
| 355 | /* |
| 356 | * We use the callback data field (which is a pointer) |
| 357 | * as our counter. |
| 358 | */ |
| 359 | ret = strict_strtoul(number, 0, (unsigned long *)&count); |
| 360 | if (ret) |
| 361 | return ret; |
| 362 | |
| 363 | out_reg: |
Steven Rostedt | b6887d7 | 2009-02-17 12:32:04 -0500 | [diff] [blame] | 364 | ret = register_ftrace_function_probe(glob, ops, count); |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 365 | |
| 366 | return ret; |
| 367 | } |
| 368 | |
| 369 | static struct ftrace_func_command ftrace_traceon_cmd = { |
| 370 | .name = "traceon", |
| 371 | .func = ftrace_trace_onoff_callback, |
| 372 | }; |
| 373 | |
| 374 | static struct ftrace_func_command ftrace_traceoff_cmd = { |
| 375 | .name = "traceoff", |
| 376 | .func = ftrace_trace_onoff_callback, |
| 377 | }; |
| 378 | |
| 379 | static int __init init_func_cmd_traceon(void) |
| 380 | { |
| 381 | int ret; |
| 382 | |
| 383 | ret = register_ftrace_command(&ftrace_traceoff_cmd); |
| 384 | if (ret) |
| 385 | return ret; |
| 386 | |
| 387 | ret = register_ftrace_command(&ftrace_traceon_cmd); |
| 388 | if (ret) |
| 389 | unregister_ftrace_command(&ftrace_traceoff_cmd); |
| 390 | return ret; |
| 391 | } |
| 392 | #else |
| 393 | static inline int init_func_cmd_traceon(void) |
| 394 | { |
| 395 | return 0; |
| 396 | } |
| 397 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
| 398 | |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 399 | static __init int init_function_trace(void) |
| 400 | { |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 401 | init_func_cmd_traceon(); |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 402 | return register_tracer(&function_trace); |
| 403 | } |
Steven Rostedt | 1b29b01 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 404 | device_initcall(init_function_trace); |
Steven Rostedt | 23b4ff3a | 2009-02-14 19:04:24 -0500 | [diff] [blame] | 405 | |