trace.h 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784
  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. void ftrace_clear_pids(struct trace_array *tr);
  783. int init_function_trace(void);
  784. void ftrace_pid_follow_fork(struct trace_array *tr, bool enable);
  785. #else
  786. static inline int ftrace_trace_task(struct trace_array *tr)
  787. {
  788. return 1;
  789. }
  790. static inline int ftrace_is_dead(void) { return 0; }
  791. static inline int
  792. ftrace_create_function_files(struct trace_array *tr,
  793. struct dentry *parent)
  794. {
  795. return 0;
  796. }
  797. static inline void ftrace_destroy_function_files(struct trace_array *tr) { }
  798. static inline __init void
  799. ftrace_init_global_array_ops(struct trace_array *tr) { }
  800. static inline void ftrace_reset_array_ops(struct trace_array *tr) { }
  801. static inline void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d) { }
  802. static inline void ftrace_init_tracefs_toplevel(struct trace_array *tr, struct dentry *d) { }
  803. static inline void ftrace_clear_pids(struct trace_array *tr) { }
  804. static inline int init_function_trace(void) { return 0; }
  805. static inline void ftrace_pid_follow_fork(struct trace_array *tr, bool enable) { }
  806. /* ftace_func_t type is not defined, use macro instead of static inline */
  807. #define ftrace_init_array_ops(tr, func) do { } while (0)
  808. #endif /* CONFIG_FUNCTION_TRACER */
  809. #if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
  810. struct ftrace_probe_ops {
  811. void (*func)(unsigned long ip,
  812. unsigned long parent_ip,
  813. struct trace_array *tr,
  814. struct ftrace_probe_ops *ops,
  815. void *data);
  816. int (*init)(struct ftrace_probe_ops *ops,
  817. struct trace_array *tr,
  818. unsigned long ip, void *init_data,
  819. void **data);
  820. void (*free)(struct ftrace_probe_ops *ops,
  821. struct trace_array *tr,
  822. unsigned long ip, void *data);
  823. int (*print)(struct seq_file *m,
  824. unsigned long ip,
  825. struct ftrace_probe_ops *ops,
  826. void *data);
  827. };
  828. struct ftrace_func_mapper;
  829. typedef int (*ftrace_mapper_func)(void *data);
  830. struct ftrace_func_mapper *allocate_ftrace_func_mapper(void);
  831. void **ftrace_func_mapper_find_ip(struct ftrace_func_mapper *mapper,
  832. unsigned long ip);
  833. int ftrace_func_mapper_add_ip(struct ftrace_func_mapper *mapper,
  834. unsigned long ip, void *data);
  835. void *ftrace_func_mapper_remove_ip(struct ftrace_func_mapper *mapper,
  836. unsigned long ip);
  837. void free_ftrace_func_mapper(struct ftrace_func_mapper *mapper,
  838. ftrace_mapper_func free_func);
  839. extern int
  840. register_ftrace_function_probe(char *glob, struct trace_array *tr,
  841. struct ftrace_probe_ops *ops, void *data);
  842. extern int
  843. unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr,
  844. struct ftrace_probe_ops *ops);
  845. extern void clear_ftrace_function_probes(struct trace_array *tr);
  846. int register_ftrace_command(struct ftrace_func_command *cmd);
  847. int unregister_ftrace_command(struct ftrace_func_command *cmd);
  848. void ftrace_create_filter_files(struct ftrace_ops *ops,
  849. struct dentry *parent);
  850. void ftrace_destroy_filter_files(struct ftrace_ops *ops);
  851. #else
  852. struct ftrace_func_command;
  853. static inline __init int register_ftrace_command(struct ftrace_func_command *cmd)
  854. {
  855. return -EINVAL;
  856. }
  857. static inline __init int unregister_ftrace_command(char *cmd_name)
  858. {
  859. return -EINVAL;
  860. }
  861. static inline void clear_ftrace_function_probes(struct trace_array *tr)
  862. {
  863. }
  864. /*
  865. * The ops parameter passed in is usually undefined.
  866. * This must be a macro.
  867. */
  868. #define ftrace_create_filter_files(ops, parent) do { } while (0)
  869. #define ftrace_destroy_filter_files(ops) do { } while (0)
  870. #endif /* CONFIG_FUNCTION_TRACER && CONFIG_DYNAMIC_FTRACE */
  871. bool ftrace_event_is_function(struct trace_event_call *call);
  872. /*
  873. * struct trace_parser - servers for reading the user input separated by spaces
  874. * @cont: set if the input is not complete - no final space char was found
  875. * @buffer: holds the parsed user input
  876. * @idx: user input length
  877. * @size: buffer size
  878. */
  879. struct trace_parser {
  880. bool cont;
  881. char *buffer;
  882. unsigned idx;
  883. unsigned size;
  884. };
  885. static inline bool trace_parser_loaded(struct trace_parser *parser)
  886. {
  887. return (parser->idx != 0);
  888. }
  889. static inline bool trace_parser_cont(struct trace_parser *parser)
  890. {
  891. return parser->cont;
  892. }
  893. static inline void trace_parser_clear(struct trace_parser *parser)
  894. {
  895. parser->cont = false;
  896. parser->idx = 0;
  897. }
  898. extern int trace_parser_get_init(struct trace_parser *parser, int size);
  899. extern void trace_parser_put(struct trace_parser *parser);
  900. extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
  901. size_t cnt, loff_t *ppos);
  902. /*
  903. * Only create function graph options if function graph is configured.
  904. */
  905. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  906. # define FGRAPH_FLAGS \
  907. C(DISPLAY_GRAPH, "display-graph"),
  908. #else
  909. # define FGRAPH_FLAGS
  910. #endif
  911. #ifdef CONFIG_BRANCH_TRACER
  912. # define BRANCH_FLAGS \
  913. C(BRANCH, "branch"),
  914. #else
  915. # define BRANCH_FLAGS
  916. #endif
  917. #ifdef CONFIG_FUNCTION_TRACER
  918. # define FUNCTION_FLAGS \
  919. C(FUNCTION, "function-trace"), \
  920. C(FUNC_FORK, "function-fork"),
  921. # define FUNCTION_DEFAULT_FLAGS TRACE_ITER_FUNCTION
  922. #else
  923. # define FUNCTION_FLAGS
  924. # define FUNCTION_DEFAULT_FLAGS 0UL
  925. # define TRACE_ITER_FUNC_FORK 0UL
  926. #endif
  927. #ifdef CONFIG_STACKTRACE
  928. # define STACK_FLAGS \
  929. C(STACKTRACE, "stacktrace"),
  930. #else
  931. # define STACK_FLAGS
  932. #endif
  933. /*
  934. * trace_iterator_flags is an enumeration that defines bit
  935. * positions into trace_flags that controls the output.
  936. *
  937. * NOTE: These bits must match the trace_options array in
  938. * trace.c (this macro guarantees it).
  939. */
  940. #define TRACE_FLAGS \
  941. C(PRINT_PARENT, "print-parent"), \
  942. C(SYM_OFFSET, "sym-offset"), \
  943. C(SYM_ADDR, "sym-addr"), \
  944. C(VERBOSE, "verbose"), \
  945. C(RAW, "raw"), \
  946. C(HEX, "hex"), \
  947. C(BIN, "bin"), \
  948. C(BLOCK, "block"), \
  949. C(PRINTK, "trace_printk"), \
  950. C(ANNOTATE, "annotate"), \
  951. C(USERSTACKTRACE, "userstacktrace"), \
  952. C(SYM_USEROBJ, "sym-userobj"), \
  953. C(PRINTK_MSGONLY, "printk-msg-only"), \
  954. C(CONTEXT_INFO, "context-info"), /* Print pid/cpu/time */ \
  955. C(LATENCY_FMT, "latency-format"), \
  956. C(RECORD_CMD, "record-cmd"), \
  957. C(OVERWRITE, "overwrite"), \
  958. C(STOP_ON_FREE, "disable_on_free"), \
  959. C(IRQ_INFO, "irq-info"), \
  960. C(MARKERS, "markers"), \
  961. C(EVENT_FORK, "event-fork"), \
  962. FUNCTION_FLAGS \
  963. FGRAPH_FLAGS \
  964. STACK_FLAGS \
  965. BRANCH_FLAGS
  966. /*
  967. * By defining C, we can make TRACE_FLAGS a list of bit names
  968. * that will define the bits for the flag masks.
  969. */
  970. #undef C
  971. #define C(a, b) TRACE_ITER_##a##_BIT
  972. enum trace_iterator_bits {
  973. TRACE_FLAGS
  974. /* Make sure we don't go more than we have bits for */
  975. TRACE_ITER_LAST_BIT
  976. };
  977. /*
  978. * By redefining C, we can make TRACE_FLAGS a list of masks that
  979. * use the bits as defined above.
  980. */
  981. #undef C
  982. #define C(a, b) TRACE_ITER_##a = (1 << TRACE_ITER_##a##_BIT)
  983. enum trace_iterator_flags { TRACE_FLAGS };
  984. /*
  985. * TRACE_ITER_SYM_MASK masks the options in trace_flags that
  986. * control the output of kernel symbols.
  987. */
  988. #define TRACE_ITER_SYM_MASK \
  989. (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR)
  990. extern struct tracer nop_trace;
  991. #ifdef CONFIG_BRANCH_TRACER
  992. extern int enable_branch_tracing(struct trace_array *tr);
  993. extern void disable_branch_tracing(void);
  994. static inline int trace_branch_enable(struct trace_array *tr)
  995. {
  996. if (tr->trace_flags & TRACE_ITER_BRANCH)
  997. return enable_branch_tracing(tr);
  998. return 0;
  999. }
  1000. static inline void trace_branch_disable(void)
  1001. {
  1002. /* due to races, always disable */
  1003. disable_branch_tracing();
  1004. }
  1005. #else
  1006. static inline int trace_branch_enable(struct trace_array *tr)
  1007. {
  1008. return 0;
  1009. }
  1010. static inline void trace_branch_disable(void)
  1011. {
  1012. }
  1013. #endif /* CONFIG_BRANCH_TRACER */
  1014. /* set ring buffers to default size if not already done so */
  1015. int tracing_update_buffers(void);
  1016. struct ftrace_event_field {
  1017. struct list_head link;
  1018. const char *name;
  1019. const char *type;
  1020. int filter_type;
  1021. int offset;
  1022. int size;
  1023. int is_signed;
  1024. };
  1025. struct event_filter {
  1026. int n_preds; /* Number assigned */
  1027. int a_preds; /* allocated */
  1028. struct filter_pred *preds;
  1029. struct filter_pred *root;
  1030. char *filter_string;
  1031. };
  1032. struct event_subsystem {
  1033. struct list_head list;
  1034. const char *name;
  1035. struct event_filter *filter;
  1036. int ref_count;
  1037. };
  1038. struct trace_subsystem_dir {
  1039. struct list_head list;
  1040. struct event_subsystem *subsystem;
  1041. struct trace_array *tr;
  1042. struct dentry *entry;
  1043. int ref_count;
  1044. int nr_events;
  1045. };
  1046. extern int call_filter_check_discard(struct trace_event_call *call, void *rec,
  1047. struct ring_buffer *buffer,
  1048. struct ring_buffer_event *event);
  1049. void trace_buffer_unlock_commit_regs(struct trace_array *tr,
  1050. struct ring_buffer *buffer,
  1051. struct ring_buffer_event *event,
  1052. unsigned long flags, int pc,
  1053. struct pt_regs *regs);
  1054. static inline void trace_buffer_unlock_commit(struct trace_array *tr,
  1055. struct ring_buffer *buffer,
  1056. struct ring_buffer_event *event,
  1057. unsigned long flags, int pc)
  1058. {
  1059. trace_buffer_unlock_commit_regs(tr, buffer, event, flags, pc, NULL);
  1060. }
  1061. DECLARE_PER_CPU(struct ring_buffer_event *, trace_buffered_event);
  1062. DECLARE_PER_CPU(int, trace_buffered_event_cnt);
  1063. void trace_buffered_event_disable(void);
  1064. void trace_buffered_event_enable(void);
  1065. static inline void
  1066. __trace_event_discard_commit(struct ring_buffer *buffer,
  1067. struct ring_buffer_event *event)
  1068. {
  1069. if (this_cpu_read(trace_buffered_event) == event) {
  1070. /* Simply release the temp buffer */
  1071. this_cpu_dec(trace_buffered_event_cnt);
  1072. return;
  1073. }
  1074. ring_buffer_discard_commit(buffer, event);
  1075. }
  1076. /*
  1077. * Helper function for event_trigger_unlock_commit{_regs}().
  1078. * If there are event triggers attached to this event that requires
  1079. * filtering against its fields, then they wil be called as the
  1080. * entry already holds the field information of the current event.
  1081. *
  1082. * It also checks if the event should be discarded or not.
  1083. * It is to be discarded if the event is soft disabled and the
  1084. * event was only recorded to process triggers, or if the event
  1085. * filter is active and this event did not match the filters.
  1086. *
  1087. * Returns true if the event is discarded, false otherwise.
  1088. */
  1089. static inline bool
  1090. __event_trigger_test_discard(struct trace_event_file *file,
  1091. struct ring_buffer *buffer,
  1092. struct ring_buffer_event *event,
  1093. void *entry,
  1094. enum event_trigger_type *tt)
  1095. {
  1096. unsigned long eflags = file->flags;
  1097. if (eflags & EVENT_FILE_FL_TRIGGER_COND)
  1098. *tt = event_triggers_call(file, entry);
  1099. if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags) ||
  1100. (unlikely(file->flags & EVENT_FILE_FL_FILTERED) &&
  1101. !filter_match_preds(file->filter, entry))) {
  1102. __trace_event_discard_commit(buffer, event);
  1103. return true;
  1104. }
  1105. return false;
  1106. }
  1107. /**
  1108. * event_trigger_unlock_commit - handle triggers and finish event commit
  1109. * @file: The file pointer assoctiated to the event
  1110. * @buffer: The ring buffer that the event is being written to
  1111. * @event: The event meta data in the ring buffer
  1112. * @entry: The event itself
  1113. * @irq_flags: The state of the interrupts at the start of the event
  1114. * @pc: The state of the preempt count at the start of the event.
  1115. *
  1116. * This is a helper function to handle triggers that require data
  1117. * from the event itself. It also tests the event against filters and
  1118. * if the event is soft disabled and should be discarded.
  1119. */
  1120. static inline void
  1121. event_trigger_unlock_commit(struct trace_event_file *file,
  1122. struct ring_buffer *buffer,
  1123. struct ring_buffer_event *event,
  1124. void *entry, unsigned long irq_flags, int pc)
  1125. {
  1126. enum event_trigger_type tt = ETT_NONE;
  1127. if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
  1128. trace_buffer_unlock_commit(file->tr, buffer, event, irq_flags, pc);
  1129. if (tt)
  1130. event_triggers_post_call(file, tt, entry);
  1131. }
  1132. /**
  1133. * event_trigger_unlock_commit_regs - handle triggers and finish event commit
  1134. * @file: The file pointer assoctiated to the event
  1135. * @buffer: The ring buffer that the event is being written to
  1136. * @event: The event meta data in the ring buffer
  1137. * @entry: The event itself
  1138. * @irq_flags: The state of the interrupts at the start of the event
  1139. * @pc: The state of the preempt count at the start of the event.
  1140. *
  1141. * This is a helper function to handle triggers that require data
  1142. * from the event itself. It also tests the event against filters and
  1143. * if the event is soft disabled and should be discarded.
  1144. *
  1145. * Same as event_trigger_unlock_commit() but calls
  1146. * trace_buffer_unlock_commit_regs() instead of trace_buffer_unlock_commit().
  1147. */
  1148. static inline void
  1149. event_trigger_unlock_commit_regs(struct trace_event_file *file,
  1150. struct ring_buffer *buffer,
  1151. struct ring_buffer_event *event,
  1152. void *entry, unsigned long irq_flags, int pc,
  1153. struct pt_regs *regs)
  1154. {
  1155. enum event_trigger_type tt = ETT_NONE;
  1156. if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
  1157. trace_buffer_unlock_commit_regs(file->tr, buffer, event,
  1158. irq_flags, pc, regs);
  1159. if (tt)
  1160. event_triggers_post_call(file, tt, entry);
  1161. }
  1162. #define FILTER_PRED_INVALID ((unsigned short)-1)
  1163. #define FILTER_PRED_IS_RIGHT (1 << 15)
  1164. #define FILTER_PRED_FOLD (1 << 15)
  1165. /*
  1166. * The max preds is the size of unsigned short with
  1167. * two flags at the MSBs. One bit is used for both the IS_RIGHT
  1168. * and FOLD flags. The other is reserved.
  1169. *
  1170. * 2^14 preds is way more than enough.
  1171. */
  1172. #define MAX_FILTER_PRED 16384
  1173. struct filter_pred;
  1174. struct regex;
  1175. typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event);
  1176. typedef int (*regex_match_func)(char *str, struct regex *r, int len);
  1177. enum regex_type {
  1178. MATCH_FULL = 0,
  1179. MATCH_FRONT_ONLY,
  1180. MATCH_MIDDLE_ONLY,
  1181. MATCH_END_ONLY,
  1182. MATCH_GLOB,
  1183. };
  1184. struct regex {
  1185. char pattern[MAX_FILTER_STR_VAL];
  1186. int len;
  1187. int field_len;
  1188. regex_match_func match;
  1189. };
  1190. struct filter_pred {
  1191. filter_pred_fn_t fn;
  1192. u64 val;
  1193. struct regex regex;
  1194. unsigned short *ops;
  1195. struct ftrace_event_field *field;
  1196. int offset;
  1197. int not;
  1198. int op;
  1199. unsigned short index;
  1200. unsigned short parent;
  1201. unsigned short left;
  1202. unsigned short right;
  1203. };
  1204. static inline bool is_string_field(struct ftrace_event_field *field)
  1205. {
  1206. return field->filter_type == FILTER_DYN_STRING ||
  1207. field->filter_type == FILTER_STATIC_STRING ||
  1208. field->filter_type == FILTER_PTR_STRING ||
  1209. field->filter_type == FILTER_COMM;
  1210. }
  1211. static inline bool is_function_field(struct ftrace_event_field *field)
  1212. {
  1213. return field->filter_type == FILTER_TRACE_FN;
  1214. }
  1215. extern enum regex_type
  1216. filter_parse_regex(char *buff, int len, char **search, int *not);
  1217. extern void print_event_filter(struct trace_event_file *file,
  1218. struct trace_seq *s);
  1219. extern int apply_event_filter(struct trace_event_file *file,
  1220. char *filter_string);
  1221. extern int apply_subsystem_event_filter(struct trace_subsystem_dir *dir,
  1222. char *filter_string);
  1223. extern void print_subsystem_event_filter(struct event_subsystem *system,
  1224. struct trace_seq *s);
  1225. extern int filter_assign_type(const char *type);
  1226. extern int create_event_filter(struct trace_event_call *call,
  1227. char *filter_str, bool set_str,
  1228. struct event_filter **filterp);
  1229. extern void free_event_filter(struct event_filter *filter);
  1230. struct ftrace_event_field *
  1231. trace_find_event_field(struct trace_event_call *call, char *name);
  1232. extern void trace_event_enable_cmd_record(bool enable);
  1233. extern int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr);
  1234. extern int event_trace_del_tracer(struct trace_array *tr);
  1235. extern struct trace_event_file *find_event_file(struct trace_array *tr,
  1236. const char *system,
  1237. const char *event);
  1238. static inline void *event_file_data(struct file *filp)
  1239. {
  1240. return ACCESS_ONCE(file_inode(filp)->i_private);
  1241. }
  1242. extern struct mutex event_mutex;
  1243. extern struct list_head ftrace_events;
  1244. extern const struct file_operations event_trigger_fops;
  1245. extern const struct file_operations event_hist_fops;
  1246. #ifdef CONFIG_HIST_TRIGGERS
  1247. extern int register_trigger_hist_cmd(void);
  1248. extern int register_trigger_hist_enable_disable_cmds(void);
  1249. #else
  1250. static inline int register_trigger_hist_cmd(void) { return 0; }
  1251. static inline int register_trigger_hist_enable_disable_cmds(void) { return 0; }
  1252. #endif
  1253. extern int register_trigger_cmds(void);
  1254. extern void clear_event_triggers(struct trace_array *tr);
  1255. struct event_trigger_data {
  1256. unsigned long count;
  1257. int ref;
  1258. struct event_trigger_ops *ops;
  1259. struct event_command *cmd_ops;
  1260. struct event_filter __rcu *filter;
  1261. char *filter_str;
  1262. void *private_data;
  1263. bool paused;
  1264. bool paused_tmp;
  1265. struct list_head list;
  1266. char *name;
  1267. struct list_head named_list;
  1268. struct event_trigger_data *named_data;
  1269. };
  1270. /* Avoid typos */
  1271. #define ENABLE_EVENT_STR "enable_event"
  1272. #define DISABLE_EVENT_STR "disable_event"
  1273. #define ENABLE_HIST_STR "enable_hist"
  1274. #define DISABLE_HIST_STR "disable_hist"
  1275. struct enable_trigger_data {
  1276. struct trace_event_file *file;
  1277. bool enable;
  1278. bool hist;
  1279. };
  1280. extern int event_enable_trigger_print(struct seq_file *m,
  1281. struct event_trigger_ops *ops,
  1282. struct event_trigger_data *data);
  1283. extern void event_enable_trigger_free(struct event_trigger_ops *ops,
  1284. struct event_trigger_data *data);
  1285. extern int event_enable_trigger_func(struct event_command *cmd_ops,
  1286. struct trace_event_file *file,
  1287. char *glob, char *cmd, char *param);
  1288. extern int event_enable_register_trigger(char *glob,
  1289. struct event_trigger_ops *ops,
  1290. struct event_trigger_data *data,
  1291. struct trace_event_file *file);
  1292. extern void event_enable_unregister_trigger(char *glob,
  1293. struct event_trigger_ops *ops,
  1294. struct event_trigger_data *test,
  1295. struct trace_event_file *file);
  1296. extern void trigger_data_free(struct event_trigger_data *data);
  1297. extern int event_trigger_init(struct event_trigger_ops *ops,
  1298. struct event_trigger_data *data);
  1299. extern int trace_event_trigger_enable_disable(struct trace_event_file *file,
  1300. int trigger_enable);
  1301. extern void update_cond_flag(struct trace_event_file *file);
  1302. extern void unregister_trigger(char *glob, struct event_trigger_ops *ops,
  1303. struct event_trigger_data *test,
  1304. struct trace_event_file *file);
  1305. extern int set_trigger_filter(char *filter_str,
  1306. struct event_trigger_data *trigger_data,
  1307. struct trace_event_file *file);
  1308. extern struct event_trigger_data *find_named_trigger(const char *name);
  1309. extern bool is_named_trigger(struct event_trigger_data *test);
  1310. extern int save_named_trigger(const char *name,
  1311. struct event_trigger_data *data);
  1312. extern void del_named_trigger(struct event_trigger_data *data);
  1313. extern void pause_named_trigger(struct event_trigger_data *data);
  1314. extern void unpause_named_trigger(struct event_trigger_data *data);
  1315. extern void set_named_trigger_data(struct event_trigger_data *data,
  1316. struct event_trigger_data *named_data);
  1317. extern int register_event_command(struct event_command *cmd);
  1318. extern int unregister_event_command(struct event_command *cmd);
  1319. extern int register_trigger_hist_enable_disable_cmds(void);
  1320. /**
  1321. * struct event_trigger_ops - callbacks for trace event triggers
  1322. *
  1323. * The methods in this structure provide per-event trigger hooks for
  1324. * various trigger operations.
  1325. *
  1326. * All the methods below, except for @init() and @free(), must be
  1327. * implemented.
  1328. *
  1329. * @func: The trigger 'probe' function called when the triggering
  1330. * event occurs. The data passed into this callback is the data
  1331. * that was supplied to the event_command @reg() function that
  1332. * registered the trigger (see struct event_command) along with
  1333. * the trace record, rec.
  1334. *
  1335. * @init: An optional initialization function called for the trigger
  1336. * when the trigger is registered (via the event_command reg()
  1337. * function). This can be used to perform per-trigger
  1338. * initialization such as incrementing a per-trigger reference
  1339. * count, for instance. This is usually implemented by the
  1340. * generic utility function @event_trigger_init() (see
  1341. * trace_event_triggers.c).
  1342. *
  1343. * @free: An optional de-initialization function called for the
  1344. * trigger when the trigger is unregistered (via the
  1345. * event_command @reg() function). This can be used to perform
  1346. * per-trigger de-initialization such as decrementing a
  1347. * per-trigger reference count and freeing corresponding trigger
  1348. * data, for instance. This is usually implemented by the
  1349. * generic utility function @event_trigger_free() (see
  1350. * trace_event_triggers.c).
  1351. *
  1352. * @print: The callback function invoked to have the trigger print
  1353. * itself. This is usually implemented by a wrapper function
  1354. * that calls the generic utility function @event_trigger_print()
  1355. * (see trace_event_triggers.c).
  1356. */
  1357. struct event_trigger_ops {
  1358. void (*func)(struct event_trigger_data *data,
  1359. void *rec);
  1360. int (*init)(struct event_trigger_ops *ops,
  1361. struct event_trigger_data *data);
  1362. void (*free)(struct event_trigger_ops *ops,
  1363. struct event_trigger_data *data);
  1364. int (*print)(struct seq_file *m,
  1365. struct event_trigger_ops *ops,
  1366. struct event_trigger_data *data);
  1367. };
  1368. /**
  1369. * struct event_command - callbacks and data members for event commands
  1370. *
  1371. * Event commands are invoked by users by writing the command name
  1372. * into the 'trigger' file associated with a trace event. The
  1373. * parameters associated with a specific invocation of an event
  1374. * command are used to create an event trigger instance, which is
  1375. * added to the list of trigger instances associated with that trace
  1376. * event. When the event is hit, the set of triggers associated with
  1377. * that event is invoked.
  1378. *
  1379. * The data members in this structure provide per-event command data
  1380. * for various event commands.
  1381. *
  1382. * All the data members below, except for @post_trigger, must be set
  1383. * for each event command.
  1384. *
  1385. * @name: The unique name that identifies the event command. This is
  1386. * the name used when setting triggers via trigger files.
  1387. *
  1388. * @trigger_type: A unique id that identifies the event command
  1389. * 'type'. This value has two purposes, the first to ensure that
  1390. * only one trigger of the same type can be set at a given time
  1391. * for a particular event e.g. it doesn't make sense to have both
  1392. * a traceon and traceoff trigger attached to a single event at
  1393. * the same time, so traceon and traceoff have the same type
  1394. * though they have different names. The @trigger_type value is
  1395. * also used as a bit value for deferring the actual trigger
  1396. * action until after the current event is finished. Some
  1397. * commands need to do this if they themselves log to the trace
  1398. * buffer (see the @post_trigger() member below). @trigger_type
  1399. * values are defined by adding new values to the trigger_type
  1400. * enum in include/linux/trace_events.h.
  1401. *
  1402. * @flags: See the enum event_command_flags below.
  1403. *
  1404. * All the methods below, except for @set_filter() and @unreg_all(),
  1405. * must be implemented.
  1406. *
  1407. * @func: The callback function responsible for parsing and
  1408. * registering the trigger written to the 'trigger' file by the
  1409. * user. It allocates the trigger instance and registers it with
  1410. * the appropriate trace event. It makes use of the other
  1411. * event_command callback functions to orchestrate this, and is
  1412. * usually implemented by the generic utility function
  1413. * @event_trigger_callback() (see trace_event_triggers.c).
  1414. *
  1415. * @reg: Adds the trigger to the list of triggers associated with the
  1416. * event, and enables the event trigger itself, after
  1417. * initializing it (via the event_trigger_ops @init() function).
  1418. * This is also where commands can use the @trigger_type value to
  1419. * make the decision as to whether or not multiple instances of
  1420. * the trigger should be allowed. This is usually implemented by
  1421. * the generic utility function @register_trigger() (see
  1422. * trace_event_triggers.c).
  1423. *
  1424. * @unreg: Removes the trigger from the list of triggers associated
  1425. * with the event, and disables the event trigger itself, after
  1426. * initializing it (via the event_trigger_ops @free() function).
  1427. * This is usually implemented by the generic utility function
  1428. * @unregister_trigger() (see trace_event_triggers.c).
  1429. *
  1430. * @unreg_all: An optional function called to remove all the triggers
  1431. * from the list of triggers associated with the event. Called
  1432. * when a trigger file is opened in truncate mode.
  1433. *
  1434. * @set_filter: An optional function called to parse and set a filter
  1435. * for the trigger. If no @set_filter() method is set for the
  1436. * event command, filters set by the user for the command will be
  1437. * ignored. This is usually implemented by the generic utility
  1438. * function @set_trigger_filter() (see trace_event_triggers.c).
  1439. *
  1440. * @get_trigger_ops: The callback function invoked to retrieve the
  1441. * event_trigger_ops implementation associated with the command.
  1442. */
  1443. struct event_command {
  1444. struct list_head list;
  1445. char *name;
  1446. enum event_trigger_type trigger_type;
  1447. int flags;
  1448. int (*func)(struct event_command *cmd_ops,
  1449. struct trace_event_file *file,
  1450. char *glob, char *cmd, char *params);
  1451. int (*reg)(char *glob,
  1452. struct event_trigger_ops *ops,
  1453. struct event_trigger_data *data,
  1454. struct trace_event_file *file);
  1455. void (*unreg)(char *glob,
  1456. struct event_trigger_ops *ops,
  1457. struct event_trigger_data *data,
  1458. struct trace_event_file *file);
  1459. void (*unreg_all)(struct trace_event_file *file);
  1460. int (*set_filter)(char *filter_str,
  1461. struct event_trigger_data *data,
  1462. struct trace_event_file *file);
  1463. struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
  1464. };
  1465. /**
  1466. * enum event_command_flags - flags for struct event_command
  1467. *
  1468. * @POST_TRIGGER: A flag that says whether or not this command needs
  1469. * to have its action delayed until after the current event has
  1470. * been closed. Some triggers need to avoid being invoked while
  1471. * an event is currently in the process of being logged, since
  1472. * the trigger may itself log data into the trace buffer. Thus
  1473. * we make sure the current event is committed before invoking
  1474. * those triggers. To do that, the trigger invocation is split
  1475. * in two - the first part checks the filter using the current
  1476. * trace record; if a command has the @post_trigger flag set, it
  1477. * sets a bit for itself in the return value, otherwise it
  1478. * directly invokes the trigger. Once all commands have been
  1479. * either invoked or set their return flag, the current record is
  1480. * either committed or discarded. At that point, if any commands
  1481. * have deferred their triggers, those commands are finally
  1482. * invoked following the close of the current event. In other
  1483. * words, if the event_trigger_ops @func() probe implementation
  1484. * itself logs to the trace buffer, this flag should be set,
  1485. * otherwise it can be left unspecified.
  1486. *
  1487. * @NEEDS_REC: A flag that says whether or not this command needs
  1488. * access to the trace record in order to perform its function,
  1489. * regardless of whether or not it has a filter associated with
  1490. * it (filters make a trigger require access to the trace record
  1491. * but are not always present).
  1492. */
  1493. enum event_command_flags {
  1494. EVENT_CMD_FL_POST_TRIGGER = 1,
  1495. EVENT_CMD_FL_NEEDS_REC = 2,
  1496. };
  1497. static inline bool event_command_post_trigger(struct event_command *cmd_ops)
  1498. {
  1499. return cmd_ops->flags & EVENT_CMD_FL_POST_TRIGGER;
  1500. }
  1501. static inline bool event_command_needs_rec(struct event_command *cmd_ops)
  1502. {
  1503. return cmd_ops->flags & EVENT_CMD_FL_NEEDS_REC;
  1504. }
  1505. extern int trace_event_enable_disable(struct trace_event_file *file,
  1506. int enable, int soft_disable);
  1507. extern int tracing_alloc_snapshot(void);
  1508. extern const char *__start___trace_bprintk_fmt[];
  1509. extern const char *__stop___trace_bprintk_fmt[];
  1510. extern const char *__start___tracepoint_str[];
  1511. extern const char *__stop___tracepoint_str[];
  1512. void trace_printk_control(bool enabled);
  1513. void trace_printk_init_buffers(void);
  1514. void trace_printk_start_comm(void);
  1515. int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
  1516. int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
  1517. /*
  1518. * Normal trace_printk() and friends allocates special buffers
  1519. * to do the manipulation, as well as saves the print formats
  1520. * into sections to display. But the trace infrastructure wants
  1521. * to use these without the added overhead at the price of being
  1522. * a bit slower (used mainly for warnings, where we don't care
  1523. * about performance). The internal_trace_puts() is for such
  1524. * a purpose.
  1525. */
  1526. #define internal_trace_puts(str) __trace_puts(_THIS_IP_, str, strlen(str))
  1527. #undef FTRACE_ENTRY
  1528. #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
  1529. extern struct trace_event_call \
  1530. __aligned(4) event_##call;
  1531. #undef FTRACE_ENTRY_DUP
  1532. #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \
  1533. FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
  1534. filter)
  1535. #undef FTRACE_ENTRY_PACKED
  1536. #define FTRACE_ENTRY_PACKED(call, struct_name, id, tstruct, print, filter) \
  1537. FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
  1538. filter)
  1539. #include "trace_entries.h"
  1540. #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER)
  1541. int perf_ftrace_event_register(struct trace_event_call *call,
  1542. enum trace_reg type, void *data);
  1543. #else
  1544. #define perf_ftrace_event_register NULL
  1545. #endif
  1546. #ifdef CONFIG_FTRACE_SYSCALLS
  1547. void init_ftrace_syscalls(void);
  1548. const char *get_syscall_name(int syscall);
  1549. #else
  1550. static inline void init_ftrace_syscalls(void) { }
  1551. static inline const char *get_syscall_name(int syscall)
  1552. {
  1553. return NULL;
  1554. }
  1555. #endif
  1556. #ifdef CONFIG_EVENT_TRACING
  1557. void trace_event_init(void);
  1558. void trace_event_enum_update(struct trace_eval_map **map, int len);
  1559. #else
  1560. static inline void __init trace_event_init(void) { }
  1561. static inline void trace_event_enum_update(struct trace_eval_map **map, int len) { }
  1562. #endif
  1563. extern struct trace_iterator *tracepoint_print_iter;
  1564. #endif /* _LINUX_KERNEL_TRACE_H */