diff options
Diffstat (limited to 'include/linux/ftrace.h')
-rw-r--r-- | include/linux/ftrace.h | 160 |
1 files changed, 145 insertions, 15 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 7854d87b97b2..11cac81eed08 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -7,6 +7,8 @@ | |||
7 | #include <linux/init.h> | 7 | #include <linux/init.h> |
8 | #include <linux/types.h> | 8 | #include <linux/types.h> |
9 | #include <linux/kallsyms.h> | 9 | #include <linux/kallsyms.h> |
10 | #include <linux/bitops.h> | ||
11 | #include <linux/sched.h> | ||
10 | 12 | ||
11 | #ifdef CONFIG_FUNCTION_TRACER | 13 | #ifdef CONFIG_FUNCTION_TRACER |
12 | 14 | ||
@@ -115,8 +117,13 @@ extern int ftrace_update_ftrace_func(ftrace_func_t func); | |||
115 | extern void ftrace_caller(void); | 117 | extern void ftrace_caller(void); |
116 | extern void ftrace_call(void); | 118 | extern void ftrace_call(void); |
117 | extern void mcount_call(void); | 119 | extern void mcount_call(void); |
118 | #ifdef CONFIG_FUNCTION_RET_TRACER | 120 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
119 | extern void ftrace_return_caller(void); | 121 | extern void ftrace_graph_caller(void); |
122 | extern int ftrace_enable_ftrace_graph_caller(void); | ||
123 | extern int ftrace_disable_ftrace_graph_caller(void); | ||
124 | #else | ||
125 | static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; } | ||
126 | static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; } | ||
120 | #endif | 127 | #endif |
121 | 128 | ||
122 | /** | 129 | /** |
@@ -311,35 +318,158 @@ ftrace_init_module(struct module *mod, | |||
311 | unsigned long *start, unsigned long *end) { } | 318 | unsigned long *start, unsigned long *end) { } |
312 | #endif | 319 | #endif |
313 | 320 | ||
321 | enum { | ||
322 | POWER_NONE = 0, | ||
323 | POWER_CSTATE = 1, | ||
324 | POWER_PSTATE = 2, | ||
325 | }; | ||
326 | |||
327 | struct power_trace { | ||
328 | #ifdef CONFIG_POWER_TRACER | ||
329 | ktime_t stamp; | ||
330 | ktime_t end; | ||
331 | int type; | ||
332 | int state; | ||
333 | #endif | ||
334 | }; | ||
335 | |||
336 | #ifdef CONFIG_POWER_TRACER | ||
337 | extern void trace_power_start(struct power_trace *it, unsigned int type, | ||
338 | unsigned int state); | ||
339 | extern void trace_power_mark(struct power_trace *it, unsigned int type, | ||
340 | unsigned int state); | ||
341 | extern void trace_power_end(struct power_trace *it); | ||
342 | #else | ||
343 | static inline void trace_power_start(struct power_trace *it, unsigned int type, | ||
344 | unsigned int state) { } | ||
345 | static inline void trace_power_mark(struct power_trace *it, unsigned int type, | ||
346 | unsigned int state) { } | ||
347 | static inline void trace_power_end(struct power_trace *it) { } | ||
348 | #endif | ||
349 | |||
350 | |||
351 | /* | ||
352 | * Structure that defines an entry function trace. | ||
353 | */ | ||
354 | struct ftrace_graph_ent { | ||
355 | unsigned long func; /* Current function */ | ||
356 | int depth; | ||
357 | }; | ||
314 | 358 | ||
315 | /* | 359 | /* |
316 | * Structure that defines a return function trace. | 360 | * Structure that defines a return function trace. |
317 | */ | 361 | */ |
318 | struct ftrace_retfunc { | 362 | struct ftrace_graph_ret { |
319 | unsigned long ret; /* Return address */ | ||
320 | unsigned long func; /* Current function */ | 363 | unsigned long func; /* Current function */ |
321 | unsigned long long calltime; | 364 | unsigned long long calltime; |
322 | unsigned long long rettime; | 365 | unsigned long long rettime; |
323 | /* Number of functions that overran the depth limit for current task */ | 366 | /* Number of functions that overran the depth limit for current task */ |
324 | unsigned long overrun; | 367 | unsigned long overrun; |
368 | int depth; | ||
325 | }; | 369 | }; |
326 | 370 | ||
327 | #ifdef CONFIG_FUNCTION_RET_TRACER | 371 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
372 | |||
373 | /* | ||
374 | * Sometimes we don't want to trace a function with the function | ||
375 | * graph tracer but we want them to keep traced by the usual function | ||
376 | * tracer if the function graph tracer is not configured. | ||
377 | */ | ||
378 | #define __notrace_funcgraph notrace | ||
379 | |||
328 | #define FTRACE_RETFUNC_DEPTH 50 | 380 | #define FTRACE_RETFUNC_DEPTH 50 |
329 | #define FTRACE_RETSTACK_ALLOC_SIZE 32 | 381 | #define FTRACE_RETSTACK_ALLOC_SIZE 32 |
330 | /* Type of a callback handler of tracing return function */ | 382 | /* Type of the callback handlers for tracing function graph*/ |
331 | typedef void (*trace_function_return_t)(struct ftrace_retfunc *); | 383 | typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */ |
384 | typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */ | ||
385 | |||
386 | extern int register_ftrace_graph(trace_func_graph_ret_t retfunc, | ||
387 | trace_func_graph_ent_t entryfunc); | ||
388 | |||
389 | extern void ftrace_graph_stop(void); | ||
390 | |||
391 | /* The current handlers in use */ | ||
392 | extern trace_func_graph_ret_t ftrace_graph_return; | ||
393 | extern trace_func_graph_ent_t ftrace_graph_entry; | ||
394 | |||
395 | extern void unregister_ftrace_graph(void); | ||
396 | |||
397 | extern void ftrace_graph_init_task(struct task_struct *t); | ||
398 | extern void ftrace_graph_exit_task(struct task_struct *t); | ||
332 | 399 | ||
333 | extern int register_ftrace_return(trace_function_return_t func); | 400 | static inline int task_curr_ret_stack(struct task_struct *t) |
334 | /* The current handler in use */ | 401 | { |
335 | extern trace_function_return_t ftrace_function_return; | 402 | return t->curr_ret_stack; |
336 | extern void unregister_ftrace_return(void); | 403 | } |
404 | |||
405 | static inline void pause_graph_tracing(void) | ||
406 | { | ||
407 | atomic_inc(¤t->tracing_graph_pause); | ||
408 | } | ||
337 | 409 | ||
338 | extern void ftrace_retfunc_init_task(struct task_struct *t); | 410 | static inline void unpause_graph_tracing(void) |
339 | extern void ftrace_retfunc_exit_task(struct task_struct *t); | 411 | { |
412 | atomic_dec(¤t->tracing_graph_pause); | ||
413 | } | ||
340 | #else | 414 | #else |
341 | static inline void ftrace_retfunc_init_task(struct task_struct *t) { } | 415 | |
342 | static inline void ftrace_retfunc_exit_task(struct task_struct *t) { } | 416 | #define __notrace_funcgraph |
417 | |||
418 | static inline void ftrace_graph_init_task(struct task_struct *t) { } | ||
419 | static inline void ftrace_graph_exit_task(struct task_struct *t) { } | ||
420 | |||
421 | static inline int task_curr_ret_stack(struct task_struct *tsk) | ||
422 | { | ||
423 | return -1; | ||
424 | } | ||
425 | |||
426 | static inline void pause_graph_tracing(void) { } | ||
427 | static inline void unpause_graph_tracing(void) { } | ||
343 | #endif | 428 | #endif |
344 | 429 | ||
430 | #ifdef CONFIG_TRACING | ||
431 | #include <linux/sched.h> | ||
432 | |||
433 | /* flags for current->trace */ | ||
434 | enum { | ||
435 | TSK_TRACE_FL_TRACE_BIT = 0, | ||
436 | TSK_TRACE_FL_GRAPH_BIT = 1, | ||
437 | }; | ||
438 | enum { | ||
439 | TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT, | ||
440 | TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT, | ||
441 | }; | ||
442 | |||
443 | static inline void set_tsk_trace_trace(struct task_struct *tsk) | ||
444 | { | ||
445 | set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace); | ||
446 | } | ||
447 | |||
448 | static inline void clear_tsk_trace_trace(struct task_struct *tsk) | ||
449 | { | ||
450 | clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace); | ||
451 | } | ||
452 | |||
453 | static inline int test_tsk_trace_trace(struct task_struct *tsk) | ||
454 | { | ||
455 | return tsk->trace & TSK_TRACE_FL_TRACE; | ||
456 | } | ||
457 | |||
458 | static inline void set_tsk_trace_graph(struct task_struct *tsk) | ||
459 | { | ||
460 | set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace); | ||
461 | } | ||
462 | |||
463 | static inline void clear_tsk_trace_graph(struct task_struct *tsk) | ||
464 | { | ||
465 | clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace); | ||
466 | } | ||
467 | |||
468 | static inline int test_tsk_trace_graph(struct task_struct *tsk) | ||
469 | { | ||
470 | return tsk->trace & TSK_TRACE_FL_GRAPH; | ||
471 | } | ||
472 | |||
473 | #endif /* CONFIG_TRACING */ | ||
474 | |||
345 | #endif /* _LINUX_FTRACE_H */ | 475 | #endif /* _LINUX_FTRACE_H */ |