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