21 static int ftrace_function_enabled;
25 static void tracing_start_function_trace(
void);
26 static void tracing_stop_function_trace(
void);
35 tracing_start_function_trace();
41 tracing_stop_function_trace();
51 function_trace_call_preempt_only(
unsigned long ip,
unsigned long parent_ip,
61 if (
unlikely(!ftrace_function_enabled))
86 function_trace_call(
unsigned long ip,
unsigned long parent_ip,
87 struct ftrace_ops *op,
struct pt_regs *pt_regs)
97 if (
unlikely(!ftrace_function_enabled))
109 if (
likely(disabled == 1)) {
119 function_stack_trace_call(
unsigned long ip,
unsigned long parent_ip,
120 struct ftrace_ops *op,
struct pt_regs *pt_regs)
129 if (
unlikely(!ftrace_function_enabled))
141 if (
likely(disabled == 1)) {
152 __trace_stack(tr, flags, 5, pc);
162 .func = function_trace_call,
163 .flags = FTRACE_OPS_FL_GLOBAL | FTRACE_OPS_FL_RECURSION_SAFE,
166 static struct ftrace_ops trace_stack_ops __read_mostly =
168 .func = function_stack_trace_call,
169 .flags = FTRACE_OPS_FL_GLOBAL | FTRACE_OPS_FL_RECURSION_SAFE,
173 #ifdef CONFIG_STACKTRACE
184 static void tracing_start_function_trace(
void)
186 ftrace_function_enabled = 0;
189 trace_ops.func = function_trace_call_preempt_only;
191 trace_ops.func = function_trace_call;
198 ftrace_function_enabled = 1;
201 static void tracing_stop_function_trace(
void)
203 ftrace_function_enabled = 0;
211 static int func_set_flag(
u32 old_flags,
u32 bit,
int set)
235 static struct tracer function_trace __read_mostly =
238 .init = function_trace_init,
239 .reset = function_trace_reset,
240 .start = function_trace_start,
242 .flags = &func_flags,
243 .set_flag = func_set_flag,
244 #ifdef CONFIG_FTRACE_SELFTEST
245 .selftest = trace_selftest_startup_function,
249 #ifdef CONFIG_DYNAMIC_FTRACE
251 ftrace_traceon(
unsigned long ip,
unsigned long parent_ip,
void **data)
253 long *
count = (
long *)data;
268 ftrace_traceoff(
unsigned long ip,
unsigned long parent_ip,
void **data)
270 long *count = (
long *)data;
285 ftrace_trace_onoff_print(
struct seq_file *
m,
unsigned long ip,
286 struct ftrace_probe_ops *ops,
void *data);
288 static struct ftrace_probe_ops traceon_probe_ops = {
289 .func = ftrace_traceon,
290 .print = ftrace_trace_onoff_print,
293 static struct ftrace_probe_ops traceoff_probe_ops = {
294 .func = ftrace_traceoff,
295 .print = ftrace_trace_onoff_print,
299 ftrace_trace_onoff_print(
struct seq_file *
m,
unsigned long ip,
300 struct ftrace_probe_ops *ops,
void *data)
302 long count = (
long)data;
306 if (ops == &traceon_probe_ops)
320 ftrace_trace_onoff_unreg(
char *glob,
char *
cmd,
char *
param)
322 struct ftrace_probe_ops *ops;
325 if (
strcmp(cmd,
"traceon") == 0)
326 ops = &traceon_probe_ops;
328 ops = &traceoff_probe_ops;
330 unregister_ftrace_function_probe_func(glob, ops);
336 ftrace_trace_onoff_callback(
struct ftrace_hash *
hash,
337 char *glob,
char *cmd,
char *param,
int enable)
339 struct ftrace_probe_ops *ops;
340 void *count = (
void *)-1;
349 return ftrace_trace_onoff_unreg(glob+1, cmd, param);
352 if (
strcmp(cmd,
"traceon") == 0)
353 ops = &traceon_probe_ops;
355 ops = &traceoff_probe_ops;
360 number =
strsep(¶m,
":");
374 ret = register_ftrace_function_probe(glob, ops, count);
376 return ret < 0 ? ret : 0;
381 .func = ftrace_trace_onoff_callback,
386 .func = ftrace_trace_onoff_callback,
389 static int __init init_func_cmd_traceon(
void)
393 ret = register_ftrace_command(&ftrace_traceoff_cmd);
397 ret = register_ftrace_command(&ftrace_traceon_cmd);
399 unregister_ftrace_command(&ftrace_traceoff_cmd);
403 static inline int init_func_cmd_traceon(
void)
409 static __init int init_function_trace(
void)
411 init_func_cmd_traceon();