trace_entries.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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 laid 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 address:
  56. */
  57. FTRACE_ENTRY_REG(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. FILTER_TRACE_FN,
  65. perf_ftrace_event_register
  66. );
  67. /* Function call entry */
  68. FTRACE_ENTRY_PACKED(funcgraph_entry, ftrace_graph_ent_entry,
  69. TRACE_GRAPH_ENT,
  70. F_STRUCT(
  71. __field_struct( struct ftrace_graph_ent, graph_ent )
  72. __field_desc( unsigned long, graph_ent, func )
  73. __field_desc( int, graph_ent, depth )
  74. ),
  75. F_printk("--> %lx (%d)", __entry->func, __entry->depth),
  76. FILTER_OTHER
  77. );
  78. /* Function return entry */
  79. FTRACE_ENTRY_PACKED(funcgraph_exit, ftrace_graph_ret_entry,
  80. TRACE_GRAPH_RET,
  81. F_STRUCT(
  82. __field_struct( struct ftrace_graph_ret, ret )
  83. __field_desc( unsigned long, ret, func )
  84. __field_desc( unsigned long long, ret, calltime)
  85. __field_desc( unsigned long long, ret, rettime )
  86. __field_desc( unsigned long, ret, overrun )
  87. __field_desc( int, ret, depth )
  88. ),
  89. F_printk("<-- %lx (%d) (start: %llx end: %llx) over: %d",
  90. __entry->func, __entry->depth,
  91. __entry->calltime, __entry->rettime,
  92. __entry->depth),
  93. FILTER_OTHER
  94. );
  95. /*
  96. * Context switch trace entry - which task (and prio) we switched from/to:
  97. *
  98. * This is used for both wakeup and context switches. We only want
  99. * to create one structure, but we need two outputs for it.
  100. */
  101. #define FTRACE_CTX_FIELDS \
  102. __field( unsigned int, prev_pid ) \
  103. __field( unsigned int, next_pid ) \
  104. __field( unsigned int, next_cpu ) \
  105. __field( unsigned char, prev_prio ) \
  106. __field( unsigned char, prev_state ) \
  107. __field( unsigned char, next_prio ) \
  108. __field( unsigned char, next_state )
  109. FTRACE_ENTRY(context_switch, ctx_switch_entry,
  110. TRACE_CTX,
  111. F_STRUCT(
  112. FTRACE_CTX_FIELDS
  113. ),
  114. F_printk("%u:%u:%u ==> %u:%u:%u [%03u]",
  115. __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
  116. __entry->next_pid, __entry->next_prio, __entry->next_state,
  117. __entry->next_cpu),
  118. FILTER_OTHER
  119. );
  120. /*
  121. * FTRACE_ENTRY_DUP only creates the format file, it will not
  122. * create another structure.
  123. */
  124. FTRACE_ENTRY_DUP(wakeup, ctx_switch_entry,
  125. TRACE_WAKE,
  126. F_STRUCT(
  127. FTRACE_CTX_FIELDS
  128. ),
  129. F_printk("%u:%u:%u ==+ %u:%u:%u [%03u]",
  130. __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
  131. __entry->next_pid, __entry->next_prio, __entry->next_state,
  132. __entry->next_cpu),
  133. FILTER_OTHER
  134. );
  135. /*
  136. * Stack-trace entry:
  137. */
  138. #define FTRACE_STACK_ENTRIES 8
  139. #ifndef CONFIG_64BIT
  140. # define IP_FMT "%08lx"
  141. #else
  142. # define IP_FMT "%016lx"
  143. #endif
  144. FTRACE_ENTRY(kernel_stack, stack_entry,
  145. TRACE_STACK,
  146. F_STRUCT(
  147. __field( int, size )
  148. __dynamic_array(unsigned long, caller )
  149. ),
  150. F_printk("\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n"
  151. "\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n"
  152. "\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n",
  153. __entry->caller[0], __entry->caller[1], __entry->caller[2],
  154. __entry->caller[3], __entry->caller[4], __entry->caller[5],
  155. __entry->caller[6], __entry->caller[7]),
  156. FILTER_OTHER
  157. );
  158. FTRACE_ENTRY(user_stack, userstack_entry,
  159. TRACE_USER_STACK,
  160. F_STRUCT(
  161. __field( unsigned int, tgid )
  162. __array( unsigned long, caller, FTRACE_STACK_ENTRIES )
  163. ),
  164. F_printk("\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n"
  165. "\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n"
  166. "\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n",
  167. __entry->caller[0], __entry->caller[1], __entry->caller[2],
  168. __entry->caller[3], __entry->caller[4], __entry->caller[5],
  169. __entry->caller[6], __entry->caller[7]),
  170. FILTER_OTHER
  171. );
  172. /*
  173. * trace_printk entry:
  174. */
  175. FTRACE_ENTRY(bprint, bprint_entry,
  176. TRACE_BPRINT,
  177. F_STRUCT(
  178. __field( unsigned long, ip )
  179. __field( const char *, fmt )
  180. __dynamic_array( u32, buf )
  181. ),
  182. F_printk("%ps: %s",
  183. (void *)__entry->ip, __entry->fmt),
  184. FILTER_OTHER
  185. );
  186. FTRACE_ENTRY(print, print_entry,
  187. TRACE_PRINT,
  188. F_STRUCT(
  189. __field( unsigned long, ip )
  190. __dynamic_array( char, buf )
  191. ),
  192. F_printk("%ps: %s",
  193. (void *)__entry->ip, __entry->buf),
  194. FILTER_OTHER
  195. );
  196. FTRACE_ENTRY(bputs, bputs_entry,
  197. TRACE_BPUTS,
  198. F_STRUCT(
  199. __field( unsigned long, ip )
  200. __field( const char *, str )
  201. ),
  202. F_printk("%ps: %s",
  203. (void *)__entry->ip, __entry->str),
  204. FILTER_OTHER
  205. );
  206. FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
  207. TRACE_MMIO_RW,
  208. F_STRUCT(
  209. __field_struct( struct mmiotrace_rw, rw )
  210. __field_desc( resource_size_t, rw, phys )
  211. __field_desc( unsigned long, rw, value )
  212. __field_desc( unsigned long, rw, pc )
  213. __field_desc( int, rw, map_id )
  214. __field_desc( unsigned char, rw, opcode )
  215. __field_desc( unsigned char, rw, width )
  216. ),
  217. F_printk("%lx %lx %lx %d %x %x",
  218. (unsigned long)__entry->phys, __entry->value, __entry->pc,
  219. __entry->map_id, __entry->opcode, __entry->width),
  220. FILTER_OTHER
  221. );
  222. FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
  223. TRACE_MMIO_MAP,
  224. F_STRUCT(
  225. __field_struct( struct mmiotrace_map, map )
  226. __field_desc( resource_size_t, map, phys )
  227. __field_desc( unsigned long, map, virt )
  228. __field_desc( unsigned long, map, len )
  229. __field_desc( int, map, map_id )
  230. __field_desc( unsigned char, map, opcode )
  231. ),
  232. F_printk("%lx %lx %lx %d %x",
  233. (unsigned long)__entry->phys, __entry->virt, __entry->len,
  234. __entry->map_id, __entry->opcode),
  235. FILTER_OTHER
  236. );
  237. #define TRACE_FUNC_SIZE 30
  238. #define TRACE_FILE_SIZE 20
  239. FTRACE_ENTRY(branch, trace_branch,
  240. TRACE_BRANCH,
  241. F_STRUCT(
  242. __field( unsigned int, line )
  243. __array( char, func, TRACE_FUNC_SIZE+1 )
  244. __array( char, file, TRACE_FILE_SIZE+1 )
  245. __field( char, correct )
  246. ),
  247. F_printk("%u:%s:%s (%u)",
  248. __entry->line,
  249. __entry->func, __entry->file, __entry->correct),
  250. FILTER_OTHER
  251. );
  252. FTRACE_ENTRY(hwlat, hwlat_entry,
  253. TRACE_HWLAT,
  254. F_STRUCT(
  255. __field( u64, duration )
  256. __field( u64, outer_duration )
  257. __field( u64, nmi_total_ts )
  258. __field_struct( struct timespec, timestamp )
  259. __field_desc( long, timestamp, tv_sec )
  260. __field_desc( long, timestamp, tv_nsec )
  261. __field( unsigned int, nmi_count )
  262. __field( unsigned int, seqnum )
  263. ),
  264. F_printk("cnt:%u\tts:%010lu.%010lu\tinner:%llu\touter:%llunmi-ts:%llu\tnmi-count:%u\n",
  265. __entry->seqnum,
  266. __entry->tv_sec,
  267. __entry->tv_nsec,
  268. __entry->duration,
  269. __entry->outer_duration,
  270. __entry->nmi_total_ts,
  271. __entry->nmi_count),
  272. FILTER_OTHER
  273. );