ftrace.h 20 KB

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