aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ftrace.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ftrace.h')
-rw-r--r--include/linux/ftrace.h160
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);
115extern void ftrace_caller(void); 117extern void ftrace_caller(void);
116extern void ftrace_call(void); 118extern void ftrace_call(void);
117extern void mcount_call(void); 119extern void mcount_call(void);
118#ifdef CONFIG_FUNCTION_RET_TRACER 120#ifdef CONFIG_FUNCTION_GRAPH_TRACER
119extern void ftrace_return_caller(void); 121extern void ftrace_graph_caller(void);
122extern int ftrace_enable_ftrace_graph_caller(void);
123extern int ftrace_disable_ftrace_graph_caller(void);
124#else
125static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; }
126static 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
321enum {
322 POWER_NONE = 0,
323 POWER_CSTATE = 1,
324 POWER_PSTATE = 2,
325};
326
327struct 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
337extern void trace_power_start(struct power_trace *it, unsigned int type,
338 unsigned int state);
339extern void trace_power_mark(struct power_trace *it, unsigned int type,
340 unsigned int state);
341extern void trace_power_end(struct power_trace *it);
342#else
343static inline void trace_power_start(struct power_trace *it, unsigned int type,
344 unsigned int state) { }
345static inline void trace_power_mark(struct power_trace *it, unsigned int type,
346 unsigned int state) { }
347static inline void trace_power_end(struct power_trace *it) { }
348#endif
349
350
351/*
352 * Structure that defines an entry function trace.
353 */
354struct 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 */
318struct ftrace_retfunc { 362struct 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*/
331typedef void (*trace_function_return_t)(struct ftrace_retfunc *); 383typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
384typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
385
386extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
387 trace_func_graph_ent_t entryfunc);
388
389extern void ftrace_graph_stop(void);
390
391/* The current handlers in use */
392extern trace_func_graph_ret_t ftrace_graph_return;
393extern trace_func_graph_ent_t ftrace_graph_entry;
394
395extern void unregister_ftrace_graph(void);
396
397extern void ftrace_graph_init_task(struct task_struct *t);
398extern void ftrace_graph_exit_task(struct task_struct *t);
332 399
333extern int register_ftrace_return(trace_function_return_t func); 400static inline int task_curr_ret_stack(struct task_struct *t)
334/* The current handler in use */ 401{
335extern trace_function_return_t ftrace_function_return; 402 return t->curr_ret_stack;
336extern void unregister_ftrace_return(void); 403}
404
405static inline void pause_graph_tracing(void)
406{
407 atomic_inc(&current->tracing_graph_pause);
408}
337 409
338extern void ftrace_retfunc_init_task(struct task_struct *t); 410static inline void unpause_graph_tracing(void)
339extern void ftrace_retfunc_exit_task(struct task_struct *t); 411{
412 atomic_dec(&current->tracing_graph_pause);
413}
340#else 414#else
341static inline void ftrace_retfunc_init_task(struct task_struct *t) { } 415
342static inline void ftrace_retfunc_exit_task(struct task_struct *t) { } 416#define __notrace_funcgraph
417
418static inline void ftrace_graph_init_task(struct task_struct *t) { }
419static inline void ftrace_graph_exit_task(struct task_struct *t) { }
420
421static inline int task_curr_ret_stack(struct task_struct *tsk)
422{
423 return -1;
424}
425
426static inline void pause_graph_tracing(void) { }
427static 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 */
434enum {
435 TSK_TRACE_FL_TRACE_BIT = 0,
436 TSK_TRACE_FL_GRAPH_BIT = 1,
437};
438enum {
439 TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT,
440 TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT,
441};
442
443static inline void set_tsk_trace_trace(struct task_struct *tsk)
444{
445 set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
446}
447
448static inline void clear_tsk_trace_trace(struct task_struct *tsk)
449{
450 clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
451}
452
453static inline int test_tsk_trace_trace(struct task_struct *tsk)
454{
455 return tsk->trace & TSK_TRACE_FL_TRACE;
456}
457
458static inline void set_tsk_trace_graph(struct task_struct *tsk)
459{
460 set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
461}
462
463static inline void clear_tsk_trace_graph(struct task_struct *tsk)
464{
465 clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
466}
467
468static 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 */