ftrace.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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. loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int origin);
  258. int ftrace_regex_release(struct inode *inode, struct file *file);
  259. void __init
  260. ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);
  261. /* defined in arch */
  262. extern int ftrace_ip_converted(unsigned long ip);
  263. extern int ftrace_dyn_arch_init(void *data);
  264. extern int ftrace_update_ftrace_func(ftrace_func_t func);
  265. extern void ftrace_caller(void);
  266. extern void ftrace_call(void);
  267. extern void mcount_call(void);
  268. #ifndef FTRACE_ADDR
  269. #define FTRACE_ADDR ((unsigned long)ftrace_caller)
  270. #endif
  271. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  272. extern void ftrace_graph_caller(void);
  273. extern int ftrace_enable_ftrace_graph_caller(void);
  274. extern int ftrace_disable_ftrace_graph_caller(void);
  275. #else
  276. static inline int ftrace_enable_ftrace_graph_caller(void) { return 0; }
  277. static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; }
  278. #endif
  279. /**
  280. * ftrace_make_nop - convert code into nop
  281. * @mod: module structure if called by module load initialization
  282. * @rec: the mcount call site record
  283. * @addr: the address that the call site should be calling
  284. *
  285. * This is a very sensitive operation and great care needs
  286. * to be taken by the arch. The operation should carefully
  287. * read the location, check to see if what is read is indeed
  288. * what we expect it to be, and then on success of the compare,
  289. * it should write to the location.
  290. *
  291. * The code segment at @rec->ip should be a caller to @addr
  292. *
  293. * Return must be:
  294. * 0 on success
  295. * -EFAULT on error reading the location
  296. * -EINVAL on a failed compare of the contents
  297. * -EPERM on error writing to the location
  298. * Any other value will be considered a failure.
  299. */
  300. extern int ftrace_make_nop(struct module *mod,
  301. struct dyn_ftrace *rec, unsigned long addr);
  302. /**
  303. * ftrace_make_call - convert a nop call site into a call to addr
  304. * @rec: the mcount call site record
  305. * @addr: the address that the call site should call
  306. *
  307. * This is a very sensitive operation and great care needs
  308. * to be taken by the arch. The operation should carefully
  309. * read the location, check to see if what is read is indeed
  310. * what we expect it to be, and then on success of the compare,
  311. * it should write to the location.
  312. *
  313. * The code segment at @rec->ip should be a nop
  314. *
  315. * Return must be:
  316. * 0 on success
  317. * -EFAULT on error reading the location
  318. * -EINVAL on a failed compare of the contents
  319. * -EPERM on error writing to the location
  320. * Any other value will be considered a failure.
  321. */
  322. extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
  323. /* May be defined in arch */
  324. extern int ftrace_arch_read_dyn_info(char *buf, int size);
  325. extern int skip_trace(unsigned long ip);
  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 int register_ftrace_command(struct ftrace_func_command *cmd)
  335. {
  336. return -EINVAL;
  337. }
  338. static inline int unregister_ftrace_command(char *cmd_name)
  339. {
  340. return -EINVAL;
  341. }
  342. static inline int ftrace_text_reserved(void *start, void *end)
  343. {
  344. return 0;
  345. }
  346. /*
  347. * Again users of functions that have ftrace_ops may not
  348. * have them defined when ftrace is not enabled, but these
  349. * functions may still be called. Use a macro instead of inline.
  350. */
  351. #define ftrace_regex_open(ops, flag, inod, file) ({ -ENODEV; })
  352. #define ftrace_set_early_filter(ops, buf, enable) do { } while (0)
  353. #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
  354. #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
  355. #define ftrace_free_filter(ops) do { } while (0)
  356. static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
  357. size_t cnt, loff_t *ppos) { return -ENODEV; }
  358. static inline ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
  359. size_t cnt, loff_t *ppos) { return -ENODEV; }
  360. static inline loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int origin)
  361. {
  362. return -ENODEV;
  363. }
  364. static inline int
  365. ftrace_regex_release(struct inode *inode, struct file *file) { return -ENODEV; }
  366. #endif /* CONFIG_DYNAMIC_FTRACE */
  367. /* totally disable ftrace - can not re-enable after this */
  368. void ftrace_kill(void);
  369. static inline void tracer_disable(void)
  370. {
  371. #ifdef CONFIG_FUNCTION_TRACER
  372. ftrace_enabled = 0;
  373. #endif
  374. }
  375. /*
  376. * Ftrace disable/restore without lock. Some synchronization mechanism
  377. * must be used to prevent ftrace_enabled to be changed between
  378. * disable/restore.
  379. */
  380. static inline int __ftrace_enabled_save(void)
  381. {
  382. #ifdef CONFIG_FUNCTION_TRACER
  383. int saved_ftrace_enabled = ftrace_enabled;
  384. ftrace_enabled = 0;
  385. return saved_ftrace_enabled;
  386. #else
  387. return 0;
  388. #endif
  389. }
  390. static inline void __ftrace_enabled_restore(int enabled)
  391. {
  392. #ifdef CONFIG_FUNCTION_TRACER
  393. ftrace_enabled = enabled;
  394. #endif
  395. }
  396. #ifndef HAVE_ARCH_CALLER_ADDR
  397. # ifdef CONFIG_FRAME_POINTER
  398. # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  399. # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
  400. # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
  401. # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
  402. # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
  403. # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
  404. # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
  405. # else
  406. # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  407. # define CALLER_ADDR1 0UL
  408. # define CALLER_ADDR2 0UL
  409. # define CALLER_ADDR3 0UL
  410. # define CALLER_ADDR4 0UL
  411. # define CALLER_ADDR5 0UL
  412. # define CALLER_ADDR6 0UL
  413. # endif
  414. #endif /* ifndef HAVE_ARCH_CALLER_ADDR */
  415. #ifdef CONFIG_IRQSOFF_TRACER
  416. extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
  417. extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
  418. #else
  419. static inline void time_hardirqs_on(unsigned long a0, unsigned long a1) { }
  420. static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { }
  421. #endif
  422. #ifdef CONFIG_PREEMPT_TRACER
  423. extern void trace_preempt_on(unsigned long a0, unsigned long a1);
  424. extern void trace_preempt_off(unsigned long a0, unsigned long a1);
  425. #else
  426. static inline void trace_preempt_on(unsigned long a0, unsigned long a1) { }
  427. static inline void trace_preempt_off(unsigned long a0, unsigned long a1) { }
  428. #endif
  429. #ifdef CONFIG_FTRACE_MCOUNT_RECORD
  430. extern void ftrace_init(void);
  431. #else
  432. static inline void ftrace_init(void) { }
  433. #endif
  434. /*
  435. * Structure that defines an entry function trace.
  436. */
  437. struct ftrace_graph_ent {
  438. unsigned long func; /* Current function */
  439. int depth;
  440. };
  441. /*
  442. * Structure that defines a return function trace.
  443. */
  444. struct ftrace_graph_ret {
  445. unsigned long func; /* Current function */
  446. unsigned long long calltime;
  447. unsigned long long rettime;
  448. /* Number of functions that overran the depth limit for current task */
  449. unsigned long overrun;
  450. int depth;
  451. };
  452. /* Type of the callback handlers for tracing function graph*/
  453. typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
  454. typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
  455. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  456. /* for init task */
  457. #define INIT_FTRACE_GRAPH .ret_stack = NULL,
  458. /*
  459. * Stack of return addresses for functions
  460. * of a thread.
  461. * Used in struct thread_info
  462. */
  463. struct ftrace_ret_stack {
  464. unsigned long ret;
  465. unsigned long func;
  466. unsigned long long calltime;
  467. unsigned long long subtime;
  468. unsigned long fp;
  469. };
  470. /*
  471. * Primary handler of a function return.
  472. * It relays on ftrace_return_to_handler.
  473. * Defined in entry_32/64.S
  474. */
  475. extern void return_to_handler(void);
  476. extern int
  477. ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
  478. unsigned long frame_pointer);
  479. /*
  480. * Sometimes we don't want to trace a function with the function
  481. * graph tracer but we want them to keep traced by the usual function
  482. * tracer if the function graph tracer is not configured.
  483. */
  484. #define __notrace_funcgraph notrace
  485. /*
  486. * We want to which function is an entrypoint of a hardirq.
  487. * That will help us to put a signal on output.
  488. */
  489. #define __irq_entry __attribute__((__section__(".irqentry.text")))
  490. /* Limits of hardirq entrypoints */
  491. extern char __irqentry_text_start[];
  492. extern char __irqentry_text_end[];
  493. #define FTRACE_RETFUNC_DEPTH 50
  494. #define FTRACE_RETSTACK_ALLOC_SIZE 32
  495. extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,
  496. trace_func_graph_ent_t entryfunc);
  497. extern void ftrace_graph_stop(void);
  498. /* The current handlers in use */
  499. extern trace_func_graph_ret_t ftrace_graph_return;
  500. extern trace_func_graph_ent_t ftrace_graph_entry;
  501. extern void unregister_ftrace_graph(void);
  502. extern void ftrace_graph_init_task(struct task_struct *t);
  503. extern void ftrace_graph_exit_task(struct task_struct *t);
  504. extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu);
  505. static inline int task_curr_ret_stack(struct task_struct *t)
  506. {
  507. return t->curr_ret_stack;
  508. }
  509. static inline void pause_graph_tracing(void)
  510. {
  511. atomic_inc(&current->tracing_graph_pause);
  512. }
  513. static inline void unpause_graph_tracing(void)
  514. {
  515. atomic_dec(&current->tracing_graph_pause);
  516. }
  517. #else /* !CONFIG_FUNCTION_GRAPH_TRACER */
  518. #define __notrace_funcgraph
  519. #define __irq_entry
  520. #define INIT_FTRACE_GRAPH
  521. static inline void ftrace_graph_init_task(struct task_struct *t) { }
  522. static inline void ftrace_graph_exit_task(struct task_struct *t) { }
  523. static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { }
  524. static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc,
  525. trace_func_graph_ent_t entryfunc)
  526. {
  527. return -1;
  528. }
  529. static inline void unregister_ftrace_graph(void) { }
  530. static inline int task_curr_ret_stack(struct task_struct *tsk)
  531. {
  532. return -1;
  533. }
  534. static inline void pause_graph_tracing(void) { }
  535. static inline void unpause_graph_tracing(void) { }
  536. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
  537. #ifdef CONFIG_TRACING
  538. /* flags for current->trace */
  539. enum {
  540. TSK_TRACE_FL_TRACE_BIT = 0,
  541. TSK_TRACE_FL_GRAPH_BIT = 1,
  542. };
  543. enum {
  544. TSK_TRACE_FL_TRACE = 1 << TSK_TRACE_FL_TRACE_BIT,
  545. TSK_TRACE_FL_GRAPH = 1 << TSK_TRACE_FL_GRAPH_BIT,
  546. };
  547. static inline void set_tsk_trace_trace(struct task_struct *tsk)
  548. {
  549. set_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
  550. }
  551. static inline void clear_tsk_trace_trace(struct task_struct *tsk)
  552. {
  553. clear_bit(TSK_TRACE_FL_TRACE_BIT, &tsk->trace);
  554. }
  555. static inline int test_tsk_trace_trace(struct task_struct *tsk)
  556. {
  557. return tsk->trace & TSK_TRACE_FL_TRACE;
  558. }
  559. static inline void set_tsk_trace_graph(struct task_struct *tsk)
  560. {
  561. set_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
  562. }
  563. static inline void clear_tsk_trace_graph(struct task_struct *tsk)
  564. {
  565. clear_bit(TSK_TRACE_FL_GRAPH_BIT, &tsk->trace);
  566. }
  567. static inline int test_tsk_trace_graph(struct task_struct *tsk)
  568. {
  569. return tsk->trace & TSK_TRACE_FL_GRAPH;
  570. }
  571. enum ftrace_dump_mode;
  572. extern enum ftrace_dump_mode ftrace_dump_on_oops;
  573. #ifdef CONFIG_PREEMPT
  574. #define INIT_TRACE_RECURSION .trace_recursion = 0,
  575. #endif
  576. #endif /* CONFIG_TRACING */
  577. #ifndef INIT_TRACE_RECURSION
  578. #define INIT_TRACE_RECURSION
  579. #endif
  580. #ifdef CONFIG_FTRACE_SYSCALLS
  581. unsigned long arch_syscall_addr(int nr);
  582. #endif /* CONFIG_FTRACE_SYSCALLS */
  583. #endif /* _LINUX_FTRACE_H */