trace_events.h 19 KB

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