trace_entries.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. /*
  2. * This file defines the trace event structures that go into the ring
  3. * buffer directly. They are created via macros so that changes for them
  4. * appear in the format file. Using macros will automate this process.
  5. *
  6. * The macro used to create a ftrace data structure is:
  7. *
  8. * FTRACE_ENTRY( name, struct_name, id, structure, print )
  9. *
  10. * @name: the name used the event name, as well as the name of
  11. * the directory that holds the format file.
  12. *
  13. * @struct_name: the name of the structure that is created.
  14. *
  15. * @id: The event identifier that is used to detect what event
  16. * this is from the ring buffer.
  17. *
  18. * @structure: the structure layout
  19. *
  20. * - __field( type, item )
  21. * This is equivalent to declaring
  22. * type item;
  23. * in the structure.
  24. * - __array( type, item, size )
  25. * This is equivalent to declaring
  26. * type item[size];
  27. * in the structure.
  28. *
  29. * * for structures within structures, the format of the internal
  30. * structure is layed out. This allows the internal structure
  31. * to be deciphered for the format file. Although these macros
  32. * may become out of sync with the internal structure, they
  33. * will create a compile error if it happens. Since the
  34. * internel structures are just tracing helpers, this is not
  35. * an issue.
  36. *
  37. * When an internal structure is used, it should use:
  38. *
  39. * __field_struct( type, item )
  40. *
  41. * instead of __field. This will prevent it from being shown in
  42. * the output file. The fields in the structure should use.
  43. *
  44. * __field_desc( type, container, item )
  45. * __array_desc( type, container, item, len )
  46. *
  47. * type, item and len are the same as __field and __array, but
  48. * container is added. This is the name of the item in
  49. * __field_struct that this is describing.
  50. *
  51. *
  52. * @print: the print format shown to users in the format file.
  53. */
  54. /*
  55. * Function trace entry - function address and parent function addres:
  56. */
  57. FTRACE_ENTRY(function, ftrace_entry,
  58. TRACE_FN,
  59. F_STRUCT(
  60. __field( unsigned long, ip )
  61. __field( unsigned long, parent_ip )
  62. ),
  63. F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip)
  64. );
  65. /* Function call entry */
  66. FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
  67. TRACE_GRAPH_ENT,
  68. F_STRUCT(
  69. __field_struct( struct ftrace_graph_ent, graph_ent )
  70. __field_desc( unsigned long, graph_ent, func )
  71. __field_desc( int, graph_ent, depth )
  72. ),
  73. F_printk("--> %lx (%d)", __entry->func, __entry->depth)
  74. );
  75. /* Function return entry */
  76. FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry,
  77. TRACE_GRAPH_RET,
  78. F_STRUCT(
  79. __field_struct( struct ftrace_graph_ret, ret )
  80. __field_desc( unsigned long, ret, func )
  81. __field_desc( unsigned long long, ret, calltime)
  82. __field_desc( unsigned long long, ret, rettime )
  83. __field_desc( unsigned long, ret, overrun )
  84. __field_desc( int, ret, depth )
  85. ),
  86. F_printk("<-- %lx (%d) (start: %llx end: %llx) over: %d",
  87. __entry->func, __entry->depth,
  88. __entry->calltime, __entry->rettime,
  89. __entry->depth)
  90. );
  91. /*
  92. * Context switch trace entry - which task (and prio) we switched from/to:
  93. *
  94. * This is used for both wakeup and context switches. We only want
  95. * to create one structure, but we need two outputs for it.
  96. */
  97. #define FTRACE_CTX_FIELDS \
  98. __field( unsigned int, prev_pid ) \
  99. __field( unsigned char, prev_prio ) \
  100. __field( unsigned char, prev_state ) \
  101. __field( unsigned int, next_pid ) \
  102. __field( unsigned char, next_prio ) \
  103. __field( unsigned char, next_state ) \
  104. __field( unsigned int, next_cpu )
  105. #if 0
  106. FTRACE_ENTRY_STRUCT_ONLY(ctx_switch_entry,
  107. F_STRUCT(
  108. FTRACE_CTX_FIELDS
  109. )
  110. );
  111. #endif
  112. FTRACE_ENTRY(context_switch, ctx_switch_entry,
  113. TRACE_CTX,
  114. F_STRUCT(
  115. FTRACE_CTX_FIELDS
  116. ),
  117. F_printk("%u:%u:%u ==> %u:%u:%u [%03u]",
  118. __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
  119. __entry->next_pid, __entry->next_prio, __entry->next_state,
  120. __entry->next_cpu
  121. )
  122. );
  123. /*
  124. * FTRACE_ENTRY_DUP only creates the format file, it will not
  125. * create another structure.
  126. */
  127. FTRACE_ENTRY_DUP(wakeup, ctx_switch_entry,
  128. TRACE_WAKE,
  129. F_STRUCT(
  130. FTRACE_CTX_FIELDS
  131. ),
  132. F_printk("%u:%u:%u ==+ %u:%u:%u [%03u]",
  133. __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
  134. __entry->next_pid, __entry->next_prio, __entry->next_state,
  135. __entry->next_cpu
  136. )
  137. );
  138. /*
  139. * Special (free-form) trace entry:
  140. */
  141. FTRACE_ENTRY(special, special_entry,
  142. TRACE_SPECIAL,
  143. F_STRUCT(
  144. __field( unsigned long, arg1 )
  145. __field( unsigned long, arg2 )
  146. __field( unsigned long, arg3 )
  147. ),
  148. F_printk("(%08lx) (%08lx) (%08lx)",
  149. __entry->arg1, __entry->arg2, __entry->arg3)
  150. );
  151. /*
  152. * Stack-trace entry:
  153. */
  154. #define FTRACE_STACK_ENTRIES 8
  155. FTRACE_ENTRY(kernel_stack, stack_entry,
  156. TRACE_STACK,
  157. F_STRUCT(
  158. __array( unsigned long, caller, FTRACE_STACK_ENTRIES )
  159. ),
  160. F_printk("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
  161. "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n",
  162. __entry->caller[0], __entry->caller[1], __entry->caller[2],
  163. __entry->caller[3], __entry->caller[4], __entry->caller[5],
  164. __entry->caller[6], __entry->caller[7])
  165. );
  166. FTRACE_ENTRY(user_stack, userstack_entry,
  167. TRACE_USER_STACK,
  168. F_STRUCT(
  169. __field( unsigned int, tgid )
  170. __array( unsigned long, caller, FTRACE_STACK_ENTRIES )
  171. ),
  172. F_printk("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
  173. "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n",
  174. __entry->caller[0], __entry->caller[1], __entry->caller[2],
  175. __entry->caller[3], __entry->caller[4], __entry->caller[5],
  176. __entry->caller[6], __entry->caller[7])
  177. );
  178. /*
  179. * trace_printk entry:
  180. */
  181. FTRACE_ENTRY(bprint, bprint_entry,
  182. TRACE_BPRINT,
  183. F_STRUCT(
  184. __field( unsigned long, ip )
  185. __field( const char *, fmt )
  186. __dynamic_array( u32, buf )
  187. ),
  188. F_printk("%08lx fmt:%p",
  189. __entry->ip, __entry->fmt)
  190. );
  191. FTRACE_ENTRY(print, print_entry,
  192. TRACE_PRINT,
  193. F_STRUCT(
  194. __field( unsigned long, ip )
  195. __dynamic_array( char, buf )
  196. ),
  197. F_printk("%08lx %s",
  198. __entry->ip, __entry->buf)
  199. );
  200. FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
  201. TRACE_MMIO_RW,
  202. F_STRUCT(
  203. __field_struct( struct mmiotrace_rw, rw )
  204. __field_desc( resource_size_t, rw, phys )
  205. __field_desc( unsigned long, rw, value )
  206. __field_desc( unsigned long, rw, pc )
  207. __field_desc( int, rw, map_id )
  208. __field_desc( unsigned char, rw, opcode )
  209. __field_desc( unsigned char, rw, width )
  210. ),
  211. F_printk("%lx %lx %lx %d %x %x",
  212. (unsigned long)__entry->phys, __entry->value, __entry->pc,
  213. __entry->map_id, __entry->opcode, __entry->width)
  214. );
  215. FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
  216. TRACE_MMIO_MAP,
  217. F_STRUCT(
  218. __field_struct( struct mmiotrace_map, map )
  219. __field_desc( resource_size_t, map, phys )
  220. __field_desc( unsigned long, map, virt )
  221. __field_desc( unsigned long, map, len )
  222. __field_desc( int, map, map_id )
  223. __field_desc( unsigned char, map, opcode )
  224. ),
  225. F_printk("%lx %lx %lx %d %x",
  226. (unsigned long)__entry->phys, __entry->virt, __entry->len,
  227. __entry->map_id, __entry->opcode)
  228. );
  229. FTRACE_ENTRY(boot_call, trace_boot_call,
  230. TRACE_BOOT_CALL,
  231. F_STRUCT(
  232. __field_struct( struct boot_trace_call, boot_call )
  233. __field_desc( pid_t, boot_call, caller )
  234. __array_desc( char, boot_call, func, KSYM_SYMBOL_LEN)
  235. ),
  236. F_printk("%d %s", __entry->caller, __entry->func)
  237. );
  238. FTRACE_ENTRY(boot_ret, trace_boot_ret,
  239. TRACE_BOOT_RET,
  240. F_STRUCT(
  241. __field_struct( struct boot_trace_ret, boot_ret )
  242. __array_desc( char, boot_ret, func, KSYM_SYMBOL_LEN)
  243. __field_desc( int, boot_ret, result )
  244. __field_desc( unsigned long, boot_ret, duration )
  245. ),
  246. F_printk("%s %d %lx",
  247. __entry->func, __entry->result, __entry->duration)
  248. );
  249. #define TRACE_FUNC_SIZE 30
  250. #define TRACE_FILE_SIZE 20
  251. FTRACE_ENTRY(branch, trace_branch,
  252. TRACE_BRANCH,
  253. F_STRUCT(
  254. __field( unsigned int, line )
  255. __array( char, func, TRACE_FUNC_SIZE+1 )
  256. __array( char, file, TRACE_FILE_SIZE+1 )
  257. __field( char, correct )
  258. ),
  259. F_printk("%u:%s:%s (%u)",
  260. __entry->line,
  261. __entry->func, __entry->file, __entry->correct)
  262. );
  263. FTRACE_ENTRY(hw_branch, hw_branch_entry,
  264. TRACE_HW_BRANCHES,
  265. F_STRUCT(
  266. __field( u64, from )
  267. __field( u64, to )
  268. ),
  269. F_printk("from: %llx to: %llx", __entry->from, __entry->to)
  270. );
  271. FTRACE_ENTRY(power, trace_power,
  272. TRACE_POWER,
  273. F_STRUCT(
  274. __field_struct( struct power_trace, state_data )
  275. __field_desc( s64, state_data, stamp )
  276. __field_desc( s64, state_data, end )
  277. __field_desc( int, state_data, type )
  278. __field_desc( int, state_data, state )
  279. ),
  280. F_printk("%llx->%llx type:%u state:%u",
  281. __entry->stamp, __entry->end,
  282. __entry->type, __entry->state)
  283. );
  284. FTRACE_ENTRY(kmem_alloc, kmemtrace_alloc_entry,
  285. TRACE_KMEM_ALLOC,
  286. F_STRUCT(
  287. __field( enum kmemtrace_type_id, type_id )
  288. __field( unsigned long, call_site )
  289. __field( const void *, ptr )
  290. __field( size_t, bytes_req )
  291. __field( size_t, bytes_alloc )
  292. __field( gfp_t, gfp_flags )
  293. __field( int, node )
  294. ),
  295. F_printk("type:%u call_site:%lx ptr:%p req:%zi alloc:%zi"
  296. " flags:%x node:%d",
  297. __entry->type_id, __entry->call_site, __entry->ptr,
  298. __entry->bytes_req, __entry->bytes_alloc,
  299. __entry->gfp_flags, __entry->node)
  300. );
  301. FTRACE_ENTRY(kmem_free, kmemtrace_free_entry,
  302. TRACE_KMEM_FREE,
  303. F_STRUCT(
  304. __field( enum kmemtrace_type_id, type_id )
  305. __field( unsigned long, call_site )
  306. __field( const void *, ptr )
  307. ),
  308. F_printk("type:%u call_site:%lx ptr:%p",
  309. __entry->type_id, __entry->call_site, __entry->ptr)
  310. );