trace_entries.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. * @print: the print format shown to users in the format file.
  30. */
  31. /*
  32. * Function trace entry - function address and parent function addres:
  33. */
  34. FTRACE_ENTRY(function, ftrace_entry,
  35. TRACE_FN,
  36. F_STRUCT(
  37. __field( unsigned long, ip )
  38. __field( unsigned long, parent_ip )
  39. ),
  40. F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip)
  41. );
  42. /* Function call entry */
  43. FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
  44. TRACE_GRAPH_ENT,
  45. F_STRUCT(
  46. __field( struct ftrace_graph_ent, graph_ent )
  47. ),
  48. F_printk("--> %lx (%d)", __entry->graph_ent.func, __entry->depth)
  49. );
  50. /* Function return entry */
  51. FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry,
  52. TRACE_GRAPH_RET,
  53. F_STRUCT(
  54. __field( struct ftrace_graph_ret, ret )
  55. ),
  56. F_printk("<-- %lx (%d) (start: %llx end: %llx) over: %d",
  57. __entry->func, __entry->depth,
  58. __entry->calltime, __entry->rettim,
  59. __entrty->depth)
  60. );
  61. /*
  62. * Context switch trace entry - which task (and prio) we switched from/to:
  63. *
  64. * This is used for both wakeup and context switches. We only want
  65. * to create one structure, but we need two outputs for it.
  66. */
  67. #define FTRACE_CTX_FIELDS \
  68. __field( unsigned int, prev_pid ) \
  69. __field( unsigned char, prev_prio ) \
  70. __field( unsigned char, prev_state ) \
  71. __field( unsigned int, next_pid ) \
  72. __field( unsigned char, next_prio ) \
  73. __field( unsigned char, next_state ) \
  74. __field( unsigned int, next_cpu )
  75. #if 0
  76. FTRACE_ENTRY_STRUCT_ONLY(ctx_switch_entry,
  77. F_STRUCT(
  78. FTRACE_CTX_FIELDS
  79. )
  80. );
  81. #endif
  82. FTRACE_ENTRY(context_switch, ctx_switch_entry,
  83. TRACE_CTX,
  84. F_STRUCT(
  85. FTRACE_CTX_FIELDS
  86. ),
  87. F_printk(b"%u:%u:%u ==> %u:%u:%u [%03u]",
  88. __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
  89. __entry->next_pid, __entry->next_prio, __entry->next_state,
  90. __entry->next_cpu
  91. )
  92. );
  93. /*
  94. * FTRACE_ENTRY_DUP only creates the format file, it will not
  95. * create another structure.
  96. */
  97. FTRACE_ENTRY_DUP(wakeup, ctx_switch_entry,
  98. TRACE_WAKE,
  99. F_STRUCT(
  100. FTRACE_CTX_FIELDS
  101. ),
  102. F_printk("%u:%u:%u ==+ %u:%u:%u [%03u]",
  103. __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
  104. __entry->next_pid, __entry->next_prio, __entry->next_state,
  105. __entry->next_cpu
  106. )
  107. );
  108. /*
  109. * Special (free-form) trace entry:
  110. */
  111. FTRACE_ENTRY(special, special_entry,
  112. TRACE_SPECIAL,
  113. F_STRUCT(
  114. __field( unsigned long, arg1 )
  115. __field( unsigned long, arg2 )
  116. __field( unsigned long, arg3 )
  117. ),
  118. F_printk("(%08lx) (%08lx) (%08lx)",
  119. __entry->arg1, __entry->arg2, __entry->arg3)
  120. );
  121. /*
  122. * Stack-trace entry:
  123. */
  124. #define FTRACE_STACK_ENTRIES 8
  125. FTRACE_ENTRY(kernel_stack, stack_entry,
  126. TRACE_STACK,
  127. F_STRUCT(
  128. __array( unsigned long, caller, FTRACE_STACK_ENTRIES )
  129. ),
  130. F_printk("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
  131. "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n",
  132. __entry->caller[0], __entry->caller[1], __entry->caller[2],
  133. __entry->caller[3], __entry->caller[4], __entry->caller[5],
  134. __entry->caller[6], __entry->caller[7])
  135. );
  136. FTRACE_ENTRY(user_stack, userstack_entry,
  137. TRACE_USER_STACK,
  138. F_STRUCT(
  139. __field( unsigned int, tgid )
  140. __array( unsigned long, caller, FTRACE_STACK_ENTRIES )
  141. ),
  142. F_printk("\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n"
  143. "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n",
  144. __entry->caller[0], __entry->caller[1], __entry->caller[2],
  145. __entry->caller[3], __entry->caller[4], __entry->caller[5],
  146. __entry->caller[6], __entry->caller[7])
  147. );
  148. /*
  149. * trace_printk entry:
  150. */
  151. FTRACE_ENTRY(bprint, bprint_entry,
  152. TRACE_BPRINT,
  153. F_STRUCT(
  154. __field( unsigned long, ip )
  155. __field( const char *, fmt )
  156. __dynamic_array( u32, buf )
  157. ),
  158. F_printk("%08lx fmt:%p",
  159. __entry->ip, __entry->fmt)
  160. );
  161. FTRACE_ENTRY(print, print_entry,
  162. TRACE_PRINT,
  163. F_STRUCT(
  164. __field( unsigned long, ip )
  165. __dynamic_array( char, buf )
  166. ),
  167. F_printk("%08lx %s",
  168. __entry->ip, __entry->buf)
  169. );
  170. FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
  171. TRACE_MMIO_RW,
  172. F_STRUCT(
  173. __field( struct mmiotrace_rw, rw )
  174. ),
  175. F_printk("%lx %lx %lx %d %lx %lx",
  176. __entry->phs, __entry->value, __entry->pc,
  177. __entry->map_id, __entry->opcode, __entry->width)
  178. );
  179. FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
  180. TRACE_MMIO_MAP,
  181. F_STRUCT(
  182. __field( struct mmiotrace_map, map )
  183. ),
  184. F_printk("%lx %lx %lx %d %lx",
  185. __entry->phs, __entry->virt, __entry->len,
  186. __entry->map_id, __entry->opcode)
  187. );
  188. FTRACE_ENTRY(boot_call, trace_boot_call,
  189. TRACE_BOOT_CALL,
  190. F_STRUCT(
  191. __field( struct boot_trace_call, boot_call )
  192. ),
  193. F_printk("%d %s", __entry->caller, __entry->func)
  194. );
  195. FTRACE_ENTRY(boot_ret, trace_boot_ret,
  196. TRACE_BOOT_RET,
  197. F_STRUCT(
  198. __field( struct boot_trace_ret, boot_ret )
  199. ),
  200. F_printk("%s %d %lx",
  201. __entry->func, __entry->result, __entry->duration)
  202. );
  203. #define TRACE_FUNC_SIZE 30
  204. #define TRACE_FILE_SIZE 20
  205. FTRACE_ENTRY(branch, trace_branch,
  206. TRACE_BRANCH,
  207. F_STRUCT(
  208. __field( unsigned int, line )
  209. __array( char, func, TRACE_FUNC_SIZE+1 )
  210. __array( char, file, TRACE_FILE_SIZE+1 )
  211. __field( char, correct )
  212. ),
  213. F_printk("%u:%s:%s (%u)",
  214. __entry->line,
  215. __entry->func, __entry->file, __entry->correct)
  216. );
  217. FTRACE_ENTRY(hw_branch, hw_branch_entry,
  218. TRACE_HW_BRANCHES,
  219. F_STRUCT(
  220. __field( u64, from )
  221. __field( u64, to )
  222. ),
  223. F_printk("from: %llx to: %llx", __entry->from, __entry->to)
  224. );
  225. FTRACE_ENTRY(power, trace_power,
  226. TRACE_POWER,
  227. F_STRUCT(
  228. __field( struct power_trace, state_data )
  229. ),
  230. F_printk("%llx->%llx type:%u state:%u",
  231. __entry->stamp, __entry->end,
  232. __entry->type, __entry->state)
  233. );
  234. FTRACE_ENTRY(kmem_alloc, kmemtrace_alloc_entry,
  235. TRACE_KMEM_ALLOC,
  236. F_STRUCT(
  237. __field( enum kmemtrace_type_id, type_id )
  238. __field( unsigned long, call_site )
  239. __field( const void *, ptr )
  240. __field( size_t, bytes_req )
  241. __field( size_t, bytes_alloc )
  242. __field( gfp_t, gfp_flags )
  243. __field( int, node )
  244. ),
  245. F_printk("type:%u call_site:%lx ptr:%p req:%lu alloc:%lu"
  246. " flags:%x node:%d",
  247. __entry->type_id, __entry->call_site, __entry->ptr,
  248. __entry->bytes_req, __entry->bytes_alloc,
  249. __entry->gfp_flags, __entry->node)
  250. );
  251. FTRACE_ENTRY(kmem_free, kmemtrace_free_entry,
  252. TRACE_KMEM_FREE,
  253. F_STRUCT(
  254. __field( enum kmemtrace_type_id, type_id )
  255. __field( unsigned long, call_site )
  256. __field( const void *, ptr )
  257. ),
  258. F_printk("type:%u call_site:%lx ptr:%p",
  259. __entry->type_id, __entry->call_site, __entry->ptr)
  260. );