ftrace_event.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. #ifndef _LINUX_FTRACE_EVENT_H
  2. #define _LINUX_FTRACE_EVENT_H
  3. #include <linux/ring_buffer.h>
  4. #include <linux/trace_seq.h>
  5. #include <linux/percpu.h>
  6. #include <linux/hardirq.h>
  7. #include <linux/perf_event.h>
  8. #include <linux/tracepoint.h>
  9. struct trace_array;
  10. struct trace_buffer;
  11. struct tracer;
  12. struct dentry;
  13. struct trace_print_flags {
  14. unsigned long mask;
  15. const char *name;
  16. };
  17. struct trace_print_flags_u64 {
  18. unsigned long long mask;
  19. const char *name;
  20. };
  21. const char *ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
  22. unsigned long flags,
  23. const struct trace_print_flags *flag_array);
  24. const char *ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
  25. const struct trace_print_flags *symbol_array);
  26. #if BITS_PER_LONG == 32
  27. const char *ftrace_print_symbols_seq_u64(struct trace_seq *p,
  28. unsigned long long val,
  29. const struct trace_print_flags_u64
  30. *symbol_array);
  31. #endif
  32. const char *ftrace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
  33. unsigned int bitmask_size);
  34. const char *ftrace_print_hex_seq(struct trace_seq *p,
  35. const unsigned char *buf, int len);
  36. const char *ftrace_print_array_seq(struct trace_seq *p,
  37. const void *buf, int buf_len,
  38. size_t el_size);
  39. struct trace_iterator;
  40. struct trace_event;
  41. int ftrace_raw_output_prep(struct trace_iterator *iter,
  42. struct trace_event *event);
  43. /*
  44. * The trace entry - the most basic unit of tracing. This is what
  45. * is printed in the end as a single line in the trace output, such as:
  46. *
  47. * bash-15816 [01] 235.197585: idle_cpu <- irq_enter
  48. */
  49. struct trace_entry {
  50. unsigned short type;
  51. unsigned char flags;
  52. unsigned char preempt_count;
  53. int pid;
  54. };
  55. #define FTRACE_MAX_EVENT \
  56. ((1 << (sizeof(((struct trace_entry *)0)->type) * 8)) - 1)
  57. /*
  58. * Trace iterator - used by printout routines who present trace
  59. * results to users and which routines might sleep, etc:
  60. */
  61. struct trace_iterator {
  62. struct trace_array *tr;
  63. struct tracer *trace;
  64. struct trace_buffer *trace_buffer;
  65. void *private;
  66. int cpu_file;
  67. struct mutex mutex;
  68. struct ring_buffer_iter **buffer_iter;
  69. unsigned long iter_flags;
  70. /* trace_seq for __print_flags() and __print_symbolic() etc. */
  71. struct trace_seq tmp_seq;
  72. cpumask_var_t started;
  73. /* it's true when current open file is snapshot */
  74. bool snapshot;
  75. /* The below is zeroed out in pipe_read */
  76. struct trace_seq seq;
  77. struct trace_entry *ent;
  78. unsigned long lost_events;
  79. int leftover;
  80. int ent_size;
  81. int cpu;
  82. u64 ts;
  83. loff_t pos;
  84. long idx;
  85. /* All new field here will be zeroed out in pipe_read */
  86. };
  87. enum trace_iter_flags {
  88. TRACE_FILE_LAT_FMT = 1,
  89. TRACE_FILE_ANNOTATE = 2,
  90. TRACE_FILE_TIME_IN_NS = 4,
  91. };
  92. typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter,
  93. int flags, struct trace_event *event);
  94. struct trace_event_functions {
  95. trace_print_func trace;
  96. trace_print_func raw;
  97. trace_print_func hex;
  98. trace_print_func binary;
  99. };
  100. struct trace_event {
  101. struct hlist_node node;
  102. struct list_head list;
  103. int type;
  104. struct trace_event_functions *funcs;
  105. };
  106. extern int register_ftrace_event(struct trace_event *event);
  107. extern int unregister_ftrace_event(struct trace_event *event);
  108. /* Return values for print_line callback */
  109. enum print_line_t {
  110. TRACE_TYPE_PARTIAL_LINE = 0, /* Retry after flushing the seq */
  111. TRACE_TYPE_HANDLED = 1,
  112. TRACE_TYPE_UNHANDLED = 2, /* Relay to other output functions */
  113. TRACE_TYPE_NO_CONSUME = 3 /* Handled but ask to not consume */
  114. };
  115. /*
  116. * Several functions return TRACE_TYPE_PARTIAL_LINE if the trace_seq
  117. * overflowed, and TRACE_TYPE_HANDLED otherwise. This helper function
  118. * simplifies those functions and keeps them in sync.
  119. */
  120. static inline enum print_line_t trace_handle_return(struct trace_seq *s)
  121. {
  122. return trace_seq_has_overflowed(s) ?
  123. TRACE_TYPE_PARTIAL_LINE : TRACE_TYPE_HANDLED;
  124. }
  125. void tracing_generic_entry_update(struct trace_entry *entry,
  126. unsigned long flags,
  127. int pc);
  128. struct ftrace_event_file;
  129. struct ring_buffer_event *
  130. trace_event_buffer_lock_reserve(struct ring_buffer **current_buffer,
  131. struct ftrace_event_file *ftrace_file,
  132. int type, unsigned long len,
  133. unsigned long flags, int pc);
  134. struct ring_buffer_event *
  135. trace_current_buffer_lock_reserve(struct ring_buffer **current_buffer,
  136. int type, unsigned long len,
  137. unsigned long flags, int pc);
  138. void trace_current_buffer_unlock_commit(struct ring_buffer *buffer,
  139. struct ring_buffer_event *event,
  140. unsigned long flags, int pc);
  141. void trace_buffer_unlock_commit(struct ring_buffer *buffer,
  142. struct ring_buffer_event *event,
  143. unsigned long flags, int pc);
  144. void trace_buffer_unlock_commit_regs(struct ring_buffer *buffer,
  145. struct ring_buffer_event *event,
  146. unsigned long flags, int pc,
  147. struct pt_regs *regs);
  148. void trace_current_buffer_discard_commit(struct ring_buffer *buffer,
  149. struct ring_buffer_event *event);
  150. void tracing_record_cmdline(struct task_struct *tsk);
  151. int ftrace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...);
  152. struct event_filter;
  153. enum trace_reg {
  154. TRACE_REG_REGISTER,
  155. TRACE_REG_UNREGISTER,
  156. #ifdef CONFIG_PERF_EVENTS
  157. TRACE_REG_PERF_REGISTER,
  158. TRACE_REG_PERF_UNREGISTER,
  159. TRACE_REG_PERF_OPEN,
  160. TRACE_REG_PERF_CLOSE,
  161. TRACE_REG_PERF_ADD,
  162. TRACE_REG_PERF_DEL,
  163. #endif
  164. };
  165. struct ftrace_event_call;
  166. struct ftrace_event_class {
  167. const char *system;
  168. void *probe;
  169. #ifdef CONFIG_PERF_EVENTS
  170. void *perf_probe;
  171. #endif
  172. int (*reg)(struct ftrace_event_call *event,
  173. enum trace_reg type, void *data);
  174. int (*define_fields)(struct ftrace_event_call *);
  175. struct list_head *(*get_fields)(struct ftrace_event_call *);
  176. struct list_head fields;
  177. int (*raw_init)(struct ftrace_event_call *);
  178. };
  179. extern int ftrace_event_reg(struct ftrace_event_call *event,
  180. enum trace_reg type, void *data);
  181. int ftrace_output_event(struct trace_iterator *iter, struct ftrace_event_call *event,
  182. char *fmt, ...);
  183. int ftrace_event_define_field(struct ftrace_event_call *call,
  184. char *type, int len, char *item, int offset,
  185. int field_size, int sign, int filter);
  186. struct ftrace_event_buffer {
  187. struct ring_buffer *buffer;
  188. struct ring_buffer_event *event;
  189. struct ftrace_event_file *ftrace_file;
  190. void *entry;
  191. unsigned long flags;
  192. int pc;
  193. };
  194. void *ftrace_event_buffer_reserve(struct ftrace_event_buffer *fbuffer,
  195. struct ftrace_event_file *ftrace_file,
  196. unsigned long len);
  197. void ftrace_event_buffer_commit(struct ftrace_event_buffer *fbuffer);
  198. int ftrace_event_define_field(struct ftrace_event_call *call,
  199. char *type, int len, char *item, int offset,
  200. int field_size, int sign, int filter);
  201. enum {
  202. TRACE_EVENT_FL_FILTERED_BIT,
  203. TRACE_EVENT_FL_CAP_ANY_BIT,
  204. TRACE_EVENT_FL_NO_SET_FILTER_BIT,
  205. TRACE_EVENT_FL_IGNORE_ENABLE_BIT,
  206. TRACE_EVENT_FL_WAS_ENABLED_BIT,
  207. TRACE_EVENT_FL_USE_CALL_FILTER_BIT,
  208. TRACE_EVENT_FL_TRACEPOINT_BIT,
  209. };
  210. /*
  211. * Event flags:
  212. * FILTERED - The event has a filter attached
  213. * CAP_ANY - Any user can enable for perf
  214. * NO_SET_FILTER - Set when filter has error and is to be ignored
  215. * IGNORE_ENABLE - For ftrace internal events, do not enable with debugfs file
  216. * WAS_ENABLED - Set and stays set when an event was ever enabled
  217. * (used for module unloading, if a module event is enabled,
  218. * it is best to clear the buffers that used it).
  219. * USE_CALL_FILTER - For ftrace internal events, don't use file filter
  220. * TRACEPOINT - Event is a tracepoint
  221. */
  222. enum {
  223. TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT),
  224. TRACE_EVENT_FL_CAP_ANY = (1 << TRACE_EVENT_FL_CAP_ANY_BIT),
  225. TRACE_EVENT_FL_NO_SET_FILTER = (1 << TRACE_EVENT_FL_NO_SET_FILTER_BIT),
  226. TRACE_EVENT_FL_IGNORE_ENABLE = (1 << TRACE_EVENT_FL_IGNORE_ENABLE_BIT),
  227. TRACE_EVENT_FL_WAS_ENABLED = (1 << TRACE_EVENT_FL_WAS_ENABLED_BIT),
  228. TRACE_EVENT_FL_USE_CALL_FILTER = (1 << TRACE_EVENT_FL_USE_CALL_FILTER_BIT),
  229. TRACE_EVENT_FL_TRACEPOINT = (1 << TRACE_EVENT_FL_TRACEPOINT_BIT),
  230. };
  231. struct ftrace_event_call {
  232. struct list_head list;
  233. struct ftrace_event_class *class;
  234. union {
  235. char *name;
  236. /* Set TRACE_EVENT_FL_TRACEPOINT flag when using "tp" */
  237. struct tracepoint *tp;
  238. };
  239. struct trace_event event;
  240. char *print_fmt;
  241. struct event_filter *filter;
  242. void *mod;
  243. void *data;
  244. /*
  245. * bit 0: filter_active
  246. * bit 1: allow trace by non root (cap any)
  247. * bit 2: failed to apply filter
  248. * bit 3: ftrace internal event (do not enable)
  249. * bit 4: Event was enabled by module
  250. * bit 5: use call filter rather than file filter
  251. * bit 6: Event is a tracepoint
  252. */
  253. int flags; /* static flags of different events */
  254. #ifdef CONFIG_PERF_EVENTS
  255. int perf_refcount;
  256. struct hlist_head __percpu *perf_events;
  257. int (*perf_perm)(struct ftrace_event_call *,
  258. struct perf_event *);
  259. #endif
  260. };
  261. static inline const char *
  262. ftrace_event_name(struct ftrace_event_call *call)
  263. {
  264. if (call->flags & TRACE_EVENT_FL_TRACEPOINT)
  265. return call->tp ? call->tp->name : NULL;
  266. else
  267. return call->name;
  268. }
  269. struct trace_array;
  270. struct ftrace_subsystem_dir;
  271. enum {
  272. FTRACE_EVENT_FL_ENABLED_BIT,
  273. FTRACE_EVENT_FL_RECORDED_CMD_BIT,
  274. FTRACE_EVENT_FL_FILTERED_BIT,
  275. FTRACE_EVENT_FL_NO_SET_FILTER_BIT,
  276. FTRACE_EVENT_FL_SOFT_MODE_BIT,
  277. FTRACE_EVENT_FL_SOFT_DISABLED_BIT,
  278. FTRACE_EVENT_FL_TRIGGER_MODE_BIT,
  279. FTRACE_EVENT_FL_TRIGGER_COND_BIT,
  280. };
  281. /*
  282. * Ftrace event file flags:
  283. * ENABLED - The event is enabled
  284. * RECORDED_CMD - The comms should be recorded at sched_switch
  285. * FILTERED - The event has a filter attached
  286. * NO_SET_FILTER - Set when filter has error and is to be ignored
  287. * SOFT_MODE - The event is enabled/disabled by SOFT_DISABLED
  288. * SOFT_DISABLED - When set, do not trace the event (even though its
  289. * tracepoint may be enabled)
  290. * TRIGGER_MODE - When set, invoke the triggers associated with the event
  291. * TRIGGER_COND - When set, one or more triggers has an associated filter
  292. */
  293. enum {
  294. FTRACE_EVENT_FL_ENABLED = (1 << FTRACE_EVENT_FL_ENABLED_BIT),
  295. FTRACE_EVENT_FL_RECORDED_CMD = (1 << FTRACE_EVENT_FL_RECORDED_CMD_BIT),
  296. FTRACE_EVENT_FL_FILTERED = (1 << FTRACE_EVENT_FL_FILTERED_BIT),
  297. FTRACE_EVENT_FL_NO_SET_FILTER = (1 << FTRACE_EVENT_FL_NO_SET_FILTER_BIT),
  298. FTRACE_EVENT_FL_SOFT_MODE = (1 << FTRACE_EVENT_FL_SOFT_MODE_BIT),
  299. FTRACE_EVENT_FL_SOFT_DISABLED = (1 << FTRACE_EVENT_FL_SOFT_DISABLED_BIT),
  300. FTRACE_EVENT_FL_TRIGGER_MODE = (1 << FTRACE_EVENT_FL_TRIGGER_MODE_BIT),
  301. FTRACE_EVENT_FL_TRIGGER_COND = (1 << FTRACE_EVENT_FL_TRIGGER_COND_BIT),
  302. };
  303. struct ftrace_event_file {
  304. struct list_head list;
  305. struct ftrace_event_call *event_call;
  306. struct event_filter *filter;
  307. struct dentry *dir;
  308. struct trace_array *tr;
  309. struct ftrace_subsystem_dir *system;
  310. struct list_head triggers;
  311. /*
  312. * 32 bit flags:
  313. * bit 0: enabled
  314. * bit 1: enabled cmd record
  315. * bit 2: enable/disable with the soft disable bit
  316. * bit 3: soft disabled
  317. * bit 4: trigger enabled
  318. *
  319. * Note: The bits must be set atomically to prevent races
  320. * from other writers. Reads of flags do not need to be in
  321. * sync as they occur in critical sections. But the way flags
  322. * is currently used, these changes do not affect the code
  323. * except that when a change is made, it may have a slight
  324. * delay in propagating the changes to other CPUs due to
  325. * caching and such. Which is mostly OK ;-)
  326. */
  327. unsigned long flags;
  328. atomic_t sm_ref; /* soft-mode reference counter */
  329. atomic_t tm_ref; /* trigger-mode reference counter */
  330. };
  331. #define __TRACE_EVENT_FLAGS(name, value) \
  332. static int __init trace_init_flags_##name(void) \
  333. { \
  334. event_##name.flags |= value; \
  335. return 0; \
  336. } \
  337. early_initcall(trace_init_flags_##name);
  338. #define __TRACE_EVENT_PERF_PERM(name, expr...) \
  339. static int perf_perm_##name(struct ftrace_event_call *tp_event, \
  340. struct perf_event *p_event) \
  341. { \
  342. return ({ expr; }); \
  343. } \
  344. static int __init trace_init_perf_perm_##name(void) \
  345. { \
  346. event_##name.perf_perm = &perf_perm_##name; \
  347. return 0; \
  348. } \
  349. early_initcall(trace_init_perf_perm_##name);
  350. #define PERF_MAX_TRACE_SIZE 2048
  351. #define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */
  352. enum event_trigger_type {
  353. ETT_NONE = (0),
  354. ETT_TRACE_ONOFF = (1 << 0),
  355. ETT_SNAPSHOT = (1 << 1),
  356. ETT_STACKTRACE = (1 << 2),
  357. ETT_EVENT_ENABLE = (1 << 3),
  358. };
  359. extern int filter_match_preds(struct event_filter *filter, void *rec);
  360. extern int filter_check_discard(struct ftrace_event_file *file, void *rec,
  361. struct ring_buffer *buffer,
  362. struct ring_buffer_event *event);
  363. extern int call_filter_check_discard(struct ftrace_event_call *call, void *rec,
  364. struct ring_buffer *buffer,
  365. struct ring_buffer_event *event);
  366. extern enum event_trigger_type event_triggers_call(struct ftrace_event_file *file,
  367. void *rec);
  368. extern void event_triggers_post_call(struct ftrace_event_file *file,
  369. enum event_trigger_type tt);
  370. /**
  371. * ftrace_trigger_soft_disabled - do triggers and test if soft disabled
  372. * @file: The file pointer of the event to test
  373. *
  374. * If any triggers without filters are attached to this event, they
  375. * will be called here. If the event is soft disabled and has no
  376. * triggers that require testing the fields, it will return true,
  377. * otherwise false.
  378. */
  379. static inline bool
  380. ftrace_trigger_soft_disabled(struct ftrace_event_file *file)
  381. {
  382. unsigned long eflags = file->flags;
  383. if (!(eflags & FTRACE_EVENT_FL_TRIGGER_COND)) {
  384. if (eflags & FTRACE_EVENT_FL_TRIGGER_MODE)
  385. event_triggers_call(file, NULL);
  386. if (eflags & FTRACE_EVENT_FL_SOFT_DISABLED)
  387. return true;
  388. }
  389. return false;
  390. }
  391. /*
  392. * Helper function for event_trigger_unlock_commit{_regs}().
  393. * If there are event triggers attached to this event that requires
  394. * filtering against its fields, then they wil be called as the
  395. * entry already holds the field information of the current event.
  396. *
  397. * It also checks if the event should be discarded or not.
  398. * It is to be discarded if the event is soft disabled and the
  399. * event was only recorded to process triggers, or if the event
  400. * filter is active and this event did not match the filters.
  401. *
  402. * Returns true if the event is discarded, false otherwise.
  403. */
  404. static inline bool
  405. __event_trigger_test_discard(struct ftrace_event_file *file,
  406. struct ring_buffer *buffer,
  407. struct ring_buffer_event *event,
  408. void *entry,
  409. enum event_trigger_type *tt)
  410. {
  411. unsigned long eflags = file->flags;
  412. if (eflags & FTRACE_EVENT_FL_TRIGGER_COND)
  413. *tt = event_triggers_call(file, entry);
  414. if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &file->flags))
  415. ring_buffer_discard_commit(buffer, event);
  416. else if (!filter_check_discard(file, entry, buffer, event))
  417. return false;
  418. return true;
  419. }
  420. /**
  421. * event_trigger_unlock_commit - handle triggers and finish event commit
  422. * @file: The file pointer assoctiated to the event
  423. * @buffer: The ring buffer that the event is being written to
  424. * @event: The event meta data in the ring buffer
  425. * @entry: The event itself
  426. * @irq_flags: The state of the interrupts at the start of the event
  427. * @pc: The state of the preempt count at the start of the event.
  428. *
  429. * This is a helper function to handle triggers that require data
  430. * from the event itself. It also tests the event against filters and
  431. * if the event is soft disabled and should be discarded.
  432. */
  433. static inline void
  434. event_trigger_unlock_commit(struct ftrace_event_file *file,
  435. struct ring_buffer *buffer,
  436. struct ring_buffer_event *event,
  437. void *entry, unsigned long irq_flags, int pc)
  438. {
  439. enum event_trigger_type tt = ETT_NONE;
  440. if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
  441. trace_buffer_unlock_commit(buffer, event, irq_flags, pc);
  442. if (tt)
  443. event_triggers_post_call(file, tt);
  444. }
  445. /**
  446. * event_trigger_unlock_commit_regs - handle triggers and finish event commit
  447. * @file: The file pointer assoctiated to the event
  448. * @buffer: The ring buffer that the event is being written to
  449. * @event: The event meta data in the ring buffer
  450. * @entry: The event itself
  451. * @irq_flags: The state of the interrupts at the start of the event
  452. * @pc: The state of the preempt count at the start of the event.
  453. *
  454. * This is a helper function to handle triggers that require data
  455. * from the event itself. It also tests the event against filters and
  456. * if the event is soft disabled and should be discarded.
  457. *
  458. * Same as event_trigger_unlock_commit() but calls
  459. * trace_buffer_unlock_commit_regs() instead of trace_buffer_unlock_commit().
  460. */
  461. static inline void
  462. event_trigger_unlock_commit_regs(struct ftrace_event_file *file,
  463. struct ring_buffer *buffer,
  464. struct ring_buffer_event *event,
  465. void *entry, unsigned long irq_flags, int pc,
  466. struct pt_regs *regs)
  467. {
  468. enum event_trigger_type tt = ETT_NONE;
  469. if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
  470. trace_buffer_unlock_commit_regs(buffer, event,
  471. irq_flags, pc, regs);
  472. if (tt)
  473. event_triggers_post_call(file, tt);
  474. }
  475. enum {
  476. FILTER_OTHER = 0,
  477. FILTER_STATIC_STRING,
  478. FILTER_DYN_STRING,
  479. FILTER_PTR_STRING,
  480. FILTER_TRACE_FN,
  481. };
  482. extern int trace_event_raw_init(struct ftrace_event_call *call);
  483. extern int trace_define_field(struct ftrace_event_call *call, const char *type,
  484. const char *name, int offset, int size,
  485. int is_signed, int filter_type);
  486. extern int trace_add_event_call(struct ftrace_event_call *call);
  487. extern int trace_remove_event_call(struct ftrace_event_call *call);
  488. #define is_signed_type(type) (((type)(-1)) < (type)1)
  489. int trace_set_clr_event(const char *system, const char *event, int set);
  490. /*
  491. * The double __builtin_constant_p is because gcc will give us an error
  492. * if we try to allocate the static variable to fmt if it is not a
  493. * constant. Even with the outer if statement optimizing out.
  494. */
  495. #define event_trace_printk(ip, fmt, args...) \
  496. do { \
  497. __trace_printk_check_format(fmt, ##args); \
  498. tracing_record_cmdline(current); \
  499. if (__builtin_constant_p(fmt)) { \
  500. static const char *trace_printk_fmt \
  501. __attribute__((section("__trace_printk_fmt"))) = \
  502. __builtin_constant_p(fmt) ? fmt : NULL; \
  503. \
  504. __trace_bprintk(ip, trace_printk_fmt, ##args); \
  505. } else \
  506. __trace_printk(ip, fmt, ##args); \
  507. } while (0)
  508. #ifdef CONFIG_PERF_EVENTS
  509. struct perf_event;
  510. DECLARE_PER_CPU(struct pt_regs, perf_trace_regs);
  511. extern int perf_trace_init(struct perf_event *event);
  512. extern void perf_trace_destroy(struct perf_event *event);
  513. extern int perf_trace_add(struct perf_event *event, int flags);
  514. extern void perf_trace_del(struct perf_event *event, int flags);
  515. extern int ftrace_profile_set_filter(struct perf_event *event, int event_id,
  516. char *filter_str);
  517. extern void ftrace_profile_free_filter(struct perf_event *event);
  518. extern void *perf_trace_buf_prepare(int size, unsigned short type,
  519. struct pt_regs **regs, int *rctxp);
  520. static inline void
  521. perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr,
  522. u64 count, struct pt_regs *regs, void *head,
  523. struct task_struct *task)
  524. {
  525. perf_tp_event(addr, count, raw_data, size, regs, head, rctx, task);
  526. }
  527. #endif
  528. #endif /* _LINUX_FTRACE_EVENT_H */