1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 Google, Inc.
7 #define TRACE_SYSTEM binder
9 #if !defined(_BINDER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
10 #define _BINDER_TRACE_H
12 #include <linux/tracepoint.h>
18 struct binder_ref_data;
20 struct binder_transaction;
22 TRACE_EVENT(binder_ioctl,
23 TP_PROTO(unsigned int cmd, unsigned long arg),
27 __field(unsigned int, cmd)
28 __field(unsigned long, arg)
34 TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg)
37 DECLARE_EVENT_CLASS(binder_lock_class,
38 TP_PROTO(const char *tag),
41 __field(const char *, tag)
46 TP_printk("tag=%s", __entry->tag)
49 #define DEFINE_BINDER_LOCK_EVENT(name) \
50 DEFINE_EVENT(binder_lock_class, name, \
51 TP_PROTO(const char *func), \
54 DEFINE_BINDER_LOCK_EVENT(binder_lock);
55 DEFINE_BINDER_LOCK_EVENT(binder_locked);
56 DEFINE_BINDER_LOCK_EVENT(binder_unlock);
58 DECLARE_EVENT_CLASS(binder_function_return_class,
67 TP_printk("ret=%d", __entry->ret)
70 #define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name) \
71 DEFINE_EVENT(binder_function_return_class, name, \
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);
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),
84 __field(bool, proc_work)
85 __field(bool, transaction_stack)
86 __field(bool, thread_todo)
89 __entry->proc_work = proc_work;
90 __entry->transaction_stack = transaction_stack;
91 __entry->thread_todo = thread_todo;
93 TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d",
94 __entry->proc_work, __entry->transaction_stack,
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),
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)
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;
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,
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),
132 __field(int, debug_id)
133 __field(int, target_node)
134 __field(int, to_proc)
135 __field(int, to_thread)
137 __field(unsigned int, code)
138 __field(unsigned int, flags)
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;
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)
155 TRACE_EVENT(binder_transaction_received,
156 TP_PROTO(struct binder_transaction *t),
160 __field(int, debug_id)
163 __entry->debug_id = t->debug_id;
165 TP_printk("transaction=%d", __entry->debug_id)
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),
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)
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;
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)
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),
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)
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;
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)
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),
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)
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;
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)
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),
251 __field(int, debug_id)
253 __field(size_t, offset)
256 __entry->debug_id = t->debug_id;
258 __entry->offset = offset;
260 TP_printk("transaction=%d src_fd=%d offset=%zu",
261 __entry->debug_id, __entry->fd, __entry->offset)
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),
269 __field(int, debug_id)
271 __field(size_t, offset)
274 __entry->debug_id = t->debug_id;
276 __entry->offset = offset;
278 TP_printk("transaction=%d dest_fd=%d offset=%zu",
279 __entry->debug_id, __entry->fd, __entry->offset)
282 DECLARE_EVENT_CLASS(binder_buffer_class,
283 TP_PROTO(struct binder_buffer *buf),
286 __field(int, debug_id)
287 __field(size_t, data_size)
288 __field(size_t, offsets_size)
289 __field(size_t, extra_buffers_size)
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;
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)
302 DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf,
303 TP_PROTO(struct binder_buffer *buffer),
306 DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release,
307 TP_PROTO(struct binder_buffer *buffer),
310 DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release,
311 TP_PROTO(struct binder_buffer *buffer),
314 DEFINE_EVENT(binder_buffer_class, binder_transaction_update_buffer_release,
315 TP_PROTO(struct binder_buffer *buffer),
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),
324 __field(bool, allocate)
325 __field(size_t, offset)
326 __field(size_t, size)
329 __entry->proc = alloc->pid;
330 __entry->allocate = allocate;
331 __entry->offset = start - alloc->buffer;
332 __entry->size = end - start;
334 TP_printk("proc=%d allocate=%d offset=%zu size=%zu",
335 __entry->proc, __entry->allocate,
336 __entry->offset, __entry->size)
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),
344 __field(size_t, page_index)
347 __entry->proc = alloc->pid;
348 __entry->page_index = page_index;
350 TP_printk("proc=%d page_index=%zu",
351 __entry->proc, __entry->page_index)
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));
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));
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));
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));
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));
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));
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));
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));
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));
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));
394 TRACE_EVENT(binder_command,
395 TP_PROTO(uint32_t cmd),
398 __field(uint32_t, cmd)
403 TP_printk("cmd=0x%x %s",
405 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ?
406 binder_command_strings[_IOC_NR(__entry->cmd)] :
410 TRACE_EVENT(binder_return,
411 TP_PROTO(uint32_t cmd),
414 __field(uint32_t, cmd)
419 TP_printk("cmd=0x%x %s",
421 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ?
422 binder_return_strings[_IOC_NR(__entry->cmd)] :
426 #endif /* _BINDER_TRACE_H */
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>