binder_trace.h 11 KB

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