binder_trace.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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_set_priority,
  67. TP_PROTO(int proc, int thread, unsigned int old_prio,
  68. unsigned int desired_prio, unsigned int new_prio),
  69. TP_ARGS(proc, thread, old_prio, new_prio, desired_prio),
  70. TP_STRUCT__entry(
  71. __field(int, proc)
  72. __field(int, thread)
  73. __field(unsigned int, old_prio)
  74. __field(unsigned int, new_prio)
  75. __field(unsigned int, desired_prio)
  76. ),
  77. TP_fast_assign(
  78. __entry->proc = proc;
  79. __entry->thread = thread;
  80. __entry->old_prio = old_prio;
  81. __entry->new_prio = new_prio;
  82. __entry->desired_prio = desired_prio;
  83. ),
  84. TP_printk("proc=%d thread=%d old=%d => new=%d desired=%d",
  85. __entry->proc, __entry->thread, __entry->old_prio,
  86. __entry->new_prio, __entry->desired_prio)
  87. );
  88. TRACE_EVENT(binder_wait_for_work,
  89. TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo),
  90. TP_ARGS(proc_work, transaction_stack, thread_todo),
  91. TP_STRUCT__entry(
  92. __field(bool, proc_work)
  93. __field(bool, transaction_stack)
  94. __field(bool, thread_todo)
  95. ),
  96. TP_fast_assign(
  97. __entry->proc_work = proc_work;
  98. __entry->transaction_stack = transaction_stack;
  99. __entry->thread_todo = thread_todo;
  100. ),
  101. TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d",
  102. __entry->proc_work, __entry->transaction_stack,
  103. __entry->thread_todo)
  104. );
  105. TRACE_EVENT(binder_txn_latency_free,
  106. TP_PROTO(struct binder_transaction *t,
  107. int from_proc, int from_thread,
  108. int to_proc, int to_thread),
  109. TP_ARGS(t, from_proc, from_thread, to_proc, to_thread),
  110. TP_STRUCT__entry(
  111. __field(int, debug_id)
  112. __field(int, from_proc)
  113. __field(int, from_thread)
  114. __field(int, to_proc)
  115. __field(int, to_thread)
  116. __field(unsigned int, code)
  117. __field(unsigned int, flags)
  118. ),
  119. TP_fast_assign(
  120. __entry->debug_id = t->debug_id;
  121. __entry->from_proc = from_proc;
  122. __entry->from_thread = from_thread;
  123. __entry->to_proc = to_proc;
  124. __entry->to_thread = to_thread;
  125. __entry->code = t->code;
  126. __entry->flags = t->flags;
  127. ),
  128. TP_printk("transaction=%d from %d:%d to %d:%d flags=0x%x code=0x%x",
  129. __entry->debug_id, __entry->from_proc, __entry->from_thread,
  130. __entry->to_proc, __entry->to_thread, __entry->code,
  131. __entry->flags)
  132. );
  133. TRACE_EVENT(binder_transaction,
  134. TP_PROTO(bool reply, struct binder_transaction *t,
  135. struct binder_node *target_node),
  136. TP_ARGS(reply, t, target_node),
  137. TP_STRUCT__entry(
  138. __field(int, debug_id)
  139. __field(int, target_node)
  140. __field(int, to_proc)
  141. __field(int, to_thread)
  142. __field(int, reply)
  143. __field(unsigned int, code)
  144. __field(unsigned int, flags)
  145. ),
  146. TP_fast_assign(
  147. __entry->debug_id = t->debug_id;
  148. __entry->target_node = target_node ? target_node->debug_id : 0;
  149. __entry->to_proc = t->to_proc->pid;
  150. __entry->to_thread = t->to_thread ? t->to_thread->pid : 0;
  151. __entry->reply = reply;
  152. __entry->code = t->code;
  153. __entry->flags = t->flags;
  154. ),
  155. TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x",
  156. __entry->debug_id, __entry->target_node,
  157. __entry->to_proc, __entry->to_thread,
  158. __entry->reply, __entry->flags, __entry->code)
  159. );
  160. TRACE_EVENT(binder_transaction_received,
  161. TP_PROTO(struct binder_transaction *t),
  162. TP_ARGS(t),
  163. TP_STRUCT__entry(
  164. __field(int, debug_id)
  165. ),
  166. TP_fast_assign(
  167. __entry->debug_id = t->debug_id;
  168. ),
  169. TP_printk("transaction=%d", __entry->debug_id)
  170. );
  171. TRACE_EVENT(binder_transaction_node_to_ref,
  172. TP_PROTO(struct binder_transaction *t, struct binder_node *node,
  173. struct binder_ref_data *rdata),
  174. TP_ARGS(t, node, rdata),
  175. TP_STRUCT__entry(
  176. __field(int, debug_id)
  177. __field(int, node_debug_id)
  178. __field(binder_uintptr_t, node_ptr)
  179. __field(int, ref_debug_id)
  180. __field(uint32_t, ref_desc)
  181. ),
  182. TP_fast_assign(
  183. __entry->debug_id = t->debug_id;
  184. __entry->node_debug_id = node->debug_id;
  185. __entry->node_ptr = node->ptr;
  186. __entry->ref_debug_id = rdata->debug_id;
  187. __entry->ref_desc = rdata->desc;
  188. ),
  189. TP_printk("transaction=%d node=%d src_ptr=0x%016llx ==> dest_ref=%d dest_desc=%d",
  190. __entry->debug_id, __entry->node_debug_id,
  191. (u64)__entry->node_ptr,
  192. __entry->ref_debug_id, __entry->ref_desc)
  193. );
  194. TRACE_EVENT(binder_transaction_ref_to_node,
  195. TP_PROTO(struct binder_transaction *t, struct binder_node *node,
  196. struct binder_ref_data *rdata),
  197. TP_ARGS(t, node, rdata),
  198. TP_STRUCT__entry(
  199. __field(int, debug_id)
  200. __field(int, ref_debug_id)
  201. __field(uint32_t, ref_desc)
  202. __field(int, node_debug_id)
  203. __field(binder_uintptr_t, node_ptr)
  204. ),
  205. TP_fast_assign(
  206. __entry->debug_id = t->debug_id;
  207. __entry->ref_debug_id = rdata->debug_id;
  208. __entry->ref_desc = rdata->desc;
  209. __entry->node_debug_id = node->debug_id;
  210. __entry->node_ptr = node->ptr;
  211. ),
  212. TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx",
  213. __entry->debug_id, __entry->node_debug_id,
  214. __entry->ref_debug_id, __entry->ref_desc,
  215. (u64)__entry->node_ptr)
  216. );
  217. TRACE_EVENT(binder_transaction_ref_to_ref,
  218. TP_PROTO(struct binder_transaction *t, struct binder_node *node,
  219. struct binder_ref_data *src_ref,
  220. struct binder_ref_data *dest_ref),
  221. TP_ARGS(t, node, src_ref, dest_ref),
  222. TP_STRUCT__entry(
  223. __field(int, debug_id)
  224. __field(int, node_debug_id)
  225. __field(int, src_ref_debug_id)
  226. __field(uint32_t, src_ref_desc)
  227. __field(int, dest_ref_debug_id)
  228. __field(uint32_t, dest_ref_desc)
  229. ),
  230. TP_fast_assign(
  231. __entry->debug_id = t->debug_id;
  232. __entry->node_debug_id = node->debug_id;
  233. __entry->src_ref_debug_id = src_ref->debug_id;
  234. __entry->src_ref_desc = src_ref->desc;
  235. __entry->dest_ref_debug_id = dest_ref->debug_id;
  236. __entry->dest_ref_desc = dest_ref->desc;
  237. ),
  238. TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d",
  239. __entry->debug_id, __entry->node_debug_id,
  240. __entry->src_ref_debug_id, __entry->src_ref_desc,
  241. __entry->dest_ref_debug_id, __entry->dest_ref_desc)
  242. );
  243. TRACE_EVENT(binder_transaction_fd_send,
  244. TP_PROTO(struct binder_transaction *t, int fd, size_t offset),
  245. TP_ARGS(t, fd, offset),
  246. TP_STRUCT__entry(
  247. __field(int, debug_id)
  248. __field(int, fd)
  249. __field(size_t, offset)
  250. ),
  251. TP_fast_assign(
  252. __entry->debug_id = t->debug_id;
  253. __entry->fd = fd;
  254. __entry->offset = offset;
  255. ),
  256. TP_printk("transaction=%d src_fd=%d offset=%zu",
  257. __entry->debug_id, __entry->fd, __entry->offset)
  258. );
  259. TRACE_EVENT(binder_transaction_fd_recv,
  260. TP_PROTO(struct binder_transaction *t, int fd, size_t offset),
  261. TP_ARGS(t, fd, offset),
  262. TP_STRUCT__entry(
  263. __field(int, debug_id)
  264. __field(int, fd)
  265. __field(size_t, offset)
  266. ),
  267. TP_fast_assign(
  268. __entry->debug_id = t->debug_id;
  269. __entry->fd = fd;
  270. __entry->offset = offset;
  271. ),
  272. TP_printk("transaction=%d dest_fd=%d offset=%zu",
  273. __entry->debug_id, __entry->fd, __entry->offset)
  274. );
  275. DECLARE_EVENT_CLASS(binder_buffer_class,
  276. TP_PROTO(struct binder_buffer *buf),
  277. TP_ARGS(buf),
  278. TP_STRUCT__entry(
  279. __field(int, debug_id)
  280. __field(size_t, data_size)
  281. __field(size_t, offsets_size)
  282. __field(size_t, extra_buffers_size)
  283. ),
  284. TP_fast_assign(
  285. __entry->debug_id = buf->debug_id;
  286. __entry->data_size = buf->data_size;
  287. __entry->offsets_size = buf->offsets_size;
  288. __entry->extra_buffers_size = buf->extra_buffers_size;
  289. ),
  290. TP_printk("transaction=%d data_size=%zd offsets_size=%zd extra_buffers_size=%zd",
  291. __entry->debug_id, __entry->data_size, __entry->offsets_size,
  292. __entry->extra_buffers_size)
  293. );
  294. DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf,
  295. TP_PROTO(struct binder_buffer *buffer),
  296. TP_ARGS(buffer));
  297. DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release,
  298. TP_PROTO(struct binder_buffer *buffer),
  299. TP_ARGS(buffer));
  300. DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release,
  301. TP_PROTO(struct binder_buffer *buffer),
  302. TP_ARGS(buffer));
  303. DEFINE_EVENT(binder_buffer_class, binder_transaction_update_buffer_release,
  304. TP_PROTO(struct binder_buffer *buffer),
  305. TP_ARGS(buffer));
  306. TRACE_EVENT(binder_update_page_range,
  307. TP_PROTO(struct binder_alloc *alloc, bool allocate,
  308. void __user *start, void __user *end),
  309. TP_ARGS(alloc, allocate, start, end),
  310. TP_STRUCT__entry(
  311. __field(int, proc)
  312. __field(bool, allocate)
  313. __field(size_t, offset)
  314. __field(size_t, size)
  315. ),
  316. TP_fast_assign(
  317. __entry->proc = alloc->pid;
  318. __entry->allocate = allocate;
  319. __entry->offset = start - alloc->buffer;
  320. __entry->size = end - start;
  321. ),
  322. TP_printk("proc=%d allocate=%d offset=%zu size=%zu",
  323. __entry->proc, __entry->allocate,
  324. __entry->offset, __entry->size)
  325. );
  326. DECLARE_EVENT_CLASS(binder_lru_page_class,
  327. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  328. TP_ARGS(alloc, page_index),
  329. TP_STRUCT__entry(
  330. __field(int, proc)
  331. __field(size_t, page_index)
  332. ),
  333. TP_fast_assign(
  334. __entry->proc = alloc->pid;
  335. __entry->page_index = page_index;
  336. ),
  337. TP_printk("proc=%d page_index=%zu",
  338. __entry->proc, __entry->page_index)
  339. );
  340. DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start,
  341. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  342. TP_ARGS(alloc, page_index));
  343. DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end,
  344. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  345. TP_ARGS(alloc, page_index));
  346. DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start,
  347. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  348. TP_ARGS(alloc, page_index));
  349. DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end,
  350. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  351. TP_ARGS(alloc, page_index));
  352. DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_start,
  353. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  354. TP_ARGS(alloc, page_index));
  355. DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_end,
  356. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  357. TP_ARGS(alloc, page_index));
  358. DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_start,
  359. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  360. TP_ARGS(alloc, page_index));
  361. DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_end,
  362. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  363. TP_ARGS(alloc, page_index));
  364. DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_start,
  365. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  366. TP_ARGS(alloc, page_index));
  367. DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_end,
  368. TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
  369. TP_ARGS(alloc, page_index));
  370. TRACE_EVENT(binder_command,
  371. TP_PROTO(uint32_t cmd),
  372. TP_ARGS(cmd),
  373. TP_STRUCT__entry(
  374. __field(uint32_t, cmd)
  375. ),
  376. TP_fast_assign(
  377. __entry->cmd = cmd;
  378. ),
  379. TP_printk("cmd=0x%x %s",
  380. __entry->cmd,
  381. _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ?
  382. binder_command_strings[_IOC_NR(__entry->cmd)] :
  383. "unknown")
  384. );
  385. TRACE_EVENT(binder_return,
  386. TP_PROTO(uint32_t cmd),
  387. TP_ARGS(cmd),
  388. TP_STRUCT__entry(
  389. __field(uint32_t, cmd)
  390. ),
  391. TP_fast_assign(
  392. __entry->cmd = cmd;
  393. ),
  394. TP_printk("cmd=0x%x %s",
  395. __entry->cmd,
  396. _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ?
  397. binder_return_strings[_IOC_NR(__entry->cmd)] :
  398. "unknown")
  399. );
  400. #endif /* _BINDER_TRACE_H */
  401. #undef TRACE_INCLUDE_PATH
  402. #undef TRACE_INCLUDE_FILE
  403. #define TRACE_INCLUDE_PATH .
  404. #define TRACE_INCLUDE_FILE binder_trace
  405. #include <trace/define_trace.h>