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 TRACE_EVENT(binder_update_page_range
,
315 TP_PROTO(struct binder_alloc
*alloc
, bool allocate
,
316 void __user
*start
, void __user
*end
),
317 TP_ARGS(alloc
, allocate
, start
, end
),
320 __field(bool, allocate
)
321 __field(size_t, offset
)
322 __field(size_t, size
)
325 __entry
->proc
= alloc
->pid
;
326 __entry
->allocate
= allocate
;
327 __entry
->offset
= start
- alloc
->buffer
;
328 __entry
->size
= end
- start
;
330 TP_printk("proc=%d allocate=%d offset=%zu size=%zu",
331 __entry
->proc
, __entry
->allocate
,
332 __entry
->offset
, __entry
->size
)
335 DECLARE_EVENT_CLASS(binder_lru_page_class
,
336 TP_PROTO(const struct binder_alloc
*alloc
, size_t page_index
),
337 TP_ARGS(alloc
, page_index
),
340 __field(size_t, page_index
)
343 __entry
->proc
= alloc
->pid
;
344 __entry
->page_index
= page_index
;
346 TP_printk("proc=%d page_index=%zu",
347 __entry
->proc
, __entry
->page_index
)
350 DEFINE_EVENT(binder_lru_page_class
, binder_alloc_lru_start
,
351 TP_PROTO(const struct binder_alloc
*alloc
, size_t page_index
),
352 TP_ARGS(alloc
, page_index
));
354 DEFINE_EVENT(binder_lru_page_class
, binder_alloc_lru_end
,
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_free_lru_start
,
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_end
,
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_alloc_page_start
,
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_end
,
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_unmap_user_start
,
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_end
,
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_kernel_start
,
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_end
,
387 TP_PROTO(const struct binder_alloc
*alloc
, size_t page_index
),
388 TP_ARGS(alloc
, page_index
));
390 TRACE_EVENT(binder_command
,
391 TP_PROTO(uint32_t cmd
),
394 __field(uint32_t, cmd
)
399 TP_printk("cmd=0x%x %s",
401 _IOC_NR(__entry
->cmd
) < ARRAY_SIZE(binder_command_strings
) ?
402 binder_command_strings
[_IOC_NR(__entry
->cmd
)] :
406 TRACE_EVENT(binder_return
,
407 TP_PROTO(uint32_t cmd
),
410 __field(uint32_t, cmd
)
415 TP_printk("cmd=0x%x %s",
417 _IOC_NR(__entry
->cmd
) < ARRAY_SIZE(binder_return_strings
) ?
418 binder_return_strings
[_IOC_NR(__entry
->cmd
)] :
422 #endif /* _BINDER_TRACE_H */
424 #undef TRACE_INCLUDE_PATH
425 #undef TRACE_INCLUDE_FILE
426 #define TRACE_INCLUDE_PATH .
427 #define TRACE_INCLUDE_FILE binder_trace
428 #include <trace/define_trace.h>