binder_trace.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 Google, Inc.
  4. */
  5. #undef TRACE_SYSTEM
  6. #define TRACE_SYSTEM binder
  7. #if !defined(_BINDER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
  8. #define _BINDER_TRACE_H
  9. #include <linux/tracepoint.h>
  10. struct binder_buffer;
  11. struct binder_node;
  12. struct binder_proc;
  13. struct binder_alloc;
  14. struct binder_ref_data;
  15. struct binder_thread;
  16. struct binder_transaction;
  17. TRACE_EVENT(binder_ioctl,
  18. TP_PROTO(unsigned int cmd, unsigned long arg),
  19. TP_ARGS(cmd, arg),
  20. TP_STRUCT__entry(
  21. __field(unsigned int, cmd)
  22. __field(unsigned long, arg)
  23. ),
  24. TP_fast_assign(
  25. __entry->cmd = cmd;
  26. __entry->arg = arg;
  27. ),
  28. TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg)
  29. );
  30. DECLARE_EVENT_CLASS(binder_lock_class,
  31. TP_PROTO(const char *tag),
  32. TP_ARGS(tag),
  33. TP_STRUCT__entry(
  34. __field(const char *, tag)
  35. ),
  36. TP_fast_assign(
  37. __entry->tag = tag;
  38. ),
  39. TP_printk("tag=%s", __entry->tag)
  40. );
  41. #define DEFINE_BINDER_LOCK_EVENT(name) \
  42. DEFINE_EVENT(binder_lock_class, name, \
  43. TP_PROTO(const char *func), \
  44. TP_ARGS(func))
  45. DEFINE_BINDER_LOCK_EVENT(binder_lock);
  46. DEFINE_BINDER_LOCK_EVENT(binder_locked);
  47. DEFINE_BINDER_LOCK_EVENT(binder_unlock);
  48. DECLARE_EVENT_CLASS(binder_function_return_class,
  49. TP_PROTO(int ret),
  50. TP_ARGS(ret),
  51. TP_STRUCT__entry(
  52. __field(int, ret)
  53. ),
  54. TP_fast_assign(
  55. __entry->ret = ret;
  56. ),
  57. TP_printk("ret=%d", __entry->ret)
  58. );
  59. #define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name) \
  60. DEFINE_EVENT(binder_function_return_class, name, \
  61. TP_PROTO(int ret), \
  62. TP_ARGS(ret))
  63. DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done);
  64. DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_write_done);
  65. DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_read_done);
  66. TRACE_EVENT(binder_wait_for_work,
  67. TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo),
  68. TP_ARGS(proc_work, transaction_stack, thread_todo),
  69. TP_STRUCT__entry(
  70. __field(bool, proc_work)
  71. __field(bool, transaction_stack)
  72. __field(bool, thread_todo)
  73. ),
  74. TP_fast_assign(
  75. __entry->proc_work = proc_work;
  76. __entry->transaction_stack = transaction_stack;
  77. __entry->thread_todo = thread_todo;
  78. ),
  79. TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d",
  80. __entry->proc_work, __entry->transaction_stack,
  81. __entry->thread_todo)
  82. );
  83. TRACE_EVENT(binder_transaction,
  84. TP_PROTO(bool reply, struct binder_transaction *t,
  85. struct binder_node *target_node),
  86. TP_ARGS(reply, t, target_node),
  87. TP_STRUCT__entry(
  88. __field(int, debug_id)
  89. __field(int, target_node)
  90. __field(int, to_proc)
  91. __field(int, to_thread)
  92. __field(int, reply)
  93. __field(unsigned int, code)
  94. __field(unsigned int, flags)
  95. ),
  96. TP_fast_assign(
  97. __entry->debug_id = t->debug_id;
  98. __entry->target_node = target_node ? target_node->debug_id : 0;
  99. __entry->to_proc = t->to_proc->pid;
  100. __entry->to_thread = t->to_thread ? t->to_thread->pid : 0;
  101. __entry->reply = reply;
  102. __entry->code = t->code;
  103. __entry->flags = t->flags;
  104. ),
  105. TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x",
  106. __entry->debug_id, __entry->target_node,
  107. __entry->to_proc, __entry->to_thread,
  108. __entry->reply, __entry->flags, __entry->code)
  109. );
  110. TRACE_EVENT(binder_transaction_received,
  111. TP_PROTO(struct binder_transaction *t),
  112. TP_ARGS(t),
  113. TP_STRUCT__entry(
  114. __field(int, debug_id)
  115. ),
  116. TP_fast_assign(
  117. __entry->debug_id = t->debug_id;
  118. ),
  119. TP_printk("transaction=%d", __entry->debug_id)
  120. );
  121. TRACE_EVENT(binder_transaction_node_to_ref,
  122. TP_PROTO(struct binder_transaction *t, struct binder_node *node,
  123. struct binder_ref_data *rdata),
  124. TP_ARGS(t, node, rdata),
  125. TP_STRUCT__entry(
  126. __field(int, debug_id)
  127. __field(int, node_debug_id)
  128. __field(binder_uintptr_t, node_ptr)
  129. __field(int, ref_debug_id)
  130. __field(uint32_t, ref_desc)
  131. ),
  132. TP_fast_assign(
  133. __entry->debug_id = t->debug_id;
  134. __entry->node_debug_id = node->debug_id;
  135. __entry->node_ptr = node->ptr;
  136. __entry->ref_debug_id = rdata->debug_id;
  137. __entry->ref_desc = rdata->desc;
  138. ),
  139. TP_printk("transaction=%d node=%d src_ptr=0x%016llx ==> dest_ref=%d dest_desc=%d",
  140. __entry->debug_id, __entry->node_debug_id,
  141. (u64)__entry->node_ptr,
  142. __entry->ref_debug_id, __entry->ref_desc)
  143. );
  144. TRACE_EVENT(binder_transaction_ref_to_node,
  145. TP_PROTO(struct binder_transaction *t, struct binder_node *node,
  146. struct binder_ref_data *rdata),
  147. TP_ARGS(t, node, rdata),
  148. TP_STRUCT__entry(
  149. __field(int, debug_id)
  150. __field(int, ref_debug_id)
  151. __field(uint32_t, ref_desc)
  152. __field(int, node_debug_id)
  153. __field(binder_uintptr_t, node_ptr)
  154. ),
  155. TP_fast_assign(
  156. __entry->debug_id = t->debug_id;
  157. __entry->ref_debug_id = rdata->debug_id;
  158. __entry->ref_desc = rdata->desc;
  159. __entry->node_debug_id = node->debug_id;
  160. __entry->node_ptr = node->ptr;
  161. ),
  162. TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx",
  163. __entry->debug_id, __entry->node_debug_id,
  164. __entry->ref_debug_id, __entry->ref_desc,
  165. (u64)__entry->node_ptr)
  166. );
  167. TRACE_EVENT(binder_transaction_ref_to_ref,
  168. TP_PROTO(struct binder_transaction *t, struct binder_node *node,
  169. struct binder_ref_data *src_ref,
  170. struct binder_ref_data *dest_ref),
  171. TP_ARGS(t, node, src_ref, dest_ref),
  172. TP_STRUCT__entry(
  173. __field(int, debug_id)
  174. __field(int, node_debug_id)
  175. __field(int, src_ref_debug_id)
  176. __field(uint32_t, src_ref_desc)
  177. __field(int, dest_ref_debug_id)
  178. __field(uint32_t, dest_ref_desc)
  179. ),
  180. TP_fast_assign(
  181. __entry->debug_id = t->debug_id;
  182. __entry->node_debug_id = node->debug_id;
  183. __entry->src_ref_debug_id = src_ref->debug_id;
  184. __entry->src_ref_desc = src_ref->desc;
  185. __entry->dest_ref_debug_id = dest_ref->debug_id;
  186. __entry->dest_ref_desc = dest_ref->desc;
  187. ),
  188. TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d",
  189. __entry->debug_id, __entry->node_debug_id,
  190. __entry->src_ref_debug_id, __entry->src_ref_desc,
  191. __entry->dest_ref_debug_id, __entry->dest_ref_desc)
  192. );
  193. TRACE_EVENT(binder_transaction_fd_send,
  194. TP_PROTO(struct binder_transaction *t, int fd, size_t offset),
  195. TP_ARGS(t, fd, offset),
  196. TP_STRUCT__entry(
  197. __field(int, debug_id)
  198. __field(int, fd)
  199. __field(size_t, offset)
  200. ),
  201. TP_fast_assign(
  202. __entry->debug_id = t->debug_id;
  203. __entry->fd = fd;
  204. __entry->offset = offset;
  205. ),
  206. TP_printk("transaction=%d src_fd=%d offset=%zu",
  207. __entry->debug_id, __entry->fd, __entry->offset)
  208. );
  209. TRACE_EVENT(binder_transaction_fd_recv,
  210. TP_PROTO(struct binder_transaction *t, int fd, size_t offset),
  211. TP_ARGS(t, fd, offset),
  212. TP_STRUCT__entry(
  213. __field(int, debug_id)
  214. __field(int, fd)
  215. __field(size_t, offset)
  216. ),
  217. TP_fast_assign(
  218. __entry->debug_id = t->debug_id;
  219. __entry->fd = fd;
  220. __entry->offset = offset;
  221. ),
  222. TP_printk("transaction=%d dest_fd=%d offset=%zu",
  223. __entry->debug_id, __entry->fd, __entry->offset)
  224. );
  225. DECLARE_EVENT_CLASS(binder_buffer_class,
  226. TP_PROTO(struct binder_buffer *buf),
  227. TP_ARGS(buf),
  228. TP_STRUCT__entry(
  229. __field(int, debug_id)
  230. __field(size_t, data_size)
  231. __field(size_t, offsets_size)
  232. __field(size_t, extra_buffers_size)
  233. ),
  234. TP_fast_assign(
  235. __entry->debug_id = buf->debug_id;
  236. __entry->data_size = buf->data_size;
  237. __entry->offsets_size = buf->offsets_size;
  238. __entry->extra_buffers_size = buf->extra_buffers_size;
  239. ),
  240. TP_printk("transaction=%d data_size=%zd offsets_size=%zd extra_buffers_size=%zd",
  241. __entry->debug_id, __entry->data_size, __entry->offsets_size,
  242. __entry->extra_buffers_size)
  243. );
  244. DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf,
  245. TP_PROTO(struct binder_buffer *buffer),
  246. TP_ARGS(buffer));
  247. DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release,
  248. TP_PROTO(struct binder_buffer *buffer),
  249. TP_ARGS(buffer));
  250. DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release,
  251. TP_PROTO(struct binder_buffer *buffer),
  252. TP_ARGS(buffer));
  253. TRACE_EVENT(binder_update_page_range,
  254. TP_PROTO(struct binder_alloc *alloc, bool allocate,
  255. void __user *start, void __user *end),
  256. TP_ARGS(alloc, allocate, start, end),
  257. TP_STRUCT__entry(
  258. __field(int, proc)
  259. __field(bool, allocate)
  260. __field(size_t, offset)
  261. __field(size_t, size)
  262. ),
  263. TP_fast_assign(
  264. __entry->proc = alloc->pid;
  265. __entry->allocate = allocate;
  266. __entry->offset = start - alloc->buffer;
  267. __entry->size = end - start;
  268. ),
  269. TP_printk("proc=%d allocate=%d offset=%zu size=%zu",
  270. __entry->proc, __entry->allocate,
  271. __entry->offset, __entry->size)
  272. );
  273. DECLARE_EVENT_CLASS(binder_lru_page_class,
  274. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  275. TP_ARGS(alloc, page_index),
  276. TP_STRUCT__entry(
  277. __field(int, proc)
  278. __field(size_t, page_index)
  279. ),
  280. TP_fast_assign(
  281. __entry->proc = alloc->pid;
  282. __entry->page_index = page_index;
  283. ),
  284. TP_printk("proc=%d page_index=%zu",
  285. __entry->proc, __entry->page_index)
  286. );
  287. DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start,
  288. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  289. TP_ARGS(alloc, page_index));
  290. DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end,
  291. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  292. TP_ARGS(alloc, page_index));
  293. DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start,
  294. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  295. TP_ARGS(alloc, page_index));
  296. DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end,
  297. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  298. TP_ARGS(alloc, page_index));
  299. DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_start,
  300. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  301. TP_ARGS(alloc, page_index));
  302. DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_end,
  303. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  304. TP_ARGS(alloc, page_index));
  305. DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_start,
  306. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  307. TP_ARGS(alloc, page_index));
  308. DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_end,
  309. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  310. TP_ARGS(alloc, page_index));
  311. DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_start,
  312. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  313. TP_ARGS(alloc, page_index));
  314. DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_end,
  315. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  316. TP_ARGS(alloc, page_index));
  317. TRACE_EVENT(binder_command,
  318. TP_PROTO(uint32_t cmd),
  319. TP_ARGS(cmd),
  320. TP_STRUCT__entry(
  321. __field(uint32_t, cmd)
  322. ),
  323. TP_fast_assign(
  324. __entry->cmd = cmd;
  325. ),
  326. TP_printk("cmd=0x%x %s",
  327. __entry->cmd,
  328. _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ?
  329. binder_command_strings[_IOC_NR(__entry->cmd)] :
  330. "unknown")
  331. );
  332. TRACE_EVENT(binder_return,
  333. TP_PROTO(uint32_t cmd),
  334. TP_ARGS(cmd),
  335. TP_STRUCT__entry(
  336. __field(uint32_t, cmd)
  337. ),
  338. TP_fast_assign(
  339. __entry->cmd = cmd;
  340. ),
  341. TP_printk("cmd=0x%x %s",
  342. __entry->cmd,
  343. _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ?
  344. binder_return_strings[_IOC_NR(__entry->cmd)] :
  345. "unknown")
  346. );
  347. #endif /* _BINDER_TRACE_H */
  348. #undef TRACE_INCLUDE_PATH
  349. #undef TRACE_INCLUDE_FILE
  350. #define TRACE_INCLUDE_PATH .
  351. #define TRACE_INCLUDE_FILE binder_trace
  352. #include <trace/define_trace.h>