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