ftrace_event.h 18 KB

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