ftrace.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*
  2. * Ftrace header. For implementation details beyond the random comments
  3. * scattered below, see: Documentation/trace/ftrace-design.txt
  4. */
  5. #ifndef _LINUX_FTRACE_H
  6. #define _LINUX_FTRACE_H
  7. #include <linux/trace_clock.h>
  8. #include <linux/kallsyms.h>
  9. #include <linux/linkage.h>
  10. #include <linux/bitops.h>
  11. #include <linux/ktime.h>
  12. #include <linux/sched.h>
  13. #include <linux/types.h>
  14. #include <linux/init.h>
  15. #include <linux/fs.h>
  16. #include <asm/ftrace.h>
  17. struct module;
  18. struct ftrace_hash;
  19. #ifdef CONFIG_FUNCTION_TRACER
  20. extern int ftrace_enabled;
  21. extern int
  22. ftrace_enable_sysctl(struct ctl_table *table, int write,
  23. void __user *buffer, size_t *lenp,
  24. loff_t *ppos);
  25. typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
  26. /*
  27. * FTRACE_OPS_FL_* bits denote the state of ftrace_ops struct and are
  28. * set in the flags member.
  29. *
  30. * ENABLED - set/unset when ftrace_ops is registered/unregistered
  31. * GLOBAL - set manualy by ftrace_ops user to denote the ftrace_ops
  32. * is part of the global tracers sharing the same filter
  33. * via set_ftrace_* debugfs files.
  34. * DYNAMIC - set when ftrace_ops is registered to denote dynamically
  35. * allocated ftrace_ops which need special care
  36. * CONTROL - set manualy by ftrace_ops user to denote the ftrace_ops
  37. * could be controled by following calls:
  38. * ftrace_function_local_enable
  39. * ftrace_function_local_disable
  40. */
  41. enum {
  42. FTRACE_OPS_FL_ENABLED = 1 << 0,
  43. FTRACE_OPS_FL_GLOBAL = 1 << 1,
  44. FTRACE_OPS_FL_DYNAMIC = 1 << 2,
  45. FTRACE_OPS_FL_CONTROL = 1 << 3,
  46. };
  47. struct ftrace_ops {
  48. ftrace_func_t func;
  49. struct ftrace_ops *next;
  50. unsigned long flags;
  51. int __percpu *disabled;
  52. #ifdef CONFIG_DYNAMIC_FTRACE
  53. struct ftrace_hash *notrace_hash;
  54. struct ftrace_hash *filter_hash;
  55. #endif
  56. };
  57. extern int function_trace_stop;
  58. /*
  59. * Type of the current tracing.
  60. */
  61. enum ftrace_tracing_type_t {
  62. FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */
  63. FTRACE_TYPE_RETURN, /* Hook the return of the function */
  64. };
  65. /* Current tracing type, default is FTRACE_TYPE_ENTER */
  66. extern enum ftrace_tracing_type_t ftrace_tracing_type;
  67. /**
  68. * ftrace_stop - stop function tracer.
  69. *
  70. * A quick way to stop the function tracer. Note this an on off switch,
  71. * it is not something that is recursive like preempt_disable.
  72. * This does not disable the calling of mcount, it only stops the
  73. * calling of functions from mcount.
  74. */
  75. static inline void ftrace_stop(void)
  76. {
  77. function_trace_stop = 1;
  78. }
  79. /**
  80. * ftrace_start - start the function tracer.
  81. *
  82. * This function is the inverse of ftrace_stop. This does not enable
  83. * the function tracing if the function tracer is disabled. This only
  84. * sets the function tracer flag to continue calling the functions
  85. * from mcount.
  86. */
  87. static inline void ftrace_start(void)
  88. {
  89. function_trace_stop = 0;
  90. }
  91. /*
  92. * The ftrace_ops must be a static and should also
  93. * be read_mostly. These functions do modify read_mostly variables
  94. * so use them sparely. Never free an ftrace_op or modify the
  95. * next pointer after it has been registered. Even after unregistering
  96. * it, the next pointer may still be used internally.
  97. */
  98. int register_ftrace_function(struct ftrace_ops *ops);
  99. int unregister_ftrace_function(struct ftrace_ops *ops);
  100. void clear_ftrace_function(void);
  101. /**
  102. * ftrace_function_local_enable - enable controlled ftrace_ops on current cpu
  103. *
  104. * This function enables tracing on current cpu by decreasing
  105. * the per cpu control variable.
  106. * It must be called with preemption disabled and only on ftrace_ops
  107. * registered with FTRACE_OPS_FL_CONTROL. If called without preemption
  108. * disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
  109. */
  110. static inline void ftrace_function_local_enable(struct ftrace_ops *ops)
  111. {
  112. if (WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_CONTROL)))
  113. return;
  114. (*this_cpu_ptr(ops->disabled))--;
  115. }
  116. /**
  117. * ftrace_function_local_disable - enable controlled ftrace_ops on current cpu
  118. *
  119. * This function enables tracing on current cpu by decreasing
  120. * the per cpu control variable.
  121. * It must be called with preemption disabled and only on ftrace_ops
  122. * registered with FTRACE_OPS_FL_CONTROL. If called without preemption
  123. * disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
  124. */
  125. static inline void ftrace_function_local_disable(struct ftrace_ops *ops)
  126. {
  127. if (WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_CONTROL)))
  128. return;
  129. (*this_cpu_ptr(ops->disabled))++;
  130. }
  131. /**
  132. * ftrace_function_local_disabled - returns ftrace_ops disabled value
  133. * on current cpu
  134. *
  135. * This function returns value of ftrace_ops::disabled on current cpu.
  136. * It must be called with preemption disabled and only on ftrace_ops
  137. * registered with FTRACE_OPS_FL_CONTROL. If called without preemption
  138. * disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
  139. */
  140. static inline int ftrace_function_local_disabled(struct ftrace_ops *ops)
  141. {
  142. WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_CONTROL));
  143. return *this_cpu_ptr(ops->disabled);
  144. }
  145. extern void ftrace_stub(unsigned long a0, unsigned long a1);
  146. #else /* !CONFIG_FUNCTION_TRACER */
  147. /*
  148. * (un)register_ftrace_function must be a macro since the ops parameter
  149. * must not be evaluated.
  150. */
  151. #define register_ftrace_function(ops) ({ 0; })
  152. #define unregister_ftrace_function(ops) ({ 0; })
  153. static inline void clear_ftrace_function(void) { }
  154. static inline void ftrace_kill(void) { }
  155. static inline void ftrace_stop(void) { }
  156. static inline void ftrace_start(void) { }
  157. #endif /* CONFIG_FUNCTION_TRACER */
  158. #ifdef CONFIG_STACK_TRACER
  159. extern int stack_tracer_enabled;
  160. int
  161. stack_trace_sysctl(struct ctl_table *table, int write,
  162. void __user *buffer, size_t *lenp,
  163. loff_t *ppos);
  164. #endif
  165. struct ftrace_func_command {
  166. struct list_head list;
  167. char *name;
  168. int (*func)(struct ftrace_hash *hash,
  169. char *func, char *cmd,
  170. char *params, int enable);
  171. };
  172. #ifdef CONFIG_DYNAMIC_FTRACE
  173. int ftrace_arch_code_modify_prepare(void);
  174. int ftrace_arch_code_modify_post_process(void);
  175. void ftrace_bug(int err, unsigned long ip);
  176. struct seq_file;
  177. struct ftrace_probe_ops {
  178. void (*func)(unsigned long ip,
  179. unsigned long parent_ip,
  180. void **data);
  181. int (*callback)(unsigned long ip, void **data);
  182. void (*free)(void **data);
  183. int (*print)(struct seq_file *m,
  184. unsigned long ip,
  185. struct ftrace_probe_ops *ops,
  186. void *data);
  187. };
  188. extern int
  189. register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
  190. void *data);
  191. extern void
  192. unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
  193. void *data);
  194. extern void
  195. unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops);
  196. extern void unregister_ftrace_function_probe_all(char *glob);
  197. extern int ftrace_text_reserved(void *start, void *end);
  198. enum {
  199. FTRACE_FL_ENABLED = (1 << 30),
  200. };
  201. #define FTRACE_FL_MASK (0x3UL << 30)
  202. #define FTRACE_REF_MAX ((1 << 30) - 1)
  203. struct dyn_ftrace {
  204. union {
  205. unsigned long ip; /* address of mcount call-site */
  206. struct dyn_ftrace *freelist;
  207. };
  208. unsigned long flags;
  209. struct dyn_arch_ftrace arch;
  210. };
  211. int ftrace_force_update(void);
  212. int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
  213. int len, int reset);
  214. int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
  215. int len, int reset);
  216. void ftrace_set_global_filter(unsigned char *buf, int len, int reset);
  217. void ftrace_set_global_notrace(unsigned char *buf, int len, int reset);
  218. void ftrace_free_filter(struct ftrace_ops *ops);
  219. int register_ftrace_command(struct ftrace_func_command *cmd);
  220. int unregister_ftrace_command(struct ftrace_func_command *cmd);
  221. enum {
  222. FTRACE_UPDATE_CALLS = (1 << 0),
  223. FTRACE_DISABLE_CALLS = (1 << 1),
  224. FTRACE_UPDATE_TRACE_FUNC = (1 << 2),
  225. FTRACE_START_FUNC_RET = (1 << 3),
  226. FTRACE_STOP_FUNC_RET = (1 << 4),
  227. };
  228. enum {
  229. FTRACE_UPDATE_IGNORE,
  230. FTRACE_UPDATE_MAKE_CALL,
  231. FTRACE_UPDATE_MAKE_NOP,
  232. };
  233. enum {
  234. FTRACE_ITER_FILTER = (1 << 0),
  235. FTRACE_ITER_NOTRACE = (1 << 1),
  236. FTRACE_ITER_PRINTALL = (1 << 2),
  237. FTRACE_ITER_DO_HASH = (1 << 3),
  238. FTRACE_ITER_HASH = (1 << 4),
  239. FTRACE_ITER_ENABLED = (1 << 5),
  240. };
  241. void arch_ftrace_update_code(int command);
  242. struct ftrace_rec_iter;
  243. struct ftrace_rec_iter *ftrace_rec_iter_start(void);
  244. struct ftrace_rec_iter *ftrace_rec_iter_next(struct ftrace_rec_iter *iter);
  245. struct dyn_ftrace *ftrace_rec_iter_record(struct ftrace_rec_iter *iter);
  246. int ftrace_update_record(struct dyn_ftrace *rec, int enable);
  247. int ftrace_test_record(struct dyn_ftrace *rec, int enable);
  248. void ftrace_run_stop_machine(int command);
  249. int ftrace_location(unsigned long ip);
  250. extern ftrace_func_t ftrace_trace_function;
  251. int ftrace_regex_open(struct ftrace_ops *ops, int flag,
  252. struct inode *inode, struct file *file);
  253. ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
  254. size_t cnt, loff_t *ppos);
  255. ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
  256. size_t cnt, loff_t *ppos);
  257. int ftrace_regex_release(struct inode *inode, struct file *file);
  258. void __init
  259. ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);
  260. /* defined in arch */
  261. extern int ftrace_ip_converted(unsigned long ip);
  262. extern int ftrace_dyn_arch_init(void *data);
  263. extern int ftrace_update_ftrace_func(ftrace_func_t func);
  264. extern void ftrace_caller(void);
  265. extern void ftrace_call(void);
  266. extern void mcount_call(void);
  267. #ifndef FTRACE_ADDR
  268. #define FTRACE_ADDR ((unsigned long)ftrace_caller)
  269. #endif
  270. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  271. extern void ftrace_graph_caller(void);
  272. extern int ftrace_enable_ftrace_graph_caller(void);
  273. extern int ftrace_disable_ftrace_graph_caller(void);
  274. #else
  275. static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; }
  276. static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; }
  277. #endif
  278. /**
  279. * ftrace_make_nop - convert code into nop
  280. * @mod: module structure if called by module load initialization
  281. * @rec: the mcount call site record
  282. * @addr: the address that the call site should be calling
  283. *
  284. * This is a very sensitive operation and great care needs
  285. * to be taken by the arch. The operation should carefully
  286. * read the location, check to see if what is read is indeed
  287. * what we expect it to be, and then on success of the compare,
  288. * it should write to the location.
  289. *
  290. * The code segment at @rec->ip should be a caller to @addr
  291. *
  292. * Return must be:
  293. * 0 on success
  294. * -EFAULT on error reading the location
  295. * -EINVAL on a failed compare of the contents
  296. * -EPERM on error writing to the location
  297. * Any other value will be considered a failure.
  298. */
  299. extern int ftrace_make_nop(struct module *mod,
  300. struct dyn_ftrace *rec, unsigned long addr);
  301. /**
  302. * ftrace_make_call - convert a nop call site into a call to addr
  303. * @rec: the mcount call site record
  304. * @addr: the address that the call site should call
  305. *
  306. * This is a very sensitive operation and great care needs
  307. * to be taken by the arch. The operation should carefully
  308. * read the location, check to see if what is read is indeed
  309. * what we expect it to be, and then on success of the compare,
  310. * it should write to the location.
  311. *
  312. * The code segment at @rec->ip should be a nop
  313. *
  314. * Return must be:
  315. * 0 on success
  316. * -EFAULT on error reading the location
  317. * -EINVAL on a failed compare of the contents
  318. * -EPERM on error writing to the location
  319. * Any other value will be considered a failure.
  320. */
  321. extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
  322. /* May be defined in arch */
  323. extern int ftrace_arch_read_dyn_info(char *buf, int size);
  324. extern int skip_trace(unsigned long ip);
  325. extern void ftrace_module_init(struct module *mod);
  326. extern void ftrace_disable_daemon(void);
  327. extern void ftrace_enable_daemon(void);
  328. #else
  329. static inline int skip_trace(unsigned long ip) { return 0; }
  330. static inline int ftrace_force_update(void) { return 0; }
  331. static inline void ftrace_disable_daemon(void) { }
  332. static inline void ftrace_enable_daemon(void) { }
  333. static inline void ftrace_release_mod(struct module *mod) {}
  334. static inline void ftrace_module_init(struct module *mod) {}
  335. static inline int register_ftrace_command(struct ftrace_func_command *cmd)
  336. {
  337. return -EINVAL;
  338. }
  339. static inline int unregister_ftrace_command(char *cmd_name)
  340. {
  341. return -EINVAL;
  342. }
  343. static inline int ftrace_text_reserved(void *start, void *end)
  344. {
  345. return 0;
  346. }
  347. /*
  348. * Again users of functions that have ftrace_ops may not
  349. * have them defined when ftrace is not enabled, but these
  350. * functions may still be called. Use a macro instead of inline.
  351. */
  352. #define ftrace_regex_open(ops, flag, inod, file) ({ -ENODEV; })
  353. #define ftrace_set_early_filter(ops, buf, enable) do { } while (0)
  354. #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
  355. #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
  356. #define ftrace_free_filter(ops) do { } while (0)
  357. static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
  358. size_t cnt, loff_t *ppos) { return -ENODEV; }
  359. static inline ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
  360. size_t cnt, loff_t *ppos) { return -ENODEV; }
  361. static inline loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int origin)
  362. {
  363. return -ENODEV;
  364. }
  365. static inline int
  366. ftrace_regex_release(struct inode *inode, struct file *file) { return -ENODEV; }
  367. #endif /* CONFIG_DYNAMIC_FTRACE */
  368. loff_t ftrace_filter_lseek(struct file *file, loff_t offset, int whence);
  369. /* totally disable ftrace - can not re-enable after this */
  370. void ftrace_kill(void);
  371. static inline void tracer_disable(void)
  372. {
  373. #ifdef CONFIG_FUNCTION_TRACER
  374. ftrace_enabled = 0;
  375. #endif
  376. }
  377. /*
  378. * Ftrace disable/restore without lock. Some synchronization mechanism
  379. * must be used to prevent ftrace_enabled to be changed between
  380. * disable/restore.
  381. */
  382. static inline int __ftrace_enabled_save(void)
  383. {
  384. #ifdef CONFIG_FUNCTION_TRACER
  385. int saved_ftrace_enabled = ftrace_enabled;
  386. ftrace_enabled = 0;
  387. return saved_ftrace_enabled;
  388. #else
  389. return 0;
  390. #endif
  391. }
  392. static inline void __ftrace_enabled_restore(int enabled)
  393. {
  394. #ifdef CONFIG_FUNCTION_TRACER
  395. ftrace_enabled = enabled;
  396. #endif
  397. }
  398. #ifndef HAVE_ARCH_CALLER_ADDR
  399. # ifdef CONFIG_FRAME_POINTER
  400. # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  401. # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
  402. # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
  403. # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
  404. # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
  405. # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
  406. # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
  407. # else
  408. # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  409. # define CALLER_ADDR1 0UL
  410. # define CALLER_ADDR2 0UL
  411. # define CALLER_ADDR3 0UL
  412. # define CALLER_ADDR4 0UL
  413. # define CALLER_ADDR5 0UL
  414. # define CALLER_ADDR6 0UL
  415. # endif
  416. #endif /* ifndef HAVE_ARCH_CALLER_ADDR */
  417. #ifdef CONFIG_IRQSOFF_TRACER
  418. extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
  419. extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
  420. #else
  421. static inline void time_hardirqs_on(unsigned long a0, unsigned long a1) { }
  422. static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { }
  423. #endif
  424. #ifdef CONFIG_PREEMPT_TRACER
  425. extern void trace_preempt_on(unsigned long a0, unsigned long a1);
  426. extern void trace_preempt_off(unsigned long a0, unsigned long a1);
  427. #else
  428. static inline void trace_preempt_on(unsigned long a0, unsigned long a1) { }
  429. static inline void trace_preempt_off(unsigned long a0, unsigned long a1) { }
  430. #endif
  431. #ifdef CONFIG_FTRACE_MCOUNT_RECORD
  432. extern void ftrace_init(void);
  433. #else
  434. static inline void ftrace_init(void) { }
  435. #endif
  436. /*
  437. * Structure that defines an entry function trace.
  438. */
  439. struct ftrace_graph_ent {
  440. unsigned long func; /* Current function */
  441. int depth;
  442. };
  443. /*
  444. * Structure that defines a return function trace.
  445. */
  446. struct ftrace_graph_ret {
  447. unsigned long func; /* Current function */
  448. unsigned long long calltime;
  449. unsigned long long rettime;
  450. /* Number of functions that overran the depth limit for current task */
  451. unsigned long overrun;
  452. int depth;
  453. };
  454. /* Type of the callback handlers for tracing function graph*/
  455. typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
  456. typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
  457. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  458. /* for init task */
  459. #define INIT_FTRACE_GRAPH .ret_stack = NULL,
  460. /*
  461. * Stack of return addresses for functions
  462. * of a thread.
  463. * Used in struct thread_info
  464. */
  465. struct ftrace_ret_stack {
  466. unsigned long ret;
  467. unsigned long func;
  468. unsigned long long calltime;
  469. unsigned long long subtime;
  470. unsigned long fp;
  471. };
  472. /*
  473. * Primary handler of a function return.
  474. * It relays on ftrace_return_to_handler.
  475. * Defined in entry_32/64.S
  476. */
  477. extern void return_to_handler(void);
  478. extern int
  479. ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
  480. unsigned long frame_pointer);
  481. /*
  482. * Sometimes we don't want to trace a function with the function
  483. * graph tracer but we want them to keep traced by the usual function
  484. * tracer if the function graph tracer is not configured.
  485. */
  486. #define __notrace_funcgraph notrace
  487. /*
  488. * We want to which function is an entrypoint of a hardirq.
  489. * That will help us to put a signal on output.
  490. */
  491. #define __irq_entry __attribute__((__section__(".irqentry.text")))
  492. /* Limits of hardirq entrypoints */
  493. extern char __irqentry_text_start[];
  494. extern char __irqentry_text_end[];
  495. #define FTRACE_RETFUNC_DEPTH 50
  496. #define FTRACE_RETSTACK_ALLOC_SIZE 32
  497. extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
  498. trace_func_graph_ent_t entryfunc);
  499. extern void ftrace_graph_stop(void);
  500. /* The current handlers in use */
  501. extern trace_func_graph_ret_t ftrace_graph_return;
  502. extern trace_func_graph_ent_t ftrace_graph_entry;
  503. extern void unregister_ftrace_graph(void);
  504. extern void ftrace_graph_init_task(struct task_struct *t);
  505. extern void ftrace_graph_exit_task(struct task_struct *t);
  506. extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu);
  507. static inline int task_curr_ret_stack(struct task_struct *t)
  508. {
  509. return t->curr_ret_stack;
  510. }
  511. static inline void pause_graph_tracing(void)
  512. {
  513. atomic_inc(&current->tracing_graph_pause);
  514. }
  515. static inline void unpause_graph_tracing(void)
  516. {
  517. atomic_dec(&current->tracing_graph_pause);
  518. }
  519. #else /* !CONFIG_FUNCTION_GRAPH_TRACER */
  520. #define __notrace_funcgraph
  521. #define __irq_entry
  522. #define INIT_FTRACE_GRAPH
  523. static inline void ftrace_graph_init_task(struct task_struct *t) { }
  524. static inline void ftrace_graph_exit_task(struct task_struct *t) { }
  525. static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { }
  526. static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc,
  527. trace_func_graph_ent_t entryfunc)
  528. {
  529. return -1;
  530. }
  531. static inline void unregister_ftrace_graph(void) { }
  532. static inline int task_curr_ret_stack(struct task_struct *tsk)
  533. {
  534. return -1;
  535. }
  536. static inline void pause_graph_tracing(void) { }
  537. static inline void unpause_graph_tracing(void) { }
  538. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
  539. #ifdef CONFIG_TRACING
  540. /* flags for current->trace */
  541. enum {
  542. TSK_TRACE_FL_TRACE_BIT = 0,
  543. TSK_TRACE_FL_GRAPH_BIT = 1,
  544. };
  545. enum {
  546. TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT,
  547. TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT,
  548. };
  549. static inline void set_tsk_trace_trace(struct task_struct *tsk)
  550. {
  551. set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
  552. }
  553. static inline void clear_tsk_trace_trace(struct task_struct *tsk)
  554. {
  555. clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
  556. }
  557. static inline int test_tsk_trace_trace(struct task_struct *tsk)
  558. {
  559. return tsk->trace & TSK_TRACE_FL_TRACE;
  560. }
  561. static inline void set_tsk_trace_graph(struct task_struct *tsk)
  562. {
  563. set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
  564. }
  565. static inline void clear_tsk_trace_graph(struct task_struct *tsk)
  566. {
  567. clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
  568. }
  569. static inline int test_tsk_trace_graph(struct task_struct *tsk)
  570. {
  571. return tsk->trace & TSK_TRACE_FL_GRAPH;
  572. }
  573. enum ftrace_dump_mode;
  574. extern enum ftrace_dump_mode ftrace_dump_on_oops;
  575. #ifdef CONFIG_PREEMPT
  576. #define INIT_TRACE_RECURSION .trace_recursion = 0,
  577. #endif
  578. #endif /* CONFIG_TRACING */
  579. #ifndef INIT_TRACE_RECURSION
  580. #define INIT_TRACE_RECURSION
  581. #endif
  582. #ifdef CONFIG_FTRACE_SYSCALLS
  583. unsigned long arch_syscall_addr(int nr);
  584. #endif /* CONFIG_FTRACE_SYSCALLS */
  585. #endif /* _LINUX_FTRACE_H */