trace.h 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777
  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/trace_events.h>
  14. #include <linux/compiler.h>
  15. #include <linux/trace_seq.h>
  16. #include <linux/glob.h>
  17. #ifdef CONFIG_FTRACE_SYSCALLS
  18. #include <asm/unistd.h> /* For NR_SYSCALLS */
  19. #include <asm/syscall.h> /* some archs define it here */
  20. #endif
  21. enum trace_type {
  22. __TRACE_FIRST_TYPE = 0,
  23. TRACE_FN,
  24. TRACE_CTX,
  25. TRACE_WAKE,
  26. TRACE_STACK,
  27. TRACE_PRINT,
  28. TRACE_BPRINT,
  29. TRACE_MMIO_RW,
  30. TRACE_MMIO_MAP,
  31. TRACE_BRANCH,
  32. TRACE_GRAPH_RET,
  33. TRACE_GRAPH_ENT,
  34. TRACE_USER_STACK,
  35. TRACE_BLK,
  36. TRACE_BPUTS,
  37. TRACE_HWLAT,
  38. TRACE_RAW_DATA,
  39. __TRACE_LAST_TYPE,
  40. };
  41. #undef __field
  42. #define __field(type, item) type item;
  43. #undef __field_struct
  44. #define __field_struct(type, item) __field(type, item)
  45. #undef __field_desc
  46. #define __field_desc(type, container, item)
  47. #undef __array
  48. #define __array(type, item, size) type item[size];
  49. #undef __array_desc
  50. #define __array_desc(type, container, item, size)
  51. #undef __dynamic_array
  52. #define __dynamic_array(type, item) type item[];
  53. #undef F_STRUCT
  54. #define F_STRUCT(args...) args
  55. #undef FTRACE_ENTRY
  56. #define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
  57. struct struct_name { \
  58. struct trace_entry ent; \
  59. tstruct \
  60. }
  61. #undef FTRACE_ENTRY_DUP
  62. #define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk, filter)
  63. #undef FTRACE_ENTRY_REG
  64. #define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, \
  65. filter, regfn) \
  66. FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
  67. filter)
  68. #undef FTRACE_ENTRY_PACKED
  69. #define FTRACE_ENTRY_PACKED(name, struct_name, id, tstruct, print, \
  70. filter) \
  71. FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
  72. filter) __packed
  73. #include "trace_entries.h"
  74. /*
  75. * syscalls are special, and need special handling, this is why
  76. * they are not included in trace_entries.h
  77. */
  78. struct syscall_trace_enter {
  79. struct trace_entry ent;
  80. int nr;
  81. unsigned long args[];
  82. };
  83. struct syscall_trace_exit {
  84. struct trace_entry ent;
  85. int nr;
  86. long ret;
  87. };
  88. struct kprobe_trace_entry_head {
  89. struct trace_entry ent;
  90. unsigned long ip;
  91. };
  92. struct kretprobe_trace_entry_head {
  93. struct trace_entry ent;
  94. unsigned long func;
  95. unsigned long ret_ip;
  96. };
  97. /*
  98. * trace_flag_type is an enumeration that holds different
  99. * states when a trace occurs. These are:
  100. * IRQS_OFF - interrupts were disabled
  101. * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags
  102. * NEED_RESCHED - reschedule is requested
  103. * HARDIRQ - inside an interrupt handler
  104. * SOFTIRQ - inside a softirq handler
  105. */
  106. enum trace_flag_type {
  107. TRACE_FLAG_IRQS_OFF = 0x01,
  108. TRACE_FLAG_IRQS_NOSUPPORT = 0x02,
  109. TRACE_FLAG_NEED_RESCHED = 0x04,
  110. TRACE_FLAG_HARDIRQ = 0x08,
  111. TRACE_FLAG_SOFTIRQ = 0x10,
  112. TRACE_FLAG_PREEMPT_RESCHED = 0x20,
  113. TRACE_FLAG_NMI = 0x40,
  114. };
  115. #define TRACE_BUF_SIZE 1024
  116. struct trace_array;
  117. /*
  118. * The CPU trace array - it consists of thousands of trace entries
  119. * plus some other descriptor data: (for example which task started
  120. * the trace, etc.)
  121. */
  122. struct trace_array_cpu {
  123. atomic_t disabled;
  124. void *buffer_page; /* ring buffer spare */
  125. unsigned long entries;
  126. unsigned long saved_latency;
  127. unsigned long critical_start;
  128. unsigned long critical_end;
  129. unsigned long critical_sequence;
  130. unsigned long nice;
  131. unsigned long policy;
  132. unsigned long rt_priority;
  133. unsigned long skipped_entries;
  134. u64 preempt_timestamp;
  135. pid_t pid;
  136. kuid_t uid;
  137. char comm[TASK_COMM_LEN];
  138. bool ignore_pid;
  139. #ifdef CONFIG_FUNCTION_TRACER
  140. bool ftrace_ignore_pid;
  141. #endif
  142. };
  143. struct tracer;
  144. struct trace_option_dentry;
  145. struct trace_buffer {
  146. struct trace_array *tr;
  147. struct ring_buffer *buffer;
  148. struct trace_array_cpu __percpu *data;
  149. u64 time_start;
  150. int cpu;
  151. };
  152. #define TRACE_FLAGS_MAX_SIZE 32
  153. struct trace_options {
  154. struct tracer *tracer;
  155. struct trace_option_dentry *topts;
  156. };
  157. struct trace_pid_list {
  158. int pid_max;
  159. unsigned long *pids;
  160. };
  161. /*
  162. * The trace array - an array of per-CPU trace arrays. This is the
  163. * highest level data structure that individual tracers deal with.
  164. * They have on/off state as well:
  165. */
  166. struct trace_array {
  167. struct list_head list;
  168. char *name;
  169. struct trace_buffer trace_buffer;
  170. #ifdef CONFIG_TRACER_MAX_TRACE
  171. /*
  172. * The max_buffer is used to snapshot the trace when a maximum
  173. * latency is reached, or when the user initiates a snapshot.
  174. * Some tracers will use this to store a maximum trace while
  175. * it continues examining live traces.
  176. *
  177. * The buffers for the max_buffer are set up the same as the trace_buffer
  178. * When a snapshot is taken, the buffer of the max_buffer is swapped
  179. * with the buffer of the trace_buffer and the buffers are reset for
  180. * the trace_buffer so the tracing can continue.
  181. */
  182. struct trace_buffer max_buffer;
  183. bool allocated_snapshot;
  184. #endif
  185. #if defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)
  186. unsigned long max_latency;
  187. #endif
  188. struct trace_pid_list __rcu *filtered_pids;
  189. /*
  190. * max_lock is used to protect the swapping of buffers
  191. * when taking a max snapshot. The buffers themselves are
  192. * protected by per_cpu spinlocks. But the action of the swap
  193. * needs its own lock.
  194. *
  195. * This is defined as a arch_spinlock_t in order to help
  196. * with performance when lockdep debugging is enabled.
  197. *
  198. * It is also used in other places outside the update_max_tr
  199. * so it needs to be defined outside of the
  200. * CONFIG_TRACER_MAX_TRACE.
  201. */
  202. arch_spinlock_t max_lock;
  203. int buffer_disabled;
  204. #ifdef CONFIG_FTRACE_SYSCALLS
  205. int sys_refcount_enter;
  206. int sys_refcount_exit;
  207. struct trace_event_file __rcu *enter_syscall_files[NR_syscalls];
  208. struct trace_event_file __rcu *exit_syscall_files[NR_syscalls];
  209. #endif
  210. int stop_count;
  211. int clock_id;
  212. int nr_topts;
  213. struct tracer *current_trace;
  214. unsigned int trace_flags;
  215. unsigned char trace_flags_index[TRACE_FLAGS_MAX_SIZE];
  216. unsigned int flags;
  217. raw_spinlock_t start_lock;
  218. struct dentry *dir;
  219. struct dentry *options;
  220. struct dentry *percpu_dir;
  221. struct dentry *event_dir;
  222. struct trace_options *topts;
  223. struct list_head systems;
  224. struct list_head events;
  225. cpumask_var_t tracing_cpumask; /* only trace on set CPUs */
  226. int ref;
  227. #ifdef CONFIG_FUNCTION_TRACER
  228. struct ftrace_ops *ops;
  229. struct trace_pid_list __rcu *function_pids;
  230. #ifdef CONFIG_DYNAMIC_FTRACE
  231. struct list_head func_probes;
  232. #endif
  233. /* function tracing enabled */
  234. int function_enabled;
  235. #endif
  236. };
  237. enum {
  238. TRACE_ARRAY_FL_GLOBAL = (1 << 0)
  239. };
  240. extern struct list_head ftrace_trace_arrays;
  241. extern struct mutex trace_types_lock;
  242. extern int trace_array_get(struct trace_array *tr);
  243. extern void trace_array_put(struct trace_array *tr);
  244. /*
  245. * The global tracer (top) should be the first trace array added,
  246. * but we check the flag anyway.
  247. */
  248. static inline struct trace_array *top_trace_array(void)
  249. {
  250. struct trace_array *tr;
  251. if (list_empty(&ftrace_trace_arrays))
  252. return NULL;
  253. tr = list_entry(ftrace_trace_arrays.prev,
  254. typeof(*tr), list);
  255. WARN_ON(!(tr->flags & TRACE_ARRAY_FL_GLOBAL));
  256. return tr;
  257. }
  258. #define FTRACE_CMP_TYPE(var, type) \
  259. __builtin_types_compatible_p(typeof(var), type *)
  260. #undef IF_ASSIGN
  261. #define IF_ASSIGN(var, entry, etype, id) \
  262. if (FTRACE_CMP_TYPE(var, etype)) { \
  263. var = (typeof(var))(entry); \
  264. WARN_ON(id && (entry)->type != id); \
  265. break; \
  266. }
  267. /* Will cause compile errors if type is not found. */
  268. extern void __ftrace_bad_type(void);
  269. /*
  270. * The trace_assign_type is a verifier that the entry type is
  271. * the same as the type being assigned. To add new types simply
  272. * add a line with the following format:
  273. *
  274. * IF_ASSIGN(var, ent, type, id);
  275. *
  276. * Where "type" is the trace type that includes the trace_entry
  277. * as the "ent" item. And "id" is the trace identifier that is
  278. * used in the trace_type enum.
  279. *
  280. * If the type can have more than one id, then use zero.
  281. */
  282. #define trace_assign_type(var, ent) \
  283. do { \
  284. IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN); \
  285. IF_ASSIGN(var, ent, struct ctx_switch_entry, 0); \
  286. IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \
  287. IF_ASSIGN(var, ent, struct userstack_entry, TRACE_USER_STACK);\
  288. IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \
  289. IF_ASSIGN(var, ent, struct bprint_entry, TRACE_BPRINT); \
  290. IF_ASSIGN(var, ent, struct bputs_entry, TRACE_BPUTS); \
  291. IF_ASSIGN(var, ent, struct hwlat_entry, TRACE_HWLAT); \
  292. IF_ASSIGN(var, ent, struct raw_data_entry, TRACE_RAW_DATA);\
  293. IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \
  294. TRACE_MMIO_RW); \
  295. IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \
  296. TRACE_MMIO_MAP); \
  297. IF_ASSIGN(var, ent, struct trace_branch, TRACE_BRANCH); \
  298. IF_ASSIGN(var, ent, struct ftrace_graph_ent_entry, \
  299. TRACE_GRAPH_ENT); \
  300. IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \
  301. TRACE_GRAPH_RET); \
  302. __ftrace_bad_type(); \
  303. } while (0)
  304. /*
  305. * An option specific to a tracer. This is a boolean value.
  306. * The bit is the bit index that sets its value on the
  307. * flags value in struct tracer_flags.
  308. */
  309. struct tracer_opt {
  310. const char *name; /* Will appear on the trace_options file */
  311. u32 bit; /* Mask assigned in val field in tracer_flags */
  312. };
  313. /*
  314. * The set of specific options for a tracer. Your tracer
  315. * have to set the initial value of the flags val.
  316. */
  317. struct tracer_flags {
  318. u32 val;
  319. struct tracer_opt *opts;
  320. struct tracer *trace;
  321. };
  322. /* Makes more easy to define a tracer opt */
  323. #define TRACER_OPT(s, b) .name = #s, .bit = b
  324. struct trace_option_dentry {
  325. struct tracer_opt *opt;
  326. struct tracer_flags *flags;
  327. struct trace_array *tr;
  328. struct dentry *entry;
  329. };
  330. /**
  331. * struct tracer - a specific tracer and its callbacks to interact with tracefs
  332. * @name: the name chosen to select it on the available_tracers file
  333. * @init: called when one switches to this tracer (echo name > current_tracer)
  334. * @reset: called when one switches to another tracer
  335. * @start: called when tracing is unpaused (echo 1 > tracing_on)
  336. * @stop: called when tracing is paused (echo 0 > tracing_on)
  337. * @update_thresh: called when tracing_thresh is updated
  338. * @open: called when the trace file is opened
  339. * @pipe_open: called when the trace_pipe file is opened
  340. * @close: called when the trace file is released
  341. * @pipe_close: called when the trace_pipe file is released
  342. * @read: override the default read callback on trace_pipe
  343. * @splice_read: override the default splice_read callback on trace_pipe
  344. * @selftest: selftest to run on boot (see trace_selftest.c)
  345. * @print_headers: override the first lines that describe your columns
  346. * @print_line: callback that prints a trace
  347. * @set_flag: signals one of your private flags changed (trace_options file)
  348. * @flags: your private flags
  349. */
  350. struct tracer {
  351. const char *name;
  352. int (*init)(struct trace_array *tr);
  353. void (*reset)(struct trace_array *tr);
  354. void (*start)(struct trace_array *tr);
  355. void (*stop)(struct trace_array *tr);
  356. int (*update_thresh)(struct trace_array *tr);
  357. void (*open)(struct trace_iterator *iter);
  358. void (*pipe_open)(struct trace_iterator *iter);
  359. void (*close)(struct trace_iterator *iter);
  360. void (*pipe_close)(struct trace_iterator *iter);
  361. ssize_t (*read)(struct trace_iterator *iter,
  362. struct file *filp, char __user *ubuf,
  363. size_t cnt, loff_t *ppos);
  364. ssize_t (*splice_read)(struct trace_iterator *iter,
  365. struct file *filp,
  366. loff_t *ppos,
  367. struct pipe_inode_info *pipe,
  368. size_t len,
  369. unsigned int flags);
  370. #ifdef CONFIG_FTRACE_STARTUP_TEST
  371. int (*selftest)(struct tracer *trace,
  372. struct trace_array *tr);
  373. #endif
  374. void (*print_header)(struct seq_file *m);
  375. enum print_line_t (*print_line)(struct trace_iterator *iter);
  376. /* If you handled the flag setting, return 0 */
  377. int (*set_flag)(struct trace_array *tr,
  378. u32 old_flags, u32 bit, int set);
  379. /* Return 0 if OK with change, else return non-zero */
  380. int (*flag_changed)(struct trace_array *tr,
  381. u32 mask, int set);
  382. struct tracer *next;
  383. struct tracer_flags *flags;
  384. int enabled;
  385. int ref;
  386. bool print_max;
  387. bool allow_instances;
  388. #ifdef CONFIG_TRACER_MAX_TRACE
  389. bool use_max_tr;
  390. #endif
  391. };
  392. /* Only current can touch trace_recursion */
  393. /*
  394. * For function tracing recursion:
  395. * The order of these bits are important.
  396. *
  397. * When function tracing occurs, the following steps are made:
  398. * If arch does not support a ftrace feature:
  399. * call internal function (uses INTERNAL bits) which calls...
  400. * If callback is registered to the "global" list, the list
  401. * function is called and recursion checks the GLOBAL bits.
  402. * then this function calls...
  403. * The function callback, which can use the FTRACE bits to
  404. * check for recursion.
  405. *
  406. * Now if the arch does not suppport a feature, and it calls
  407. * the global list function which calls the ftrace callback
  408. * all three of these steps will do a recursion protection.
  409. * There's no reason to do one if the previous caller already
  410. * did. The recursion that we are protecting against will
  411. * go through the same steps again.
  412. *
  413. * To prevent the multiple recursion checks, if a recursion
  414. * bit is set that is higher than the MAX bit of the current
  415. * check, then we know that the check was made by the previous
  416. * caller, and we can skip the current check.
  417. */
  418. enum {
  419. TRACE_BUFFER_BIT,
  420. TRACE_BUFFER_NMI_BIT,
  421. TRACE_BUFFER_IRQ_BIT,
  422. TRACE_BUFFER_SIRQ_BIT,
  423. /* Start of function recursion bits */
  424. TRACE_FTRACE_BIT,
  425. TRACE_FTRACE_NMI_BIT,
  426. TRACE_FTRACE_IRQ_BIT,
  427. TRACE_FTRACE_SIRQ_BIT,
  428. /* INTERNAL_BITs must be greater than FTRACE_BITs */
  429. TRACE_INTERNAL_BIT,
  430. TRACE_INTERNAL_NMI_BIT,
  431. TRACE_INTERNAL_IRQ_BIT,
  432. TRACE_INTERNAL_SIRQ_BIT,
  433. TRACE_BRANCH_BIT,
  434. /*
  435. * Abuse of the trace_recursion.
  436. * As we need a way to maintain state if we are tracing the function
  437. * graph in irq because we want to trace a particular function that
  438. * was called in irq context but we have irq tracing off. Since this
  439. * can only be modified by current, we can reuse trace_recursion.
  440. */
  441. TRACE_IRQ_BIT,
  442. };
  443. #define trace_recursion_set(bit) do { (current)->trace_recursion |= (1<<(bit)); } while (0)
  444. #define trace_recursion_clear(bit) do { (current)->trace_recursion &= ~(1<<(bit)); } while (0)
  445. #define trace_recursion_test(bit) ((current)->trace_recursion & (1<<(bit)))
  446. #define TRACE_CONTEXT_BITS 4
  447. #define TRACE_FTRACE_START TRACE_FTRACE_BIT
  448. #define TRACE_FTRACE_MAX ((1 << (TRACE_FTRACE_START + TRACE_CONTEXT_BITS)) - 1)
  449. #define TRACE_LIST_START TRACE_INTERNAL_BIT
  450. #define TRACE_LIST_MAX ((1 << (TRACE_LIST_START + TRACE_CONTEXT_BITS)) - 1)
  451. #define TRACE_CONTEXT_MASK TRACE_LIST_MAX
  452. static __always_inline int trace_get_context_bit(void)
  453. {
  454. int bit;
  455. if (in_interrupt()) {
  456. if (in_nmi())
  457. bit = 0;
  458. else if (in_irq())
  459. bit = 1;
  460. else
  461. bit = 2;
  462. } else
  463. bit = 3;
  464. return bit;
  465. }
  466. static __always_inline int trace_test_and_set_recursion(int start, int max)
  467. {
  468. unsigned int val = current->trace_recursion;
  469. int bit;
  470. /* A previous recursion check was made */
  471. if ((val & TRACE_CONTEXT_MASK) > max)
  472. return 0;
  473. bit = trace_get_context_bit() + start;
  474. if (unlikely(val & (1 << bit)))
  475. return -1;
  476. val |= 1 << bit;
  477. current->trace_recursion = val;
  478. barrier();
  479. return bit;
  480. }
  481. static __always_inline void trace_clear_recursion(int bit)
  482. {
  483. unsigned int val = current->trace_recursion;
  484. if (!bit)
  485. return;
  486. bit = 1 << bit;
  487. val &= ~bit;
  488. barrier();
  489. current->trace_recursion = val;
  490. }
  491. static inline struct ring_buffer_iter *
  492. trace_buffer_iter(struct trace_iterator *iter, int cpu)
  493. {
  494. if (iter->buffer_iter && iter->buffer_iter[cpu])
  495. return iter->buffer_iter[cpu];
  496. return NULL;
  497. }
  498. int tracer_init(struct tracer *t, struct trace_array *tr);
  499. int tracing_is_enabled(void);
  500. void tracing_reset(struct trace_buffer *buf, int cpu);
  501. void tracing_reset_online_cpus(struct trace_buffer *buf);
  502. void tracing_reset_current(int cpu);
  503. void tracing_reset_all_online_cpus(void);
  504. int tracing_open_generic(struct inode *inode, struct file *filp);
  505. bool tracing_is_disabled(void);
  506. int tracer_tracing_is_on(struct trace_array *tr);
  507. void tracer_tracing_on(struct trace_array *tr);
  508. void tracer_tracing_off(struct trace_array *tr);
  509. struct dentry *trace_create_file(const char *name,
  510. umode_t mode,
  511. struct dentry *parent,
  512. void *data,
  513. const struct file_operations *fops);
  514. struct dentry *tracing_init_dentry(void);
  515. struct ring_buffer_event;
  516. struct ring_buffer_event *
  517. trace_buffer_lock_reserve(struct ring_buffer *buffer,
  518. int type,
  519. unsigned long len,
  520. unsigned long flags,
  521. int pc);
  522. struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
  523. struct trace_array_cpu *data);
  524. struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
  525. int *ent_cpu, u64 *ent_ts);
  526. void trace_buffer_unlock_commit_nostack(struct ring_buffer *buffer,
  527. struct ring_buffer_event *event);
  528. int trace_empty(struct trace_iterator *iter);
  529. void *trace_find_next_entry_inc(struct trace_iterator *iter);
  530. void trace_init_global_iter(struct trace_iterator *iter);
  531. void tracing_iter_reset(struct trace_iterator *iter, int cpu);
  532. void trace_function(struct trace_array *tr,
  533. unsigned long ip,
  534. unsigned long parent_ip,
  535. unsigned long flags, int pc);
  536. void trace_graph_function(struct trace_array *tr,
  537. unsigned long ip,
  538. unsigned long parent_ip,
  539. unsigned long flags, int pc);
  540. void trace_latency_header(struct seq_file *m);
  541. void trace_default_header(struct seq_file *m);
  542. void print_trace_header(struct seq_file *m, struct trace_iterator *iter);
  543. int trace_empty(struct trace_iterator *iter);
  544. void trace_graph_return(struct ftrace_graph_ret *trace);
  545. int trace_graph_entry(struct ftrace_graph_ent *trace);
  546. void set_graph_array(struct trace_array *tr);
  547. void tracing_start_cmdline_record(void);
  548. void tracing_stop_cmdline_record(void);
  549. int register_tracer(struct tracer *type);
  550. int is_tracing_stopped(void);
  551. loff_t tracing_lseek(struct file *file, loff_t offset, int whence);
  552. extern cpumask_var_t __read_mostly tracing_buffer_mask;
  553. #define for_each_tracing_cpu(cpu) \
  554. for_each_cpu(cpu, tracing_buffer_mask)
  555. extern unsigned long nsecs_to_usecs(unsigned long nsecs);
  556. extern unsigned long tracing_thresh;
  557. /* PID filtering */
  558. extern int pid_max;
  559. bool trace_find_filtered_pid(struct trace_pid_list *filtered_pids,
  560. pid_t search_pid);
  561. bool trace_ignore_this_task(struct trace_pid_list *filtered_pids,
  562. struct task_struct *task);
  563. void trace_filter_add_remove_task(struct trace_pid_list *pid_list,
  564. struct task_struct *self,
  565. struct task_struct *task);
  566. void *trace_pid_next(struct trace_pid_list *pid_list, void *v, loff_t *pos);
  567. void *trace_pid_start(struct trace_pid_list *pid_list, loff_t *pos);
  568. int trace_pid_show(struct seq_file *m, void *v);
  569. void trace_free_pid_list(struct trace_pid_list *pid_list);
  570. int trace_pid_write(struct trace_pid_list *filtered_pids,
  571. struct trace_pid_list **new_pid_list,
  572. const char __user *ubuf, size_t cnt);
  573. #ifdef CONFIG_TRACER_MAX_TRACE
  574. void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu);
  575. void update_max_tr_single(struct trace_array *tr,
  576. struct task_struct *tsk, int cpu);
  577. #endif /* CONFIG_TRACER_MAX_TRACE */
  578. #ifdef CONFIG_STACKTRACE
  579. void ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags,
  580. int pc);
  581. void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
  582. int pc);
  583. #else
  584. static inline void ftrace_trace_userstack(struct ring_buffer *buffer,
  585. unsigned long flags, int pc)
  586. {
  587. }
  588. static inline void __trace_stack(struct trace_array *tr, unsigned long flags,
  589. int skip, int pc)
  590. {
  591. }
  592. #endif /* CONFIG_STACKTRACE */
  593. extern u64 ftrace_now(int cpu);
  594. extern void trace_find_cmdline(int pid, char comm[]);
  595. extern void trace_event_follow_fork(struct trace_array *tr, bool enable);
  596. #ifdef CONFIG_DYNAMIC_FTRACE
  597. extern unsigned long ftrace_update_tot_cnt;
  598. void ftrace_init_trace_array(struct trace_array *tr);
  599. #else
  600. static inline void ftrace_init_trace_array(struct trace_array *tr) { }
  601. #endif
  602. #define DYN_FTRACE_TEST_NAME trace_selftest_dynamic_test_func
  603. extern int DYN_FTRACE_TEST_NAME(void);
  604. #define DYN_FTRACE_TEST_NAME2 trace_selftest_dynamic_test_func2
  605. extern int DYN_FTRACE_TEST_NAME2(void);
  606. extern bool ring_buffer_expanded;
  607. extern bool tracing_selftest_disabled;
  608. #ifdef CONFIG_FTRACE_STARTUP_TEST
  609. extern int trace_selftest_startup_function(struct tracer *trace,
  610. struct trace_array *tr);
  611. extern int trace_selftest_startup_function_graph(struct tracer *trace,
  612. struct trace_array *tr);
  613. extern int trace_selftest_startup_irqsoff(struct tracer *trace,
  614. struct trace_array *tr);
  615. extern int trace_selftest_startup_preemptoff(struct tracer *trace,
  616. struct trace_array *tr);
  617. extern int trace_selftest_startup_preemptirqsoff(struct tracer *trace,
  618. struct trace_array *tr);
  619. extern int trace_selftest_startup_wakeup(struct tracer *trace,
  620. struct trace_array *tr);
  621. extern int trace_selftest_startup_nop(struct tracer *trace,
  622. struct trace_array *tr);
  623. extern int trace_selftest_startup_sched_switch(struct tracer *trace,
  624. struct trace_array *tr);
  625. extern int trace_selftest_startup_branch(struct tracer *trace,
  626. struct trace_array *tr);
  627. /*
  628. * Tracer data references selftest functions that only occur
  629. * on boot up. These can be __init functions. Thus, when selftests
  630. * are enabled, then the tracers need to reference __init functions.
  631. */
  632. #define __tracer_data __refdata
  633. #else
  634. /* Tracers are seldom changed. Optimize when selftests are disabled. */
  635. #define __tracer_data __read_mostly
  636. #endif /* CONFIG_FTRACE_STARTUP_TEST */
  637. extern void *head_page(struct trace_array_cpu *data);
  638. extern unsigned long long ns2usecs(u64 nsec);
  639. extern int
  640. trace_vbprintk(unsigned long ip, const char *fmt, va_list args);
  641. extern int
  642. trace_vprintk(unsigned long ip, const char *fmt, va_list args);
  643. extern int
  644. trace_array_vprintk(struct trace_array *tr,
  645. unsigned long ip, const char *fmt, va_list args);
  646. int trace_array_printk(struct trace_array *tr,
  647. unsigned long ip, const char *fmt, ...);
  648. int trace_array_printk_buf(struct ring_buffer *buffer,
  649. unsigned long ip, const char *fmt, ...);
  650. void trace_printk_seq(struct trace_seq *s);
  651. enum print_line_t print_trace_line(struct trace_iterator *iter);
  652. extern char trace_find_mark(unsigned long long duration);
  653. struct ftrace_hash {
  654. unsigned long size_bits;
  655. struct hlist_head *buckets;
  656. unsigned long count;
  657. struct rcu_head rcu;
  658. };
  659. struct ftrace_func_entry *
  660. ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip);
  661. static __always_inline bool ftrace_hash_empty(struct ftrace_hash *hash)
  662. {
  663. return !hash || !hash->count;
  664. }
  665. /* Standard output formatting function used for function return traces */
  666. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  667. /* Flag options */
  668. #define TRACE_GRAPH_PRINT_OVERRUN 0x1
  669. #define TRACE_GRAPH_PRINT_CPU 0x2
  670. #define TRACE_GRAPH_PRINT_OVERHEAD 0x4
  671. #define TRACE_GRAPH_PRINT_PROC 0x8
  672. #define TRACE_GRAPH_PRINT_DURATION 0x10
  673. #define TRACE_GRAPH_PRINT_ABS_TIME 0x20
  674. #define TRACE_GRAPH_PRINT_IRQS 0x40
  675. #define TRACE_GRAPH_PRINT_TAIL 0x80
  676. #define TRACE_GRAPH_SLEEP_TIME 0x100
  677. #define TRACE_GRAPH_GRAPH_TIME 0x200
  678. #define TRACE_GRAPH_PRINT_FILL_SHIFT 28
  679. #define TRACE_GRAPH_PRINT_FILL_MASK (0x3 << TRACE_GRAPH_PRINT_FILL_SHIFT)
  680. extern void ftrace_graph_sleep_time_control(bool enable);
  681. extern void ftrace_graph_graph_time_control(bool enable);
  682. extern enum print_line_t
  683. print_graph_function_flags(struct trace_iterator *iter, u32 flags);
  684. extern void print_graph_headers_flags(struct seq_file *s, u32 flags);
  685. extern void
  686. trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
  687. extern void graph_trace_open(struct trace_iterator *iter);
  688. extern void graph_trace_close(struct trace_iterator *iter);
  689. extern int __trace_graph_entry(struct trace_array *tr,
  690. struct ftrace_graph_ent *trace,
  691. unsigned long flags, int pc);
  692. extern void __trace_graph_return(struct trace_array *tr,
  693. struct ftrace_graph_ret *trace,
  694. unsigned long flags, int pc);
  695. #ifdef CONFIG_DYNAMIC_FTRACE
  696. extern struct ftrace_hash *ftrace_graph_hash;
  697. extern struct ftrace_hash *ftrace_graph_notrace_hash;
  698. static inline int ftrace_graph_addr(unsigned long addr)
  699. {
  700. int ret = 0;
  701. preempt_disable_notrace();
  702. if (ftrace_hash_empty(ftrace_graph_hash)) {
  703. ret = 1;
  704. goto out;
  705. }
  706. if (ftrace_lookup_ip(ftrace_graph_hash, addr)) {
  707. /*
  708. * If no irqs are to be traced, but a set_graph_function
  709. * is set, and called by an interrupt handler, we still
  710. * want to trace it.
  711. */
  712. if (in_irq())
  713. trace_recursion_set(TRACE_IRQ_BIT);
  714. else
  715. trace_recursion_clear(TRACE_IRQ_BIT);
  716. ret = 1;
  717. }
  718. out:
  719. preempt_enable_notrace();
  720. return ret;
  721. }
  722. static inline int ftrace_graph_notrace_addr(unsigned long addr)
  723. {
  724. int ret = 0;
  725. preempt_disable_notrace();
  726. if (ftrace_lookup_ip(ftrace_graph_notrace_hash, addr))
  727. ret = 1;
  728. preempt_enable_notrace();
  729. return ret;
  730. }
  731. #else
  732. static inline int ftrace_graph_addr(unsigned long addr)
  733. {
  734. return 1;
  735. }
  736. static inline int ftrace_graph_notrace_addr(unsigned long addr)
  737. {
  738. return 0;
  739. }
  740. #endif /* CONFIG_DYNAMIC_FTRACE */
  741. extern unsigned int fgraph_max_depth;
  742. static inline bool ftrace_graph_ignore_func(struct ftrace_graph_ent *trace)
  743. {
  744. /* trace it when it is-nested-in or is a function enabled. */
  745. return !(trace->depth || ftrace_graph_addr(trace->func)) ||
  746. (trace->depth < 0) ||
  747. (fgraph_max_depth && trace->depth >= fgraph_max_depth);
  748. }
  749. #else /* CONFIG_FUNCTION_GRAPH_TRACER */
  750. static inline enum print_line_t
  751. print_graph_function_flags(struct trace_iterator *iter, u32 flags)
  752. {
  753. return TRACE_TYPE_UNHANDLED;
  754. }
  755. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
  756. extern struct list_head ftrace_pids;
  757. #ifdef CONFIG_FUNCTION_TRACER
  758. struct ftrace_func_command {
  759. struct list_head list;
  760. char *name;
  761. int (*func)(struct trace_array *tr,
  762. struct ftrace_hash *hash,
  763. char *func, char *cmd,
  764. char *params, int enable);
  765. };
  766. extern bool ftrace_filter_param __initdata;
  767. static inline int ftrace_trace_task(struct trace_array *tr)
  768. {
  769. return !this_cpu_read(tr->trace_buffer.data->ftrace_ignore_pid);
  770. }
  771. extern int ftrace_is_dead(void);
  772. int ftrace_create_function_files(struct trace_array *tr,
  773. struct dentry *parent);
  774. void ftrace_destroy_function_files(struct trace_array *tr);
  775. void ftrace_init_global_array_ops(struct trace_array *tr);
  776. void ftrace_init_array_ops(struct trace_array *tr, ftrace_func_t func);
  777. void ftrace_reset_array_ops(struct trace_array *tr);
  778. int using_ftrace_ops_list_func(void);
  779. void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d_tracer);
  780. void ftrace_init_tracefs_toplevel(struct trace_array *tr,
  781. struct dentry *d_tracer);
  782. int init_function_trace(void);
  783. void ftrace_pid_follow_fork(struct trace_array *tr, bool enable);
  784. #else
  785. static inline int ftrace_trace_task(struct trace_array *tr)
  786. {
  787. return 1;
  788. }
  789. static inline int ftrace_is_dead(void) { return 0; }
  790. static inline int
  791. ftrace_create_function_files(struct trace_array *tr,
  792. struct dentry *parent)
  793. {
  794. return 0;
  795. }
  796. static inline void ftrace_destroy_function_files(struct trace_array *tr) { }
  797. static inline __init void
  798. ftrace_init_global_array_ops(struct trace_array *tr) { }
  799. static inline void ftrace_reset_array_ops(struct trace_array *tr) { }
  800. static inline void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d) { }
  801. static inline void ftrace_init_tracefs_toplevel(struct trace_array *tr, struct dentry *d) { }
  802. static inline int init_function_trace(void) { return 0; }
  803. static inline void ftrace_pid_follow_fork(struct trace_array *tr, bool enable) { }
  804. /* ftace_func_t type is not defined, use macro instead of static inline */
  805. #define ftrace_init_array_ops(tr, func) do { } while (0)
  806. #endif /* CONFIG_FUNCTION_TRACER */
  807. #if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
  808. struct ftrace_probe_ops {
  809. void (*func)(unsigned long ip,
  810. unsigned long parent_ip,
  811. struct trace_array *tr,
  812. struct ftrace_probe_ops *ops,
  813. void *data);
  814. int (*init)(struct ftrace_probe_ops *ops,
  815. struct trace_array *tr,
  816. unsigned long ip, void *init_data,
  817. void **data);
  818. void (*free)(struct ftrace_probe_ops *ops,
  819. struct trace_array *tr,
  820. unsigned long ip, void *data);
  821. int (*print)(struct seq_file *m,
  822. unsigned long ip,
  823. struct ftrace_probe_ops *ops,
  824. void *data);
  825. };
  826. struct ftrace_func_mapper;
  827. typedef int (*ftrace_mapper_func)(void *data);
  828. struct ftrace_func_mapper *allocate_ftrace_func_mapper(void);
  829. void **ftrace_func_mapper_find_ip(struct ftrace_func_mapper *mapper,
  830. unsigned long ip);
  831. int ftrace_func_mapper_add_ip(struct ftrace_func_mapper *mapper,
  832. unsigned long ip, void *data);
  833. void *ftrace_func_mapper_remove_ip(struct ftrace_func_mapper *mapper,
  834. unsigned long ip);
  835. void free_ftrace_func_mapper(struct ftrace_func_mapper *mapper,
  836. ftrace_mapper_func free_func);
  837. extern int
  838. register_ftrace_function_probe(char *glob, struct trace_array *tr,
  839. struct ftrace_probe_ops *ops, void *data);
  840. extern int
  841. unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr,
  842. struct ftrace_probe_ops *ops);
  843. int register_ftrace_command(struct ftrace_func_command *cmd);
  844. int unregister_ftrace_command(struct ftrace_func_command *cmd);
  845. void ftrace_create_filter_files(struct ftrace_ops *ops,
  846. struct dentry *parent);
  847. void ftrace_destroy_filter_files(struct ftrace_ops *ops);
  848. #else
  849. struct ftrace_func_command;
  850. static inline __init int register_ftrace_command(struct ftrace_func_command *cmd)
  851. {
  852. return -EINVAL;
  853. }
  854. static inline __init int unregister_ftrace_command(char *cmd_name)
  855. {
  856. return -EINVAL;
  857. }
  858. /*
  859. * The ops parameter passed in is usually undefined.
  860. * This must be a macro.
  861. */
  862. #define ftrace_create_filter_files(ops, parent) do { } while (0)
  863. #define ftrace_destroy_filter_files(ops) do { } while (0)
  864. #endif /* CONFIG_FUNCTION_TRACER && CONFIG_DYNAMIC_FTRACE */
  865. bool ftrace_event_is_function(struct trace_event_call *call);
  866. /*
  867. * struct trace_parser - servers for reading the user input separated by spaces
  868. * @cont: set if the input is not complete - no final space char was found
  869. * @buffer: holds the parsed user input
  870. * @idx: user input length
  871. * @size: buffer size
  872. */
  873. struct trace_parser {
  874. bool cont;
  875. char *buffer;
  876. unsigned idx;
  877. unsigned size;
  878. };
  879. static inline bool trace_parser_loaded(struct trace_parser *parser)
  880. {
  881. return (parser->idx != 0);
  882. }
  883. static inline bool trace_parser_cont(struct trace_parser *parser)
  884. {
  885. return parser->cont;
  886. }
  887. static inline void trace_parser_clear(struct trace_parser *parser)
  888. {
  889. parser->cont = false;
  890. parser->idx = 0;
  891. }
  892. extern int trace_parser_get_init(struct trace_parser *parser, int size);
  893. extern void trace_parser_put(struct trace_parser *parser);
  894. extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
  895. size_t cnt, loff_t *ppos);
  896. /*
  897. * Only create function graph options if function graph is configured.
  898. */
  899. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  900. # define FGRAPH_FLAGS \
  901. C(DISPLAY_GRAPH, "display-graph"),
  902. #else
  903. # define FGRAPH_FLAGS
  904. #endif
  905. #ifdef CONFIG_BRANCH_TRACER
  906. # define BRANCH_FLAGS \
  907. C(BRANCH, "branch"),
  908. #else
  909. # define BRANCH_FLAGS
  910. #endif
  911. #ifdef CONFIG_FUNCTION_TRACER
  912. # define FUNCTION_FLAGS \
  913. C(FUNCTION, "function-trace"), \
  914. C(FUNC_FORK, "function-fork"),
  915. # define FUNCTION_DEFAULT_FLAGS TRACE_ITER_FUNCTION
  916. #else
  917. # define FUNCTION_FLAGS
  918. # define FUNCTION_DEFAULT_FLAGS 0UL
  919. # define TRACE_ITER_FUNC_FORK 0UL
  920. #endif
  921. #ifdef CONFIG_STACKTRACE
  922. # define STACK_FLAGS \
  923. C(STACKTRACE, "stacktrace"),
  924. #else
  925. # define STACK_FLAGS
  926. #endif
  927. /*
  928. * trace_iterator_flags is an enumeration that defines bit
  929. * positions into trace_flags that controls the output.
  930. *
  931. * NOTE: These bits must match the trace_options array in
  932. * trace.c (this macro guarantees it).
  933. */
  934. #define TRACE_FLAGS \
  935. C(PRINT_PARENT, "print-parent"), \
  936. C(SYM_OFFSET, "sym-offset"), \
  937. C(SYM_ADDR, "sym-addr"), \
  938. C(VERBOSE, "verbose"), \
  939. C(RAW, "raw"), \
  940. C(HEX, "hex"), \
  941. C(BIN, "bin"), \
  942. C(BLOCK, "block"), \
  943. C(PRINTK, "trace_printk"), \
  944. C(ANNOTATE, "annotate"), \
  945. C(USERSTACKTRACE, "userstacktrace"), \
  946. C(SYM_USEROBJ, "sym-userobj"), \
  947. C(PRINTK_MSGONLY, "printk-msg-only"), \
  948. C(CONTEXT_INFO, "context-info"), /* Print pid/cpu/time */ \
  949. C(LATENCY_FMT, "latency-format"), \
  950. C(RECORD_CMD, "record-cmd"), \
  951. C(OVERWRITE, "overwrite"), \
  952. C(STOP_ON_FREE, "disable_on_free"), \
  953. C(IRQ_INFO, "irq-info"), \
  954. C(MARKERS, "markers"), \
  955. C(EVENT_FORK, "event-fork"), \
  956. FUNCTION_FLAGS \
  957. FGRAPH_FLAGS \
  958. STACK_FLAGS \
  959. BRANCH_FLAGS
  960. /*
  961. * By defining C, we can make TRACE_FLAGS a list of bit names
  962. * that will define the bits for the flag masks.
  963. */
  964. #undef C
  965. #define C(a, b) TRACE_ITER_##a##_BIT
  966. enum trace_iterator_bits {
  967. TRACE_FLAGS
  968. /* Make sure we don't go more than we have bits for */
  969. TRACE_ITER_LAST_BIT
  970. };
  971. /*
  972. * By redefining C, we can make TRACE_FLAGS a list of masks that
  973. * use the bits as defined above.
  974. */
  975. #undef C
  976. #define C(a, b) TRACE_ITER_##a = (1 << TRACE_ITER_##a##_BIT)
  977. enum trace_iterator_flags { TRACE_FLAGS };
  978. /*
  979. * TRACE_ITER_SYM_MASK masks the options in trace_flags that
  980. * control the output of kernel symbols.
  981. */
  982. #define TRACE_ITER_SYM_MASK \
  983. (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR)
  984. extern struct tracer nop_trace;
  985. #ifdef CONFIG_BRANCH_TRACER
  986. extern int enable_branch_tracing(struct trace_array *tr);
  987. extern void disable_branch_tracing(void);
  988. static inline int trace_branch_enable(struct trace_array *tr)
  989. {
  990. if (tr->trace_flags & TRACE_ITER_BRANCH)
  991. return enable_branch_tracing(tr);
  992. return 0;
  993. }
  994. static inline void trace_branch_disable(void)
  995. {
  996. /* due to races, always disable */
  997. disable_branch_tracing();
  998. }
  999. #else
  1000. static inline int trace_branch_enable(struct trace_array *tr)
  1001. {
  1002. return 0;
  1003. }
  1004. static inline void trace_branch_disable(void)
  1005. {
  1006. }
  1007. #endif /* CONFIG_BRANCH_TRACER */
  1008. /* set ring buffers to default size if not already done so */
  1009. int tracing_update_buffers(void);
  1010. struct ftrace_event_field {
  1011. struct list_head link;
  1012. const char *name;
  1013. const char *type;
  1014. int filter_type;
  1015. int offset;
  1016. int size;
  1017. int is_signed;
  1018. };
  1019. struct event_filter {
  1020. int n_preds; /* Number assigned */
  1021. int a_preds; /* allocated */
  1022. struct filter_pred *preds;
  1023. struct filter_pred *root;
  1024. char *filter_string;
  1025. };
  1026. struct event_subsystem {
  1027. struct list_head list;
  1028. const char *name;
  1029. struct event_filter *filter;
  1030. int ref_count;
  1031. };
  1032. struct trace_subsystem_dir {
  1033. struct list_head list;
  1034. struct event_subsystem *subsystem;
  1035. struct trace_array *tr;
  1036. struct dentry *entry;
  1037. int ref_count;
  1038. int nr_events;
  1039. };
  1040. extern int call_filter_check_discard(struct trace_event_call *call, void *rec,
  1041. struct ring_buffer *buffer,
  1042. struct ring_buffer_event *event);
  1043. void trace_buffer_unlock_commit_regs(struct trace_array *tr,
  1044. struct ring_buffer *buffer,
  1045. struct ring_buffer_event *event,
  1046. unsigned long flags, int pc,
  1047. struct pt_regs *regs);
  1048. static inline void trace_buffer_unlock_commit(struct trace_array *tr,
  1049. struct ring_buffer *buffer,
  1050. struct ring_buffer_event *event,
  1051. unsigned long flags, int pc)
  1052. {
  1053. trace_buffer_unlock_commit_regs(tr, buffer, event, flags, pc, NULL);
  1054. }
  1055. DECLARE_PER_CPU(struct ring_buffer_event *, trace_buffered_event);
  1056. DECLARE_PER_CPU(int, trace_buffered_event_cnt);
  1057. void trace_buffered_event_disable(void);
  1058. void trace_buffered_event_enable(void);
  1059. static inline void
  1060. __trace_event_discard_commit(struct ring_buffer *buffer,
  1061. struct ring_buffer_event *event)
  1062. {
  1063. if (this_cpu_read(trace_buffered_event) == event) {
  1064. /* Simply release the temp buffer */
  1065. this_cpu_dec(trace_buffered_event_cnt);
  1066. return;
  1067. }
  1068. ring_buffer_discard_commit(buffer, event);
  1069. }
  1070. /*
  1071. * Helper function for event_trigger_unlock_commit{_regs}().
  1072. * If there are event triggers attached to this event that requires
  1073. * filtering against its fields, then they wil be called as the
  1074. * entry already holds the field information of the current event.
  1075. *
  1076. * It also checks if the event should be discarded or not.
  1077. * It is to be discarded if the event is soft disabled and the
  1078. * event was only recorded to process triggers, or if the event
  1079. * filter is active and this event did not match the filters.
  1080. *
  1081. * Returns true if the event is discarded, false otherwise.
  1082. */
  1083. static inline bool
  1084. __event_trigger_test_discard(struct trace_event_file *file,
  1085. struct ring_buffer *buffer,
  1086. struct ring_buffer_event *event,
  1087. void *entry,
  1088. enum event_trigger_type *tt)
  1089. {
  1090. unsigned long eflags = file->flags;
  1091. if (eflags & EVENT_FILE_FL_TRIGGER_COND)
  1092. *tt = event_triggers_call(file, entry);
  1093. if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags) ||
  1094. (unlikely(file->flags & EVENT_FILE_FL_FILTERED) &&
  1095. !filter_match_preds(file->filter, entry))) {
  1096. __trace_event_discard_commit(buffer, event);
  1097. return true;
  1098. }
  1099. return false;
  1100. }
  1101. /**
  1102. * event_trigger_unlock_commit - handle triggers and finish event commit
  1103. * @file: The file pointer assoctiated to the event
  1104. * @buffer: The ring buffer that the event is being written to
  1105. * @event: The event meta data in the ring buffer
  1106. * @entry: The event itself
  1107. * @irq_flags: The state of the interrupts at the start of the event
  1108. * @pc: The state of the preempt count at the start of the event.
  1109. *
  1110. * This is a helper function to handle triggers that require data
  1111. * from the event itself. It also tests the event against filters and
  1112. * if the event is soft disabled and should be discarded.
  1113. */
  1114. static inline void
  1115. event_trigger_unlock_commit(struct trace_event_file *file,
  1116. struct ring_buffer *buffer,
  1117. struct ring_buffer_event *event,
  1118. void *entry, unsigned long irq_flags, int pc)
  1119. {
  1120. enum event_trigger_type tt = ETT_NONE;
  1121. if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
  1122. trace_buffer_unlock_commit(file->tr, buffer, event, irq_flags, pc);
  1123. if (tt)
  1124. event_triggers_post_call(file, tt, entry);
  1125. }
  1126. /**
  1127. * event_trigger_unlock_commit_regs - handle triggers and finish event commit
  1128. * @file: The file pointer assoctiated to the event
  1129. * @buffer: The ring buffer that the event is being written to
  1130. * @event: The event meta data in the ring buffer
  1131. * @entry: The event itself
  1132. * @irq_flags: The state of the interrupts at the start of the event
  1133. * @pc: The state of the preempt count at the start of the event.
  1134. *
  1135. * This is a helper function to handle triggers that require data
  1136. * from the event itself. It also tests the event against filters and
  1137. * if the event is soft disabled and should be discarded.
  1138. *
  1139. * Same as event_trigger_unlock_commit() but calls
  1140. * trace_buffer_unlock_commit_regs() instead of trace_buffer_unlock_commit().
  1141. */
  1142. static inline void
  1143. event_trigger_unlock_commit_regs(struct trace_event_file *file,
  1144. struct ring_buffer *buffer,
  1145. struct ring_buffer_event *event,
  1146. void *entry, unsigned long irq_flags, int pc,
  1147. struct pt_regs *regs)
  1148. {
  1149. enum event_trigger_type tt = ETT_NONE;
  1150. if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
  1151. trace_buffer_unlock_commit_regs(file->tr, buffer, event,
  1152. irq_flags, pc, regs);
  1153. if (tt)
  1154. event_triggers_post_call(file, tt, entry);
  1155. }
  1156. #define FILTER_PRED_INVALID ((unsigned short)-1)
  1157. #define FILTER_PRED_IS_RIGHT (1 << 15)
  1158. #define FILTER_PRED_FOLD (1 << 15)
  1159. /*
  1160. * The max preds is the size of unsigned short with
  1161. * two flags at the MSBs. One bit is used for both the IS_RIGHT
  1162. * and FOLD flags. The other is reserved.
  1163. *
  1164. * 2^14 preds is way more than enough.
  1165. */
  1166. #define MAX_FILTER_PRED 16384
  1167. struct filter_pred;
  1168. struct regex;
  1169. typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event);
  1170. typedef int (*regex_match_func)(char *str, struct regex *r, int len);
  1171. enum regex_type {
  1172. MATCH_FULL = 0,
  1173. MATCH_FRONT_ONLY,
  1174. MATCH_MIDDLE_ONLY,
  1175. MATCH_END_ONLY,
  1176. MATCH_GLOB,
  1177. };
  1178. struct regex {
  1179. char pattern[MAX_FILTER_STR_VAL];
  1180. int len;
  1181. int field_len;
  1182. regex_match_func match;
  1183. };
  1184. struct filter_pred {
  1185. filter_pred_fn_t fn;
  1186. u64 val;
  1187. struct regex regex;
  1188. unsigned short *ops;
  1189. struct ftrace_event_field *field;
  1190. int offset;
  1191. int not;
  1192. int op;
  1193. unsigned short index;
  1194. unsigned short parent;
  1195. unsigned short left;
  1196. unsigned short right;
  1197. };
  1198. static inline bool is_string_field(struct ftrace_event_field *field)
  1199. {
  1200. return field->filter_type == FILTER_DYN_STRING ||
  1201. field->filter_type == FILTER_STATIC_STRING ||
  1202. field->filter_type == FILTER_PTR_STRING ||
  1203. field->filter_type == FILTER_COMM;
  1204. }
  1205. static inline bool is_function_field(struct ftrace_event_field *field)
  1206. {
  1207. return field->filter_type == FILTER_TRACE_FN;
  1208. }
  1209. extern enum regex_type
  1210. filter_parse_regex(char *buff, int len, char **search, int *not);
  1211. extern void print_event_filter(struct trace_event_file *file,
  1212. struct trace_seq *s);
  1213. extern int apply_event_filter(struct trace_event_file *file,
  1214. char *filter_string);
  1215. extern int apply_subsystem_event_filter(struct trace_subsystem_dir *dir,
  1216. char *filter_string);
  1217. extern void print_subsystem_event_filter(struct event_subsystem *system,
  1218. struct trace_seq *s);
  1219. extern int filter_assign_type(const char *type);
  1220. extern int create_event_filter(struct trace_event_call *call,
  1221. char *filter_str, bool set_str,
  1222. struct event_filter **filterp);
  1223. extern void free_event_filter(struct event_filter *filter);
  1224. struct ftrace_event_field *
  1225. trace_find_event_field(struct trace_event_call *call, char *name);
  1226. extern void trace_event_enable_cmd_record(bool enable);
  1227. extern int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr);
  1228. extern int event_trace_del_tracer(struct trace_array *tr);
  1229. extern struct trace_event_file *find_event_file(struct trace_array *tr,
  1230. const char *system,
  1231. const char *event);
  1232. static inline void *event_file_data(struct file *filp)
  1233. {
  1234. return ACCESS_ONCE(file_inode(filp)->i_private);
  1235. }
  1236. extern struct mutex event_mutex;
  1237. extern struct list_head ftrace_events;
  1238. extern const struct file_operations event_trigger_fops;
  1239. extern const struct file_operations event_hist_fops;
  1240. #ifdef CONFIG_HIST_TRIGGERS
  1241. extern int register_trigger_hist_cmd(void);
  1242. extern int register_trigger_hist_enable_disable_cmds(void);
  1243. #else
  1244. static inline int register_trigger_hist_cmd(void) { return 0; }
  1245. static inline int register_trigger_hist_enable_disable_cmds(void) { return 0; }
  1246. #endif
  1247. extern int register_trigger_cmds(void);
  1248. extern void clear_event_triggers(struct trace_array *tr);
  1249. struct event_trigger_data {
  1250. unsigned long count;
  1251. int ref;
  1252. struct event_trigger_ops *ops;
  1253. struct event_command *cmd_ops;
  1254. struct event_filter __rcu *filter;
  1255. char *filter_str;
  1256. void *private_data;
  1257. bool paused;
  1258. bool paused_tmp;
  1259. struct list_head list;
  1260. char *name;
  1261. struct list_head named_list;
  1262. struct event_trigger_data *named_data;
  1263. };
  1264. /* Avoid typos */
  1265. #define ENABLE_EVENT_STR "enable_event"
  1266. #define DISABLE_EVENT_STR "disable_event"
  1267. #define ENABLE_HIST_STR "enable_hist"
  1268. #define DISABLE_HIST_STR "disable_hist"
  1269. struct enable_trigger_data {
  1270. struct trace_event_file *file;
  1271. bool enable;
  1272. bool hist;
  1273. };
  1274. extern int event_enable_trigger_print(struct seq_file *m,
  1275. struct event_trigger_ops *ops,
  1276. struct event_trigger_data *data);
  1277. extern void event_enable_trigger_free(struct event_trigger_ops *ops,
  1278. struct event_trigger_data *data);
  1279. extern int event_enable_trigger_func(struct event_command *cmd_ops,
  1280. struct trace_event_file *file,
  1281. char *glob, char *cmd, char *param);
  1282. extern int event_enable_register_trigger(char *glob,
  1283. struct event_trigger_ops *ops,
  1284. struct event_trigger_data *data,
  1285. struct trace_event_file *file);
  1286. extern void event_enable_unregister_trigger(char *glob,
  1287. struct event_trigger_ops *ops,
  1288. struct event_trigger_data *test,
  1289. struct trace_event_file *file);
  1290. extern void trigger_data_free(struct event_trigger_data *data);
  1291. extern int event_trigger_init(struct event_trigger_ops *ops,
  1292. struct event_trigger_data *data);
  1293. extern int trace_event_trigger_enable_disable(struct trace_event_file *file,
  1294. int trigger_enable);
  1295. extern void update_cond_flag(struct trace_event_file *file);
  1296. extern void unregister_trigger(char *glob, struct event_trigger_ops *ops,
  1297. struct event_trigger_data *test,
  1298. struct trace_event_file *file);
  1299. extern int set_trigger_filter(char *filter_str,
  1300. struct event_trigger_data *trigger_data,
  1301. struct trace_event_file *file);
  1302. extern struct event_trigger_data *find_named_trigger(const char *name);
  1303. extern bool is_named_trigger(struct event_trigger_data *test);
  1304. extern int save_named_trigger(const char *name,
  1305. struct event_trigger_data *data);
  1306. extern void del_named_trigger(struct event_trigger_data *data);
  1307. extern void pause_named_trigger(struct event_trigger_data *data);
  1308. extern void unpause_named_trigger(struct event_trigger_data *data);
  1309. extern void set_named_trigger_data(struct event_trigger_data *data,
  1310. struct event_trigger_data *named_data);
  1311. extern int register_event_command(struct event_command *cmd);
  1312. extern int unregister_event_command(struct event_command *cmd);
  1313. extern int register_trigger_hist_enable_disable_cmds(void);
  1314. /**
  1315. * struct event_trigger_ops - callbacks for trace event triggers
  1316. *
  1317. * The methods in this structure provide per-event trigger hooks for
  1318. * various trigger operations.
  1319. *
  1320. * All the methods below, except for @init() and @free(), must be
  1321. * implemented.
  1322. *
  1323. * @func: The trigger 'probe' function called when the triggering
  1324. * event occurs. The data passed into this callback is the data
  1325. * that was supplied to the event_command @reg() function that
  1326. * registered the trigger (see struct event_command) along with
  1327. * the trace record, rec.
  1328. *
  1329. * @init: An optional initialization function called for the trigger
  1330. * when the trigger is registered (via the event_command reg()
  1331. * function). This can be used to perform per-trigger
  1332. * initialization such as incrementing a per-trigger reference
  1333. * count, for instance. This is usually implemented by the
  1334. * generic utility function @event_trigger_init() (see
  1335. * trace_event_triggers.c).
  1336. *
  1337. * @free: An optional de-initialization function called for the
  1338. * trigger when the trigger is unregistered (via the
  1339. * event_command @reg() function). This can be used to perform
  1340. * per-trigger de-initialization such as decrementing a
  1341. * per-trigger reference count and freeing corresponding trigger
  1342. * data, for instance. This is usually implemented by the
  1343. * generic utility function @event_trigger_free() (see
  1344. * trace_event_triggers.c).
  1345. *
  1346. * @print: The callback function invoked to have the trigger print
  1347. * itself. This is usually implemented by a wrapper function
  1348. * that calls the generic utility function @event_trigger_print()
  1349. * (see trace_event_triggers.c).
  1350. */
  1351. struct event_trigger_ops {
  1352. void (*func)(struct event_trigger_data *data,
  1353. void *rec);
  1354. int (*init)(struct event_trigger_ops *ops,
  1355. struct event_trigger_data *data);
  1356. void (*free)(struct event_trigger_ops *ops,
  1357. struct event_trigger_data *data);
  1358. int (*print)(struct seq_file *m,
  1359. struct event_trigger_ops *ops,
  1360. struct event_trigger_data *data);
  1361. };
  1362. /**
  1363. * struct event_command - callbacks and data members for event commands
  1364. *
  1365. * Event commands are invoked by users by writing the command name
  1366. * into the 'trigger' file associated with a trace event. The
  1367. * parameters associated with a specific invocation of an event
  1368. * command are used to create an event trigger instance, which is
  1369. * added to the list of trigger instances associated with that trace
  1370. * event. When the event is hit, the set of triggers associated with
  1371. * that event is invoked.
  1372. *
  1373. * The data members in this structure provide per-event command data
  1374. * for various event commands.
  1375. *
  1376. * All the data members below, except for @post_trigger, must be set
  1377. * for each event command.
  1378. *
  1379. * @name: The unique name that identifies the event command. This is
  1380. * the name used when setting triggers via trigger files.
  1381. *
  1382. * @trigger_type: A unique id that identifies the event command
  1383. * 'type'. This value has two purposes, the first to ensure that
  1384. * only one trigger of the same type can be set at a given time
  1385. * for a particular event e.g. it doesn't make sense to have both
  1386. * a traceon and traceoff trigger attached to a single event at
  1387. * the same time, so traceon and traceoff have the same type
  1388. * though they have different names. The @trigger_type value is
  1389. * also used as a bit value for deferring the actual trigger
  1390. * action until after the current event is finished. Some
  1391. * commands need to do this if they themselves log to the trace
  1392. * buffer (see the @post_trigger() member below). @trigger_type
  1393. * values are defined by adding new values to the trigger_type
  1394. * enum in include/linux/trace_events.h.
  1395. *
  1396. * @flags: See the enum event_command_flags below.
  1397. *
  1398. * All the methods below, except for @set_filter() and @unreg_all(),
  1399. * must be implemented.
  1400. *
  1401. * @func: The callback function responsible for parsing and
  1402. * registering the trigger written to the 'trigger' file by the
  1403. * user. It allocates the trigger instance and registers it with
  1404. * the appropriate trace event. It makes use of the other
  1405. * event_command callback functions to orchestrate this, and is
  1406. * usually implemented by the generic utility function
  1407. * @event_trigger_callback() (see trace_event_triggers.c).
  1408. *
  1409. * @reg: Adds the trigger to the list of triggers associated with the
  1410. * event, and enables the event trigger itself, after
  1411. * initializing it (via the event_trigger_ops @init() function).
  1412. * This is also where commands can use the @trigger_type value to
  1413. * make the decision as to whether or not multiple instances of
  1414. * the trigger should be allowed. This is usually implemented by
  1415. * the generic utility function @register_trigger() (see
  1416. * trace_event_triggers.c).
  1417. *
  1418. * @unreg: Removes the trigger from the list of triggers associated
  1419. * with the event, and disables the event trigger itself, after
  1420. * initializing it (via the event_trigger_ops @free() function).
  1421. * This is usually implemented by the generic utility function
  1422. * @unregister_trigger() (see trace_event_triggers.c).
  1423. *
  1424. * @unreg_all: An optional function called to remove all the triggers
  1425. * from the list of triggers associated with the event. Called
  1426. * when a trigger file is opened in truncate mode.
  1427. *
  1428. * @set_filter: An optional function called to parse and set a filter
  1429. * for the trigger. If no @set_filter() method is set for the
  1430. * event command, filters set by the user for the command will be
  1431. * ignored. This is usually implemented by the generic utility
  1432. * function @set_trigger_filter() (see trace_event_triggers.c).
  1433. *
  1434. * @get_trigger_ops: The callback function invoked to retrieve the
  1435. * event_trigger_ops implementation associated with the command.
  1436. */
  1437. struct event_command {
  1438. struct list_head list;
  1439. char *name;
  1440. enum event_trigger_type trigger_type;
  1441. int flags;
  1442. int (*func)(struct event_command *cmd_ops,
  1443. struct trace_event_file *file,
  1444. char *glob, char *cmd, char *params);
  1445. int (*reg)(char *glob,
  1446. struct event_trigger_ops *ops,
  1447. struct event_trigger_data *data,
  1448. struct trace_event_file *file);
  1449. void (*unreg)(char *glob,
  1450. struct event_trigger_ops *ops,
  1451. struct event_trigger_data *data,
  1452. struct trace_event_file *file);
  1453. void (*unreg_all)(struct trace_event_file *file);
  1454. int (*set_filter)(char *filter_str,
  1455. struct event_trigger_data *data,
  1456. struct trace_event_file *file);
  1457. struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
  1458. };
  1459. /**
  1460. * enum event_command_flags - flags for struct event_command
  1461. *
  1462. * @POST_TRIGGER: A flag that says whether or not this command needs
  1463. * to have its action delayed until after the current event has
  1464. * been closed. Some triggers need to avoid being invoked while
  1465. * an event is currently in the process of being logged, since
  1466. * the trigger may itself log data into the trace buffer. Thus
  1467. * we make sure the current event is committed before invoking
  1468. * those triggers. To do that, the trigger invocation is split
  1469. * in two - the first part checks the filter using the current
  1470. * trace record; if a command has the @post_trigger flag set, it
  1471. * sets a bit for itself in the return value, otherwise it
  1472. * directly invokes the trigger. Once all commands have been
  1473. * either invoked or set their return flag, the current record is
  1474. * either committed or discarded. At that point, if any commands
  1475. * have deferred their triggers, those commands are finally
  1476. * invoked following the close of the current event. In other
  1477. * words, if the event_trigger_ops @func() probe implementation
  1478. * itself logs to the trace buffer, this flag should be set,
  1479. * otherwise it can be left unspecified.
  1480. *
  1481. * @NEEDS_REC: A flag that says whether or not this command needs
  1482. * access to the trace record in order to perform its function,
  1483. * regardless of whether or not it has a filter associated with
  1484. * it (filters make a trigger require access to the trace record
  1485. * but are not always present).
  1486. */
  1487. enum event_command_flags {
  1488. EVENT_CMD_FL_POST_TRIGGER = 1,
  1489. EVENT_CMD_FL_NEEDS_REC = 2,
  1490. };
  1491. static inline bool event_command_post_trigger(struct event_command *cmd_ops)
  1492. {
  1493. return cmd_ops->flags & EVENT_CMD_FL_POST_TRIGGER;
  1494. }
  1495. static inline bool event_command_needs_rec(struct event_command *cmd_ops)
  1496. {
  1497. return cmd_ops->flags & EVENT_CMD_FL_NEEDS_REC;
  1498. }
  1499. extern int trace_event_enable_disable(struct trace_event_file *file,
  1500. int enable, int soft_disable);
  1501. extern int tracing_alloc_snapshot(void);
  1502. extern const char *__start___trace_bprintk_fmt[];
  1503. extern const char *__stop___trace_bprintk_fmt[];
  1504. extern const char *__start___tracepoint_str[];
  1505. extern const char *__stop___tracepoint_str[];
  1506. void trace_printk_control(bool enabled);
  1507. void trace_printk_init_buffers(void);
  1508. void trace_printk_start_comm(void);
  1509. int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
  1510. int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
  1511. /*
  1512. * Normal trace_printk() and friends allocates special buffers
  1513. * to do the manipulation, as well as saves the print formats
  1514. * into sections to display. But the trace infrastructure wants
  1515. * to use these without the added overhead at the price of being
  1516. * a bit slower (used mainly for warnings, where we don't care
  1517. * about performance). The internal_trace_puts() is for such
  1518. * a purpose.
  1519. */
  1520. #define internal_trace_puts(str) __trace_puts(_THIS_IP_, str, strlen(str))
  1521. #undef FTRACE_ENTRY
  1522. #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
  1523. extern struct trace_event_call \
  1524. __aligned(4) event_##call;
  1525. #undef FTRACE_ENTRY_DUP
  1526. #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \
  1527. FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
  1528. filter)
  1529. #undef FTRACE_ENTRY_PACKED
  1530. #define FTRACE_ENTRY_PACKED(call, struct_name, id, tstruct, print, filter) \
  1531. FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
  1532. filter)
  1533. #include "trace_entries.h"
  1534. #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER)
  1535. int perf_ftrace_event_register(struct trace_event_call *call,
  1536. enum trace_reg type, void *data);
  1537. #else
  1538. #define perf_ftrace_event_register NULL
  1539. #endif
  1540. #ifdef CONFIG_FTRACE_SYSCALLS
  1541. void init_ftrace_syscalls(void);
  1542. const char *get_syscall_name(int syscall);
  1543. #else
  1544. static inline void init_ftrace_syscalls(void) { }
  1545. static inline const char *get_syscall_name(int syscall)
  1546. {
  1547. return NULL;
  1548. }
  1549. #endif
  1550. #ifdef CONFIG_EVENT_TRACING
  1551. void trace_event_init(void);
  1552. void trace_event_enum_update(struct trace_enum_map **map, int len);
  1553. #else
  1554. static inline void __init trace_event_init(void) { }
  1555. static inline void trace_event_enum_update(struct trace_enum_map **map, int len) { }
  1556. #endif
  1557. extern struct trace_iterator *tracepoint_print_iter;
  1558. #endif /* _LINUX_KERNEL_TRACE_H */