trace.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. #ifndef _LINUX_KERNEL_TRACE_H
  2. #define _LINUX_KERNEL_TRACE_H
  3. #include <linux/fs.h>
  4. #include <linux/atomic.h>
  5. #include <linux/sched.h>
  6. #include <linux/clocksource.h>
  7. #include <linux/ring_buffer.h>
  8. #include <linux/mmiotrace.h>
  9. #include <linux/tracepoint.h>
  10. #include <linux/ftrace.h>
  11. #include <linux/hw_breakpoint.h>
  12. #include <linux/trace_seq.h>
  13. #include <linux/ftrace_event.h>
  14. #ifdef CONFIG_FTRACE_SYSCALLS
  15. #include <asm/unistd.h> /* For NR_SYSCALLS */
  16. #include <asm/syscall.h> /* some archs define it here */
  17. #endif
  18. enum trace_type {
  19. __TRACE_FIRST_TYPE = 0,
  20. TRACE_FN,
  21. TRACE_CTX,
  22. TRACE_WAKE,
  23. TRACE_STACK,
  24. TRACE_PRINT,
  25. TRACE_BPRINT,
  26. TRACE_MMIO_RW,
  27. TRACE_MMIO_MAP,
  28. TRACE_BRANCH,
  29. TRACE_GRAPH_RET,
  30. TRACE_GRAPH_ENT,
  31. TRACE_USER_STACK,
  32. TRACE_BLK,
  33. TRACE_BPUTS,
  34. __TRACE_LAST_TYPE,
  35. };
  36. #undef __field
  37. #define __field(type, item) type item;
  38. #undef __field_struct
  39. #define __field_struct(type, item) __field(type, item)
  40. #undef __field_desc
  41. #define __field_desc(type, container, item)
  42. #undef __array
  43. #define __array(type, item, size) type item[size];
  44. #undef __array_desc
  45. #define __array_desc(type, container, item, size)
  46. #undef __dynamic_array
  47. #define __dynamic_array(type, item) type item[];
  48. #undef F_STRUCT
  49. #define F_STRUCT(args...) args
  50. #undef FTRACE_ENTRY
  51. #define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
  52. struct struct_name { \
  53. struct trace_entry ent; \
  54. tstruct \
  55. }
  56. #undef TP_ARGS
  57. #define TP_ARGS(args...) args
  58. #undef FTRACE_ENTRY_DUP
  59. #define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk, filter)
  60. #undef FTRACE_ENTRY_REG
  61. #define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, \
  62. filter, regfn) \
  63. FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
  64. filter)
  65. #include "trace_entries.h"
  66. /*
  67. * syscalls are special, and need special handling, this is why
  68. * they are not included in trace_entries.h
  69. */
  70. struct syscall_trace_enter {
  71. struct trace_entry ent;
  72. int nr;
  73. unsigned long args[];
  74. };
  75. struct syscall_trace_exit {
  76. struct trace_entry ent;
  77. int nr;
  78. long ret;
  79. };
  80. struct kprobe_trace_entry_head {
  81. struct trace_entry ent;
  82. unsigned long ip;
  83. };
  84. struct kretprobe_trace_entry_head {
  85. struct trace_entry ent;
  86. unsigned long func;
  87. unsigned long ret_ip;
  88. };
  89. /*
  90. * trace_flag_type is an enumeration that holds different
  91. * states when a trace occurs. These are:
  92. * IRQS_OFF - interrupts were disabled
  93. * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags
  94. * NEED_RESCHED - reschedule is requested
  95. * HARDIRQ - inside an interrupt handler
  96. * SOFTIRQ - inside a softirq handler
  97. */
  98. enum trace_flag_type {
  99. TRACE_FLAG_IRQS_OFF = 0x01,
  100. TRACE_FLAG_IRQS_NOSUPPORT = 0x02,
  101. TRACE_FLAG_NEED_RESCHED = 0x04,
  102. TRACE_FLAG_HARDIRQ = 0x08,
  103. TRACE_FLAG_SOFTIRQ = 0x10,
  104. TRACE_FLAG_PREEMPT_RESCHED = 0x20,
  105. };
  106. #define TRACE_BUF_SIZE 1024
  107. struct trace_array;
  108. /*
  109. * The CPU trace array - it consists of thousands of trace entries
  110. * plus some other descriptor data: (for example which task started
  111. * the trace, etc.)
  112. */
  113. struct trace_array_cpu {
  114. atomic_t disabled;
  115. void *buffer_page; /* ring buffer spare */
  116. unsigned long entries;
  117. unsigned long saved_latency;
  118. unsigned long critical_start;
  119. unsigned long critical_end;
  120. unsigned long critical_sequence;
  121. unsigned long nice;
  122. unsigned long policy;
  123. unsigned long rt_priority;
  124. unsigned long skipped_entries;
  125. cycle_t preempt_timestamp;
  126. pid_t pid;
  127. kuid_t uid;
  128. char comm[TASK_COMM_LEN];
  129. };
  130. struct tracer;
  131. struct trace_buffer {
  132. struct trace_array *tr;
  133. struct ring_buffer *buffer;
  134. struct trace_array_cpu __percpu *data;
  135. cycle_t time_start;
  136. int cpu;
  137. };
  138. /*
  139. * The trace array - an array of per-CPU trace arrays. This is the
  140. * highest level data structure that individual tracers deal with.
  141. * They have on/off state as well:
  142. */
  143. struct trace_array {
  144. struct list_head list;
  145. char *name;
  146. struct trace_buffer trace_buffer;
  147. #ifdef CONFIG_TRACER_MAX_TRACE
  148. /*
  149. * The max_buffer is used to snapshot the trace when a maximum
  150. * latency is reached, or when the user initiates a snapshot.
  151. * Some tracers will use this to store a maximum trace while
  152. * it continues examining live traces.
  153. *
  154. * The buffers for the max_buffer are set up the same as the trace_buffer
  155. * When a snapshot is taken, the buffer of the max_buffer is swapped
  156. * with the buffer of the trace_buffer and the buffers are reset for
  157. * the trace_buffer so the tracing can continue.
  158. */
  159. struct trace_buffer max_buffer;
  160. bool allocated_snapshot;
  161. #endif
  162. int buffer_disabled;
  163. #ifdef CONFIG_FTRACE_SYSCALLS
  164. int sys_refcount_enter;
  165. int sys_refcount_exit;
  166. struct ftrace_event_file __rcu *enter_syscall_files[NR_syscalls];
  167. struct ftrace_event_file __rcu *exit_syscall_files[NR_syscalls];
  168. #endif
  169. int stop_count;
  170. int clock_id;
  171. struct tracer *current_trace;
  172. unsigned int flags;
  173. raw_spinlock_t start_lock;
  174. struct dentry *dir;
  175. struct dentry *options;
  176. struct dentry *percpu_dir;
  177. struct dentry *event_dir;
  178. struct list_head systems;
  179. struct list_head events;
  180. cpumask_var_t tracing_cpumask; /* only trace on set CPUs */
  181. int ref;
  182. };
  183. enum {
  184. TRACE_ARRAY_FL_GLOBAL = (1 << 0)
  185. };
  186. extern struct list_head ftrace_trace_arrays;
  187. extern struct mutex trace_types_lock;
  188. extern int trace_array_get(struct trace_array *tr);
  189. extern void trace_array_put(struct trace_array *tr);
  190. /*
  191. * The global tracer (top) should be the first trace array added,
  192. * but we check the flag anyway.
  193. */
  194. static inline struct trace_array *top_trace_array(void)
  195. {
  196. struct trace_array *tr;
  197. tr = list_entry(ftrace_trace_arrays.prev,
  198. typeof(*tr), list);
  199. WARN_ON(!(tr->flags & TRACE_ARRAY_FL_GLOBAL));
  200. return tr;
  201. }
  202. #define FTRACE_CMP_TYPE(var, type) \
  203. __builtin_types_compatible_p(typeof(var), type *)
  204. #undef IF_ASSIGN
  205. #define IF_ASSIGN(var, entry, etype, id) \
  206. if (FTRACE_CMP_TYPE(var, etype)) { \
  207. var = (typeof(var))(entry); \
  208. WARN_ON(id && (entry)->type != id); \
  209. break; \
  210. }
  211. /* Will cause compile errors if type is not found. */
  212. extern void __ftrace_bad_type(void);
  213. /*
  214. * The trace_assign_type is a verifier that the entry type is
  215. * the same as the type being assigned. To add new types simply
  216. * add a line with the following format:
  217. *
  218. * IF_ASSIGN(var, ent, type, id);
  219. *
  220. * Where "type" is the trace type that includes the trace_entry
  221. * as the "ent" item. And "id" is the trace identifier that is
  222. * used in the trace_type enum.
  223. *
  224. * If the type can have more than one id, then use zero.
  225. */
  226. #define trace_assign_type(var, ent) \
  227. do { \
  228. IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN); \
  229. IF_ASSIGN(var, ent, struct ctx_switch_entry, 0); \
  230. IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \
  231. IF_ASSIGN(var, ent, struct userstack_entry, TRACE_USER_STACK);\
  232. IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \
  233. IF_ASSIGN(var, ent, struct bprint_entry, TRACE_BPRINT); \
  234. IF_ASSIGN(var, ent, struct bputs_entry, TRACE_BPUTS); \
  235. IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \
  236. TRACE_MMIO_RW); \
  237. IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \
  238. TRACE_MMIO_MAP); \
  239. IF_ASSIGN(var, ent, struct trace_branch, TRACE_BRANCH); \
  240. IF_ASSIGN(var, ent, struct ftrace_graph_ent_entry, \
  241. TRACE_GRAPH_ENT); \
  242. IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \
  243. TRACE_GRAPH_RET); \
  244. __ftrace_bad_type(); \
  245. } while (0)
  246. /*
  247. * An option specific to a tracer. This is a boolean value.
  248. * The bit is the bit index that sets its value on the
  249. * flags value in struct tracer_flags.
  250. */
  251. struct tracer_opt {
  252. const char *name; /* Will appear on the trace_options file */
  253. u32 bit; /* Mask assigned in val field in tracer_flags */
  254. };
  255. /*
  256. * The set of specific options for a tracer. Your tracer
  257. * have to set the initial value of the flags val.
  258. */
  259. struct tracer_flags {
  260. u32 val;
  261. struct tracer_opt *opts;
  262. };
  263. /* Makes more easy to define a tracer opt */
  264. #define TRACER_OPT(s, b) .name = #s, .bit = b
  265. /**
  266. * struct tracer - a specific tracer and its callbacks to interact with debugfs
  267. * @name: the name chosen to select it on the available_tracers file
  268. * @init: called when one switches to this tracer (echo name > current_tracer)
  269. * @reset: called when one switches to another tracer
  270. * @start: called when tracing is unpaused (echo 1 > tracing_enabled)
  271. * @stop: called when tracing is paused (echo 0 > tracing_enabled)
  272. * @open: called when the trace file is opened
  273. * @pipe_open: called when the trace_pipe file is opened
  274. * @wait_pipe: override how the user waits for traces on trace_pipe
  275. * @close: called when the trace file is released
  276. * @pipe_close: called when the trace_pipe file is released
  277. * @read: override the default read callback on trace_pipe
  278. * @splice_read: override the default splice_read callback on trace_pipe
  279. * @selftest: selftest to run on boot (see trace_selftest.c)
  280. * @print_headers: override the first lines that describe your columns
  281. * @print_line: callback that prints a trace
  282. * @set_flag: signals one of your private flags changed (trace_options file)
  283. * @flags: your private flags
  284. */
  285. struct tracer {
  286. const char *name;
  287. int (*init)(struct trace_array *tr);
  288. void (*reset)(struct trace_array *tr);
  289. void (*start)(struct trace_array *tr);
  290. void (*stop)(struct trace_array *tr);
  291. void (*open)(struct trace_iterator *iter);
  292. void (*pipe_open)(struct trace_iterator *iter);
  293. void (*wait_pipe)(struct trace_iterator *iter);
  294. void (*close)(struct trace_iterator *iter);
  295. void (*pipe_close)(struct trace_iterator *iter);
  296. ssize_t (*read)(struct trace_iterator *iter,
  297. struct file *filp, char __user *ubuf,
  298. size_t cnt, loff_t *ppos);
  299. ssize_t (*splice_read)(struct trace_iterator *iter,
  300. struct file *filp,
  301. loff_t *ppos,
  302. struct pipe_inode_info *pipe,
  303. size_t len,
  304. unsigned int flags);
  305. #ifdef CONFIG_FTRACE_STARTUP_TEST
  306. int (*selftest)(struct tracer *trace,
  307. struct trace_array *tr);
  308. #endif
  309. void (*print_header)(struct seq_file *m);
  310. enum print_line_t (*print_line)(struct trace_iterator *iter);
  311. /* If you handled the flag setting, return 0 */
  312. int (*set_flag)(u32 old_flags, u32 bit, int set);
  313. /* Return 0 if OK with change, else return non-zero */
  314. int (*flag_changed)(struct tracer *tracer,
  315. u32 mask, int set);
  316. struct tracer *next;
  317. struct tracer_flags *flags;
  318. bool print_max;
  319. bool enabled;
  320. #ifdef CONFIG_TRACER_MAX_TRACE
  321. bool use_max_tr;
  322. #endif
  323. };
  324. /* Only current can touch trace_recursion */
  325. /*
  326. * For function tracing recursion:
  327. * The order of these bits are important.
  328. *
  329. * When function tracing occurs, the following steps are made:
  330. * If arch does not support a ftrace feature:
  331. * call internal function (uses INTERNAL bits) which calls...
  332. * If callback is registered to the "global" list, the list
  333. * function is called and recursion checks the GLOBAL bits.
  334. * then this function calls...
  335. * The function callback, which can use the FTRACE bits to
  336. * check for recursion.
  337. *
  338. * Now if the arch does not suppport a feature, and it calls
  339. * the global list function which calls the ftrace callback
  340. * all three of these steps will do a recursion protection.
  341. * There's no reason to do one if the previous caller already
  342. * did. The recursion that we are protecting against will
  343. * go through the same steps again.
  344. *
  345. * To prevent the multiple recursion checks, if a recursion
  346. * bit is set that is higher than the MAX bit of the current
  347. * check, then we know that the check was made by the previous
  348. * caller, and we can skip the current check.
  349. */
  350. enum {
  351. TRACE_BUFFER_BIT,
  352. TRACE_BUFFER_NMI_BIT,
  353. TRACE_BUFFER_IRQ_BIT,
  354. TRACE_BUFFER_SIRQ_BIT,
  355. /* Start of function recursion bits */
  356. TRACE_FTRACE_BIT,
  357. TRACE_FTRACE_NMI_BIT,
  358. TRACE_FTRACE_IRQ_BIT,
  359. TRACE_FTRACE_SIRQ_BIT,
  360. /* GLOBAL_BITs must be greater than FTRACE_BITs */
  361. TRACE_GLOBAL_BIT,
  362. TRACE_GLOBAL_NMI_BIT,
  363. TRACE_GLOBAL_IRQ_BIT,
  364. TRACE_GLOBAL_SIRQ_BIT,
  365. /* INTERNAL_BITs must be greater than GLOBAL_BITs */
  366. TRACE_INTERNAL_BIT,
  367. TRACE_INTERNAL_NMI_BIT,
  368. TRACE_INTERNAL_IRQ_BIT,
  369. TRACE_INTERNAL_SIRQ_BIT,
  370. TRACE_CONTROL_BIT,
  371. /*
  372. * Abuse of the trace_recursion.
  373. * As we need a way to maintain state if we are tracing the function
  374. * graph in irq because we want to trace a particular function that
  375. * was called in irq context but we have irq tracing off. Since this
  376. * can only be modified by current, we can reuse trace_recursion.
  377. */
  378. TRACE_IRQ_BIT,
  379. };
  380. #define trace_recursion_set(bit) do { (current)->trace_recursion |= (1<<(bit)); } while (0)
  381. #define trace_recursion_clear(bit) do { (current)->trace_recursion &= ~(1<<(bit)); } while (0)
  382. #define trace_recursion_test(bit) ((current)->trace_recursion & (1<<(bit)))
  383. #define TRACE_CONTEXT_BITS 4
  384. #define TRACE_FTRACE_START TRACE_FTRACE_BIT
  385. #define TRACE_FTRACE_MAX ((1 << (TRACE_FTRACE_START + TRACE_CONTEXT_BITS)) - 1)
  386. #define TRACE_GLOBAL_START TRACE_GLOBAL_BIT
  387. #define TRACE_GLOBAL_MAX ((1 << (TRACE_GLOBAL_START + TRACE_CONTEXT_BITS)) - 1)
  388. #define TRACE_LIST_START TRACE_INTERNAL_BIT
  389. #define TRACE_LIST_MAX ((1 << (TRACE_LIST_START + TRACE_CONTEXT_BITS)) - 1)
  390. #define TRACE_CONTEXT_MASK TRACE_LIST_MAX
  391. static __always_inline int trace_get_context_bit(void)
  392. {
  393. int bit;
  394. if (in_interrupt()) {
  395. if (in_nmi())
  396. bit = 0;
  397. else if (in_irq())
  398. bit = 1;
  399. else
  400. bit = 2;
  401. } else
  402. bit = 3;
  403. return bit;
  404. }
  405. static __always_inline int trace_test_and_set_recursion(int start, int max)
  406. {
  407. unsigned int val = current->trace_recursion;
  408. int bit;
  409. /* A previous recursion check was made */
  410. if ((val & TRACE_CONTEXT_MASK) > max)
  411. return 0;
  412. bit = trace_get_context_bit() + start;
  413. if (unlikely(val & (1 << bit)))
  414. return -1;
  415. val |= 1 << bit;
  416. current->trace_recursion = val;
  417. barrier();
  418. return bit;
  419. }
  420. static __always_inline void trace_clear_recursion(int bit)
  421. {
  422. unsigned int val = current->trace_recursion;
  423. if (!bit)
  424. return;
  425. bit = 1 << bit;
  426. val &= ~bit;
  427. barrier();
  428. current->trace_recursion = val;
  429. }
  430. static inline struct ring_buffer_iter *
  431. trace_buffer_iter(struct trace_iterator *iter, int cpu)
  432. {
  433. if (iter->buffer_iter && iter->buffer_iter[cpu])
  434. return iter->buffer_iter[cpu];
  435. return NULL;
  436. }
  437. int tracer_init(struct tracer *t, struct trace_array *tr);
  438. int tracing_is_enabled(void);
  439. void tracing_reset(struct trace_buffer *buf, int cpu);
  440. void tracing_reset_online_cpus(struct trace_buffer *buf);
  441. void tracing_reset_current(int cpu);
  442. void tracing_reset_all_online_cpus(void);
  443. int tracing_open_generic(struct inode *inode, struct file *filp);
  444. bool tracing_is_disabled(void);
  445. struct dentry *trace_create_file(const char *name,
  446. umode_t mode,
  447. struct dentry *parent,
  448. void *data,
  449. const struct file_operations *fops);
  450. struct dentry *tracing_init_dentry_tr(struct trace_array *tr);
  451. struct dentry *tracing_init_dentry(void);
  452. struct ring_buffer_event;
  453. struct ring_buffer_event *
  454. trace_buffer_lock_reserve(struct ring_buffer *buffer,
  455. int type,
  456. unsigned long len,
  457. unsigned long flags,
  458. int pc);
  459. struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
  460. struct trace_array_cpu *data);
  461. struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
  462. int *ent_cpu, u64 *ent_ts);
  463. void __buffer_unlock_commit(struct ring_buffer *buffer,
  464. struct ring_buffer_event *event);
  465. int trace_empty(struct trace_iterator *iter);
  466. void *trace_find_next_entry_inc(struct trace_iterator *iter);
  467. void trace_init_global_iter(struct trace_iterator *iter);
  468. void tracing_iter_reset(struct trace_iterator *iter, int cpu);
  469. void poll_wait_pipe(struct trace_iterator *iter);
  470. void tracing_sched_switch_trace(struct trace_array *tr,
  471. struct task_struct *prev,
  472. struct task_struct *next,
  473. unsigned long flags, int pc);
  474. void tracing_sched_wakeup_trace(struct trace_array *tr,
  475. struct task_struct *wakee,
  476. struct task_struct *cur,
  477. unsigned long flags, int pc);
  478. void trace_function(struct trace_array *tr,
  479. unsigned long ip,
  480. unsigned long parent_ip,
  481. unsigned long flags, int pc);
  482. void trace_graph_function(struct trace_array *tr,
  483. unsigned long ip,
  484. unsigned long parent_ip,
  485. unsigned long flags, int pc);
  486. void trace_latency_header(struct seq_file *m);
  487. void trace_default_header(struct seq_file *m);
  488. void print_trace_header(struct seq_file *m, struct trace_iterator *iter);
  489. int trace_empty(struct trace_iterator *iter);
  490. void trace_graph_return(struct ftrace_graph_ret *trace);
  491. int trace_graph_entry(struct ftrace_graph_ent *trace);
  492. void set_graph_array(struct trace_array *tr);
  493. void tracing_start_cmdline_record(void);
  494. void tracing_stop_cmdline_record(void);
  495. void tracing_sched_switch_assign_trace(struct trace_array *tr);
  496. void tracing_stop_sched_switch_record(void);
  497. void tracing_start_sched_switch_record(void);
  498. int register_tracer(struct tracer *type);
  499. int is_tracing_stopped(void);
  500. loff_t tracing_lseek(struct file *file, loff_t offset, int whence);
  501. extern cpumask_var_t __read_mostly tracing_buffer_mask;
  502. #define for_each_tracing_cpu(cpu) \
  503. for_each_cpu(cpu, tracing_buffer_mask)
  504. extern unsigned long nsecs_to_usecs(unsigned long nsecs);
  505. extern unsigned long tracing_thresh;
  506. #ifdef CONFIG_TRACER_MAX_TRACE
  507. extern unsigned long tracing_max_latency;
  508. void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu);
  509. void update_max_tr_single(struct trace_array *tr,
  510. struct task_struct *tsk, int cpu);
  511. #endif /* CONFIG_TRACER_MAX_TRACE */
  512. #ifdef CONFIG_STACKTRACE
  513. void ftrace_trace_stack(struct ring_buffer *buffer, unsigned long flags,
  514. int skip, int pc);
  515. void ftrace_trace_stack_regs(struct ring_buffer *buffer, unsigned long flags,
  516. int skip, int pc, struct pt_regs *regs);
  517. void ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags,
  518. int pc);
  519. void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
  520. int pc);
  521. #else
  522. static inline void ftrace_trace_stack(struct ring_buffer *buffer,
  523. unsigned long flags, int skip, int pc)
  524. {
  525. }
  526. static inline void ftrace_trace_stack_regs(struct ring_buffer *buffer,
  527. unsigned long flags, int skip,
  528. int pc, struct pt_regs *regs)
  529. {
  530. }
  531. static inline void ftrace_trace_userstack(struct ring_buffer *buffer,
  532. unsigned long flags, int pc)
  533. {
  534. }
  535. static inline void __trace_stack(struct trace_array *tr, unsigned long flags,
  536. int skip, int pc)
  537. {
  538. }
  539. #endif /* CONFIG_STACKTRACE */
  540. extern cycle_t ftrace_now(int cpu);
  541. extern void trace_find_cmdline(int pid, char comm[]);
  542. #ifdef CONFIG_DYNAMIC_FTRACE
  543. extern unsigned long ftrace_update_tot_cnt;
  544. #endif
  545. #define DYN_FTRACE_TEST_NAME trace_selftest_dynamic_test_func
  546. extern int DYN_FTRACE_TEST_NAME(void);
  547. #define DYN_FTRACE_TEST_NAME2 trace_selftest_dynamic_test_func2
  548. extern int DYN_FTRACE_TEST_NAME2(void);
  549. extern bool ring_buffer_expanded;
  550. extern bool tracing_selftest_disabled;
  551. DECLARE_PER_CPU(int, ftrace_cpu_disabled);
  552. #ifdef CONFIG_FTRACE_STARTUP_TEST
  553. extern int trace_selftest_startup_function(struct tracer *trace,
  554. struct trace_array *tr);
  555. extern int trace_selftest_startup_function_graph(struct tracer *trace,
  556. struct trace_array *tr);
  557. extern int trace_selftest_startup_irqsoff(struct tracer *trace,
  558. struct trace_array *tr);
  559. extern int trace_selftest_startup_preemptoff(struct tracer *trace,
  560. struct trace_array *tr);
  561. extern int trace_selftest_startup_preemptirqsoff(struct tracer *trace,
  562. struct trace_array *tr);
  563. extern int trace_selftest_startup_wakeup(struct tracer *trace,
  564. struct trace_array *tr);
  565. extern int trace_selftest_startup_nop(struct tracer *trace,
  566. struct trace_array *tr);
  567. extern int trace_selftest_startup_sched_switch(struct tracer *trace,
  568. struct trace_array *tr);
  569. extern int trace_selftest_startup_branch(struct tracer *trace,
  570. struct trace_array *tr);
  571. /*
  572. * Tracer data references selftest functions that only occur
  573. * on boot up. These can be __init functions. Thus, when selftests
  574. * are enabled, then the tracers need to reference __init functions.
  575. */
  576. #define __tracer_data __refdata
  577. #else
  578. /* Tracers are seldom changed. Optimize when selftests are disabled. */
  579. #define __tracer_data __read_mostly
  580. #endif /* CONFIG_FTRACE_STARTUP_TEST */
  581. extern void *head_page(struct trace_array_cpu *data);
  582. extern unsigned long long ns2usecs(cycle_t nsec);
  583. extern int
  584. trace_vbprintk(unsigned long ip, const char *fmt, va_list args);
  585. extern int
  586. trace_vprintk(unsigned long ip, const char *fmt, va_list args);
  587. extern int
  588. trace_array_vprintk(struct trace_array *tr,
  589. unsigned long ip, const char *fmt, va_list args);
  590. int trace_array_printk(struct trace_array *tr,
  591. unsigned long ip, const char *fmt, ...);
  592. int trace_array_printk_buf(struct ring_buffer *buffer,
  593. unsigned long ip, const char *fmt, ...);
  594. void trace_printk_seq(struct trace_seq *s);
  595. enum print_line_t print_trace_line(struct trace_iterator *iter);
  596. extern unsigned long trace_flags;
  597. /* Standard output formatting function used for function return traces */
  598. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  599. /* Flag options */
  600. #define TRACE_GRAPH_PRINT_OVERRUN 0x1
  601. #define TRACE_GRAPH_PRINT_CPU 0x2
  602. #define TRACE_GRAPH_PRINT_OVERHEAD 0x4
  603. #define TRACE_GRAPH_PRINT_PROC 0x8
  604. #define TRACE_GRAPH_PRINT_DURATION 0x10
  605. #define TRACE_GRAPH_PRINT_ABS_TIME 0x20
  606. #define TRACE_GRAPH_PRINT_FILL_SHIFT 28
  607. #define TRACE_GRAPH_PRINT_FILL_MASK (0x3 << TRACE_GRAPH_PRINT_FILL_SHIFT)
  608. extern enum print_line_t
  609. print_graph_function_flags(struct trace_iterator *iter, u32 flags);
  610. extern void print_graph_headers_flags(struct seq_file *s, u32 flags);
  611. extern enum print_line_t
  612. trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
  613. extern void graph_trace_open(struct trace_iterator *iter);
  614. extern void graph_trace_close(struct trace_iterator *iter);
  615. extern int __trace_graph_entry(struct trace_array *tr,
  616. struct ftrace_graph_ent *trace,
  617. unsigned long flags, int pc);
  618. extern void __trace_graph_return(struct trace_array *tr,
  619. struct ftrace_graph_ret *trace,
  620. unsigned long flags, int pc);
  621. #ifdef CONFIG_DYNAMIC_FTRACE
  622. /* TODO: make this variable */
  623. #define FTRACE_GRAPH_MAX_FUNCS 32
  624. extern int ftrace_graph_count;
  625. extern unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS];
  626. extern int ftrace_graph_notrace_count;
  627. extern unsigned long ftrace_graph_notrace_funcs[FTRACE_GRAPH_MAX_FUNCS];
  628. static inline int ftrace_graph_addr(unsigned long addr)
  629. {
  630. int i;
  631. if (!ftrace_graph_count)
  632. return 1;
  633. for (i = 0; i < ftrace_graph_count; i++) {
  634. if (addr == ftrace_graph_funcs[i]) {
  635. /*
  636. * If no irqs are to be traced, but a set_graph_function
  637. * is set, and called by an interrupt handler, we still
  638. * want to trace it.
  639. */
  640. if (in_irq())
  641. trace_recursion_set(TRACE_IRQ_BIT);
  642. else
  643. trace_recursion_clear(TRACE_IRQ_BIT);
  644. return 1;
  645. }
  646. }
  647. return 0;
  648. }
  649. static inline int ftrace_graph_notrace_addr(unsigned long addr)
  650. {
  651. int i;
  652. if (!ftrace_graph_notrace_count)
  653. return 0;
  654. for (i = 0; i < ftrace_graph_notrace_count; i++) {
  655. if (addr == ftrace_graph_notrace_funcs[i])
  656. return 1;
  657. }
  658. return 0;
  659. }
  660. #else
  661. static inline int ftrace_graph_addr(unsigned long addr)
  662. {
  663. return 1;
  664. }
  665. static inline int ftrace_graph_notrace_addr(unsigned long addr)
  666. {
  667. return 0;
  668. }
  669. #endif /* CONFIG_DYNAMIC_FTRACE */
  670. #else /* CONFIG_FUNCTION_GRAPH_TRACER */
  671. static inline enum print_line_t
  672. print_graph_function_flags(struct trace_iterator *iter, u32 flags)
  673. {
  674. return TRACE_TYPE_UNHANDLED;
  675. }
  676. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
  677. extern struct list_head ftrace_pids;
  678. #ifdef CONFIG_FUNCTION_TRACER
  679. extern bool ftrace_filter_param __initdata;
  680. static inline int ftrace_trace_task(struct task_struct *task)
  681. {
  682. if (list_empty(&ftrace_pids))
  683. return 1;
  684. return test_tsk_trace_trace(task);
  685. }
  686. extern int ftrace_is_dead(void);
  687. #else
  688. static inline int ftrace_trace_task(struct task_struct *task)
  689. {
  690. return 1;
  691. }
  692. static inline int ftrace_is_dead(void) { return 0; }
  693. #endif
  694. int ftrace_event_is_function(struct ftrace_event_call *call);
  695. /*
  696. * struct trace_parser - servers for reading the user input separated by spaces
  697. * @cont: set if the input is not complete - no final space char was found
  698. * @buffer: holds the parsed user input
  699. * @idx: user input length
  700. * @size: buffer size
  701. */
  702. struct trace_parser {
  703. bool cont;
  704. char *buffer;
  705. unsigned idx;
  706. unsigned size;
  707. };
  708. static inline bool trace_parser_loaded(struct trace_parser *parser)
  709. {
  710. return (parser->idx != 0);
  711. }
  712. static inline bool trace_parser_cont(struct trace_parser *parser)
  713. {
  714. return parser->cont;
  715. }
  716. static inline void trace_parser_clear(struct trace_parser *parser)
  717. {
  718. parser->cont = false;
  719. parser->idx = 0;
  720. }
  721. extern int trace_parser_get_init(struct trace_parser *parser, int size);
  722. extern void trace_parser_put(struct trace_parser *parser);
  723. extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
  724. size_t cnt, loff_t *ppos);
  725. /*
  726. * trace_iterator_flags is an enumeration that defines bit
  727. * positions into trace_flags that controls the output.
  728. *
  729. * NOTE: These bits must match the trace_options array in
  730. * trace.c.
  731. */
  732. enum trace_iterator_flags {
  733. TRACE_ITER_PRINT_PARENT = 0x01,
  734. TRACE_ITER_SYM_OFFSET = 0x02,
  735. TRACE_ITER_SYM_ADDR = 0x04,
  736. TRACE_ITER_VERBOSE = 0x08,
  737. TRACE_ITER_RAW = 0x10,
  738. TRACE_ITER_HEX = 0x20,
  739. TRACE_ITER_BIN = 0x40,
  740. TRACE_ITER_BLOCK = 0x80,
  741. TRACE_ITER_STACKTRACE = 0x100,
  742. TRACE_ITER_PRINTK = 0x200,
  743. TRACE_ITER_PREEMPTONLY = 0x400,
  744. TRACE_ITER_BRANCH = 0x800,
  745. TRACE_ITER_ANNOTATE = 0x1000,
  746. TRACE_ITER_USERSTACKTRACE = 0x2000,
  747. TRACE_ITER_SYM_USEROBJ = 0x4000,
  748. TRACE_ITER_PRINTK_MSGONLY = 0x8000,
  749. TRACE_ITER_CONTEXT_INFO = 0x10000, /* Print pid/cpu/time */
  750. TRACE_ITER_LATENCY_FMT = 0x20000,
  751. TRACE_ITER_SLEEP_TIME = 0x40000,
  752. TRACE_ITER_GRAPH_TIME = 0x80000,
  753. TRACE_ITER_RECORD_CMD = 0x100000,
  754. TRACE_ITER_OVERWRITE = 0x200000,
  755. TRACE_ITER_STOP_ON_FREE = 0x400000,
  756. TRACE_ITER_IRQ_INFO = 0x800000,
  757. TRACE_ITER_MARKERS = 0x1000000,
  758. TRACE_ITER_FUNCTION = 0x2000000,
  759. };
  760. /*
  761. * TRACE_ITER_SYM_MASK masks the options in trace_flags that
  762. * control the output of kernel symbols.
  763. */
  764. #define TRACE_ITER_SYM_MASK \
  765. (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR)
  766. extern struct tracer nop_trace;
  767. #ifdef CONFIG_BRANCH_TRACER
  768. extern int enable_branch_tracing(struct trace_array *tr);
  769. extern void disable_branch_tracing(void);
  770. static inline int trace_branch_enable(struct trace_array *tr)
  771. {
  772. if (trace_flags & TRACE_ITER_BRANCH)
  773. return enable_branch_tracing(tr);
  774. return 0;
  775. }
  776. static inline void trace_branch_disable(void)
  777. {
  778. /* due to races, always disable */
  779. disable_branch_tracing();
  780. }
  781. #else
  782. static inline int trace_branch_enable(struct trace_array *tr)
  783. {
  784. return 0;
  785. }
  786. static inline void trace_branch_disable(void)
  787. {
  788. }
  789. #endif /* CONFIG_BRANCH_TRACER */
  790. /* set ring buffers to default size if not already done so */
  791. int tracing_update_buffers(void);
  792. struct ftrace_event_field {
  793. struct list_head link;
  794. const char *name;
  795. const char *type;
  796. int filter_type;
  797. int offset;
  798. int size;
  799. int is_signed;
  800. };
  801. struct event_filter {
  802. int n_preds; /* Number assigned */
  803. int a_preds; /* allocated */
  804. struct filter_pred *preds;
  805. struct filter_pred *root;
  806. char *filter_string;
  807. };
  808. struct event_subsystem {
  809. struct list_head list;
  810. const char *name;
  811. struct event_filter *filter;
  812. int ref_count;
  813. };
  814. struct ftrace_subsystem_dir {
  815. struct list_head list;
  816. struct event_subsystem *subsystem;
  817. struct trace_array *tr;
  818. struct dentry *entry;
  819. int ref_count;
  820. int nr_events;
  821. };
  822. #define FILTER_PRED_INVALID ((unsigned short)-1)
  823. #define FILTER_PRED_IS_RIGHT (1 << 15)
  824. #define FILTER_PRED_FOLD (1 << 15)
  825. /*
  826. * The max preds is the size of unsigned short with
  827. * two flags at the MSBs. One bit is used for both the IS_RIGHT
  828. * and FOLD flags. The other is reserved.
  829. *
  830. * 2^14 preds is way more than enough.
  831. */
  832. #define MAX_FILTER_PRED 16384
  833. struct filter_pred;
  834. struct regex;
  835. typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event);
  836. typedef int (*regex_match_func)(char *str, struct regex *r, int len);
  837. enum regex_type {
  838. MATCH_FULL = 0,
  839. MATCH_FRONT_ONLY,
  840. MATCH_MIDDLE_ONLY,
  841. MATCH_END_ONLY,
  842. };
  843. struct regex {
  844. char pattern[MAX_FILTER_STR_VAL];
  845. int len;
  846. int field_len;
  847. regex_match_func match;
  848. };
  849. struct filter_pred {
  850. filter_pred_fn_t fn;
  851. u64 val;
  852. struct regex regex;
  853. unsigned short *ops;
  854. struct ftrace_event_field *field;
  855. int offset;
  856. int not;
  857. int op;
  858. unsigned short index;
  859. unsigned short parent;
  860. unsigned short left;
  861. unsigned short right;
  862. };
  863. extern enum regex_type
  864. filter_parse_regex(char *buff, int len, char **search, int *not);
  865. extern void print_event_filter(struct ftrace_event_file *file,
  866. struct trace_seq *s);
  867. extern int apply_event_filter(struct ftrace_event_file *file,
  868. char *filter_string);
  869. extern int apply_subsystem_event_filter(struct ftrace_subsystem_dir *dir,
  870. char *filter_string);
  871. extern void print_subsystem_event_filter(struct event_subsystem *system,
  872. struct trace_seq *s);
  873. extern int filter_assign_type(const char *type);
  874. extern int create_event_filter(struct ftrace_event_call *call,
  875. char *filter_str, bool set_str,
  876. struct event_filter **filterp);
  877. extern void free_event_filter(struct event_filter *filter);
  878. struct ftrace_event_field *
  879. trace_find_event_field(struct ftrace_event_call *call, char *name);
  880. extern void trace_event_enable_cmd_record(bool enable);
  881. extern int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr);
  882. extern int event_trace_del_tracer(struct trace_array *tr);
  883. extern struct ftrace_event_file *find_event_file(struct trace_array *tr,
  884. const char *system,
  885. const char *event);
  886. static inline void *event_file_data(struct file *filp)
  887. {
  888. return ACCESS_ONCE(file_inode(filp)->i_private);
  889. }
  890. extern struct mutex event_mutex;
  891. extern struct list_head ftrace_events;
  892. extern const struct file_operations event_trigger_fops;
  893. extern int register_trigger_cmds(void);
  894. extern void clear_event_triggers(struct trace_array *tr);
  895. struct event_trigger_data {
  896. unsigned long count;
  897. int ref;
  898. struct event_trigger_ops *ops;
  899. struct event_command *cmd_ops;
  900. struct event_filter __rcu *filter;
  901. char *filter_str;
  902. void *private_data;
  903. struct list_head list;
  904. };
  905. /**
  906. * struct event_trigger_ops - callbacks for trace event triggers
  907. *
  908. * The methods in this structure provide per-event trigger hooks for
  909. * various trigger operations.
  910. *
  911. * All the methods below, except for @init() and @free(), must be
  912. * implemented.
  913. *
  914. * @func: The trigger 'probe' function called when the triggering
  915. * event occurs. The data passed into this callback is the data
  916. * that was supplied to the event_command @reg() function that
  917. * registered the trigger (see struct event_command).
  918. *
  919. * @init: An optional initialization function called for the trigger
  920. * when the trigger is registered (via the event_command reg()
  921. * function). This can be used to perform per-trigger
  922. * initialization such as incrementing a per-trigger reference
  923. * count, for instance. This is usually implemented by the
  924. * generic utility function @event_trigger_init() (see
  925. * trace_event_triggers.c).
  926. *
  927. * @free: An optional de-initialization function called for the
  928. * trigger when the trigger is unregistered (via the
  929. * event_command @reg() function). This can be used to perform
  930. * per-trigger de-initialization such as decrementing a
  931. * per-trigger reference count and freeing corresponding trigger
  932. * data, for instance. This is usually implemented by the
  933. * generic utility function @event_trigger_free() (see
  934. * trace_event_triggers.c).
  935. *
  936. * @print: The callback function invoked to have the trigger print
  937. * itself. This is usually implemented by a wrapper function
  938. * that calls the generic utility function @event_trigger_print()
  939. * (see trace_event_triggers.c).
  940. */
  941. struct event_trigger_ops {
  942. void (*func)(struct event_trigger_data *data);
  943. int (*init)(struct event_trigger_ops *ops,
  944. struct event_trigger_data *data);
  945. void (*free)(struct event_trigger_ops *ops,
  946. struct event_trigger_data *data);
  947. int (*print)(struct seq_file *m,
  948. struct event_trigger_ops *ops,
  949. struct event_trigger_data *data);
  950. };
  951. /**
  952. * struct event_command - callbacks and data members for event commands
  953. *
  954. * Event commands are invoked by users by writing the command name
  955. * into the 'trigger' file associated with a trace event. The
  956. * parameters associated with a specific invocation of an event
  957. * command are used to create an event trigger instance, which is
  958. * added to the list of trigger instances associated with that trace
  959. * event. When the event is hit, the set of triggers associated with
  960. * that event is invoked.
  961. *
  962. * The data members in this structure provide per-event command data
  963. * for various event commands.
  964. *
  965. * All the data members below, except for @post_trigger, must be set
  966. * for each event command.
  967. *
  968. * @name: The unique name that identifies the event command. This is
  969. * the name used when setting triggers via trigger files.
  970. *
  971. * @trigger_type: A unique id that identifies the event command
  972. * 'type'. This value has two purposes, the first to ensure that
  973. * only one trigger of the same type can be set at a given time
  974. * for a particular event e.g. it doesn't make sense to have both
  975. * a traceon and traceoff trigger attached to a single event at
  976. * the same time, so traceon and traceoff have the same type
  977. * though they have different names. The @trigger_type value is
  978. * also used as a bit value for deferring the actual trigger
  979. * action until after the current event is finished. Some
  980. * commands need to do this if they themselves log to the trace
  981. * buffer (see the @post_trigger() member below). @trigger_type
  982. * values are defined by adding new values to the trigger_type
  983. * enum in include/linux/ftrace_event.h.
  984. *
  985. * @post_trigger: A flag that says whether or not this command needs
  986. * to have its action delayed until after the current event has
  987. * been closed. Some triggers need to avoid being invoked while
  988. * an event is currently in the process of being logged, since
  989. * the trigger may itself log data into the trace buffer. Thus
  990. * we make sure the current event is committed before invoking
  991. * those triggers. To do that, the trigger invocation is split
  992. * in two - the first part checks the filter using the current
  993. * trace record; if a command has the @post_trigger flag set, it
  994. * sets a bit for itself in the return value, otherwise it
  995. * directly invokes the trigger. Once all commands have been
  996. * either invoked or set their return flag, the current record is
  997. * either committed or discarded. At that point, if any commands
  998. * have deferred their triggers, those commands are finally
  999. * invoked following the close of the current event. In other
  1000. * words, if the event_trigger_ops @func() probe implementation
  1001. * itself logs to the trace buffer, this flag should be set,
  1002. * otherwise it can be left unspecified.
  1003. *
  1004. * All the methods below, except for @set_filter(), must be
  1005. * implemented.
  1006. *
  1007. * @func: The callback function responsible for parsing and
  1008. * registering the trigger written to the 'trigger' file by the
  1009. * user. It allocates the trigger instance and registers it with
  1010. * the appropriate trace event. It makes use of the other
  1011. * event_command callback functions to orchestrate this, and is
  1012. * usually implemented by the generic utility function
  1013. * @event_trigger_callback() (see trace_event_triggers.c).
  1014. *
  1015. * @reg: Adds the trigger to the list of triggers associated with the
  1016. * event, and enables the event trigger itself, after
  1017. * initializing it (via the event_trigger_ops @init() function).
  1018. * This is also where commands can use the @trigger_type value to
  1019. * make the decision as to whether or not multiple instances of
  1020. * the trigger should be allowed. This is usually implemented by
  1021. * the generic utility function @register_trigger() (see
  1022. * trace_event_triggers.c).
  1023. *
  1024. * @unreg: Removes the trigger from the list of triggers associated
  1025. * with the event, and disables the event trigger itself, after
  1026. * initializing it (via the event_trigger_ops @free() function).
  1027. * This is usually implemented by the generic utility function
  1028. * @unregister_trigger() (see trace_event_triggers.c).
  1029. *
  1030. * @set_filter: An optional function called to parse and set a filter
  1031. * for the trigger. If no @set_filter() method is set for the
  1032. * event command, filters set by the user for the command will be
  1033. * ignored. This is usually implemented by the generic utility
  1034. * function @set_trigger_filter() (see trace_event_triggers.c).
  1035. *
  1036. * @get_trigger_ops: The callback function invoked to retrieve the
  1037. * event_trigger_ops implementation associated with the command.
  1038. */
  1039. struct event_command {
  1040. struct list_head list;
  1041. char *name;
  1042. enum event_trigger_type trigger_type;
  1043. bool post_trigger;
  1044. int (*func)(struct event_command *cmd_ops,
  1045. struct ftrace_event_file *file,
  1046. char *glob, char *cmd, char *params);
  1047. int (*reg)(char *glob,
  1048. struct event_trigger_ops *ops,
  1049. struct event_trigger_data *data,
  1050. struct ftrace_event_file *file);
  1051. void (*unreg)(char *glob,
  1052. struct event_trigger_ops *ops,
  1053. struct event_trigger_data *data,
  1054. struct ftrace_event_file *file);
  1055. int (*set_filter)(char *filter_str,
  1056. struct event_trigger_data *data,
  1057. struct ftrace_event_file *file);
  1058. struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
  1059. };
  1060. extern int trace_event_enable_disable(struct ftrace_event_file *file,
  1061. int enable, int soft_disable);
  1062. extern int tracing_alloc_snapshot(void);
  1063. extern const char *__start___trace_bprintk_fmt[];
  1064. extern const char *__stop___trace_bprintk_fmt[];
  1065. extern const char *__start___tracepoint_str[];
  1066. extern const char *__stop___tracepoint_str[];
  1067. void trace_printk_init_buffers(void);
  1068. void trace_printk_start_comm(void);
  1069. int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
  1070. int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
  1071. /*
  1072. * Normal trace_printk() and friends allocates special buffers
  1073. * to do the manipulation, as well as saves the print formats
  1074. * into sections to display. But the trace infrastructure wants
  1075. * to use these without the added overhead at the price of being
  1076. * a bit slower (used mainly for warnings, where we don't care
  1077. * about performance). The internal_trace_puts() is for such
  1078. * a purpose.
  1079. */
  1080. #define internal_trace_puts(str) __trace_puts(_THIS_IP_, str, strlen(str))
  1081. #undef FTRACE_ENTRY
  1082. #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
  1083. extern struct ftrace_event_call \
  1084. __attribute__((__aligned__(4))) event_##call;
  1085. #undef FTRACE_ENTRY_DUP
  1086. #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \
  1087. FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
  1088. filter)
  1089. #include "trace_entries.h"
  1090. #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER)
  1091. int perf_ftrace_event_register(struct ftrace_event_call *call,
  1092. enum trace_reg type, void *data);
  1093. #else
  1094. #define perf_ftrace_event_register NULL
  1095. #endif
  1096. #endif /* _LINUX_KERNEL_TRACE_H */