| 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_function_return_class, |
| 38 | TP_PROTO(int ret), |
| 39 | TP_ARGS(ret), |
| 40 | TP_STRUCT__entry( |
| 41 | __field(int, ret) |
| 42 | ), |
| 43 | TP_fast_assign( |
| 44 | __entry->ret = ret; |
| 45 | ), |
| 46 | TP_printk("ret=%d" , __entry->ret) |
| 47 | ); |
| 48 | |
| 49 | #define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name) \ |
| 50 | DEFINE_EVENT(binder_function_return_class, name, \ |
| 51 | TP_PROTO(int ret), \ |
| 52 | TP_ARGS(ret)) |
| 53 | |
| 54 | DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done); |
| 55 | DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_write_done); |
| 56 | DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_read_done); |
| 57 | |
| 58 | TRACE_EVENT(binder_wait_for_work, |
| 59 | TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo), |
| 60 | TP_ARGS(proc_work, transaction_stack, thread_todo), |
| 61 | |
| 62 | TP_STRUCT__entry( |
| 63 | __field(bool, proc_work) |
| 64 | __field(bool, transaction_stack) |
| 65 | __field(bool, thread_todo) |
| 66 | ), |
| 67 | TP_fast_assign( |
| 68 | __entry->proc_work = proc_work; |
| 69 | __entry->transaction_stack = transaction_stack; |
| 70 | __entry->thread_todo = thread_todo; |
| 71 | ), |
| 72 | TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d" , |
| 73 | __entry->proc_work, __entry->transaction_stack, |
| 74 | __entry->thread_todo) |
| 75 | ); |
| 76 | |
| 77 | TRACE_EVENT(binder_txn_latency_free, |
| 78 | TP_PROTO(struct binder_transaction *t, |
| 79 | int from_proc, int from_thread, |
| 80 | int to_proc, int to_thread), |
| 81 | TP_ARGS(t, from_proc, from_thread, to_proc, to_thread), |
| 82 | TP_STRUCT__entry( |
| 83 | __field(int, debug_id) |
| 84 | __field(int, from_proc) |
| 85 | __field(int, from_thread) |
| 86 | __field(int, to_proc) |
| 87 | __field(int, to_thread) |
| 88 | __field(unsigned int, code) |
| 89 | __field(unsigned int, flags) |
| 90 | ), |
| 91 | TP_fast_assign( |
| 92 | __entry->debug_id = t->debug_id; |
| 93 | __entry->from_proc = from_proc; |
| 94 | __entry->from_thread = from_thread; |
| 95 | __entry->to_proc = to_proc; |
| 96 | __entry->to_thread = to_thread; |
| 97 | __entry->code = t->code; |
| 98 | __entry->flags = t->flags; |
| 99 | ), |
| 100 | TP_printk("transaction=%d from %d:%d to %d:%d flags=0x%x code=0x%x" , |
| 101 | __entry->debug_id, __entry->from_proc, __entry->from_thread, |
| 102 | __entry->to_proc, __entry->to_thread, __entry->code, |
| 103 | __entry->flags) |
| 104 | ); |
| 105 | |
| 106 | TRACE_EVENT(binder_transaction, |
| 107 | TP_PROTO(bool reply, struct binder_transaction *t, |
| 108 | struct binder_node *target_node), |
| 109 | TP_ARGS(reply, t, target_node), |
| 110 | TP_STRUCT__entry( |
| 111 | __field(int, debug_id) |
| 112 | __field(int, target_node) |
| 113 | __field(int, to_proc) |
| 114 | __field(int, to_thread) |
| 115 | __field(int, reply) |
| 116 | __field(unsigned int, code) |
| 117 | __field(unsigned int, flags) |
| 118 | ), |
| 119 | TP_fast_assign( |
| 120 | __entry->debug_id = t->debug_id; |
| 121 | __entry->target_node = target_node ? target_node->debug_id : 0; |
| 122 | __entry->to_proc = t->to_proc->pid; |
| 123 | __entry->to_thread = t->to_thread ? t->to_thread->pid : 0; |
| 124 | __entry->reply = reply; |
| 125 | __entry->code = t->code; |
| 126 | __entry->flags = t->flags; |
| 127 | ), |
| 128 | TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x" , |
| 129 | __entry->debug_id, __entry->target_node, |
| 130 | __entry->to_proc, __entry->to_thread, |
| 131 | __entry->reply, __entry->flags, __entry->code) |
| 132 | ); |
| 133 | |
| 134 | TRACE_EVENT(binder_transaction_received, |
| 135 | TP_PROTO(struct binder_transaction *t), |
| 136 | TP_ARGS(t), |
| 137 | |
| 138 | TP_STRUCT__entry( |
| 139 | __field(int, debug_id) |
| 140 | ), |
| 141 | TP_fast_assign( |
| 142 | __entry->debug_id = t->debug_id; |
| 143 | ), |
| 144 | TP_printk("transaction=%d" , __entry->debug_id) |
| 145 | ); |
| 146 | |
| 147 | TRACE_EVENT(binder_transaction_node_to_ref, |
| 148 | TP_PROTO(struct binder_transaction *t, struct binder_node *node, |
| 149 | struct binder_ref_data *rdata), |
| 150 | TP_ARGS(t, node, rdata), |
| 151 | |
| 152 | TP_STRUCT__entry( |
| 153 | __field(int, debug_id) |
| 154 | __field(int, node_debug_id) |
| 155 | __field(binder_uintptr_t, node_ptr) |
| 156 | __field(int, ref_debug_id) |
| 157 | __field(uint32_t, ref_desc) |
| 158 | ), |
| 159 | TP_fast_assign( |
| 160 | __entry->debug_id = t->debug_id; |
| 161 | __entry->node_debug_id = node->debug_id; |
| 162 | __entry->node_ptr = node->ptr; |
| 163 | __entry->ref_debug_id = rdata->debug_id; |
| 164 | __entry->ref_desc = rdata->desc; |
| 165 | ), |
| 166 | TP_printk("transaction=%d node=%d src_ptr=0x%016llx ==> dest_ref=%d dest_desc=%d" , |
| 167 | __entry->debug_id, __entry->node_debug_id, |
| 168 | (u64)__entry->node_ptr, |
| 169 | __entry->ref_debug_id, __entry->ref_desc) |
| 170 | ); |
| 171 | |
| 172 | TRACE_EVENT(binder_transaction_ref_to_node, |
| 173 | TP_PROTO(struct binder_transaction *t, struct binder_node *node, |
| 174 | struct binder_ref_data *rdata), |
| 175 | TP_ARGS(t, node, rdata), |
| 176 | |
| 177 | TP_STRUCT__entry( |
| 178 | __field(int, debug_id) |
| 179 | __field(int, ref_debug_id) |
| 180 | __field(uint32_t, ref_desc) |
| 181 | __field(int, node_debug_id) |
| 182 | __field(binder_uintptr_t, node_ptr) |
| 183 | ), |
| 184 | TP_fast_assign( |
| 185 | __entry->debug_id = t->debug_id; |
| 186 | __entry->ref_debug_id = rdata->debug_id; |
| 187 | __entry->ref_desc = rdata->desc; |
| 188 | __entry->node_debug_id = node->debug_id; |
| 189 | __entry->node_ptr = node->ptr; |
| 190 | ), |
| 191 | TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx" , |
| 192 | __entry->debug_id, __entry->node_debug_id, |
| 193 | __entry->ref_debug_id, __entry->ref_desc, |
| 194 | (u64)__entry->node_ptr) |
| 195 | ); |
| 196 | |
| 197 | TRACE_EVENT(binder_transaction_ref_to_ref, |
| 198 | TP_PROTO(struct binder_transaction *t, struct binder_node *node, |
| 199 | struct binder_ref_data *src_ref, |
| 200 | struct binder_ref_data *dest_ref), |
| 201 | TP_ARGS(t, node, src_ref, dest_ref), |
| 202 | |
| 203 | TP_STRUCT__entry( |
| 204 | __field(int, debug_id) |
| 205 | __field(int, node_debug_id) |
| 206 | __field(int, src_ref_debug_id) |
| 207 | __field(uint32_t, src_ref_desc) |
| 208 | __field(int, dest_ref_debug_id) |
| 209 | __field(uint32_t, dest_ref_desc) |
| 210 | ), |
| 211 | TP_fast_assign( |
| 212 | __entry->debug_id = t->debug_id; |
| 213 | __entry->node_debug_id = node->debug_id; |
| 214 | __entry->src_ref_debug_id = src_ref->debug_id; |
| 215 | __entry->src_ref_desc = src_ref->desc; |
| 216 | __entry->dest_ref_debug_id = dest_ref->debug_id; |
| 217 | __entry->dest_ref_desc = dest_ref->desc; |
| 218 | ), |
| 219 | TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d" , |
| 220 | __entry->debug_id, __entry->node_debug_id, |
| 221 | __entry->src_ref_debug_id, __entry->src_ref_desc, |
| 222 | __entry->dest_ref_debug_id, __entry->dest_ref_desc) |
| 223 | ); |
| 224 | |
| 225 | TRACE_EVENT(binder_transaction_fd_send, |
| 226 | TP_PROTO(struct binder_transaction *t, int fd, size_t offset), |
| 227 | TP_ARGS(t, fd, offset), |
| 228 | |
| 229 | TP_STRUCT__entry( |
| 230 | __field(int, debug_id) |
| 231 | __field(int, fd) |
| 232 | __field(size_t, offset) |
| 233 | ), |
| 234 | TP_fast_assign( |
| 235 | __entry->debug_id = t->debug_id; |
| 236 | __entry->fd = fd; |
| 237 | __entry->offset = offset; |
| 238 | ), |
| 239 | TP_printk("transaction=%d src_fd=%d offset=%zu" , |
| 240 | __entry->debug_id, __entry->fd, __entry->offset) |
| 241 | ); |
| 242 | |
| 243 | TRACE_EVENT(binder_transaction_fd_recv, |
| 244 | TP_PROTO(struct binder_transaction *t, int fd, size_t offset), |
| 245 | TP_ARGS(t, fd, offset), |
| 246 | |
| 247 | TP_STRUCT__entry( |
| 248 | __field(int, debug_id) |
| 249 | __field(int, fd) |
| 250 | __field(size_t, offset) |
| 251 | ), |
| 252 | TP_fast_assign( |
| 253 | __entry->debug_id = t->debug_id; |
| 254 | __entry->fd = fd; |
| 255 | __entry->offset = offset; |
| 256 | ), |
| 257 | TP_printk("transaction=%d dest_fd=%d offset=%zu" , |
| 258 | __entry->debug_id, __entry->fd, __entry->offset) |
| 259 | ); |
| 260 | |
| 261 | DECLARE_EVENT_CLASS(binder_buffer_class, |
| 262 | TP_PROTO(struct binder_buffer *buf), |
| 263 | TP_ARGS(buf), |
| 264 | TP_STRUCT__entry( |
| 265 | __field(int, debug_id) |
| 266 | __field(size_t, data_size) |
| 267 | __field(size_t, offsets_size) |
| 268 | __field(size_t, extra_buffers_size) |
| 269 | ), |
| 270 | TP_fast_assign( |
| 271 | __entry->debug_id = buf->debug_id; |
| 272 | __entry->data_size = buf->data_size; |
| 273 | __entry->offsets_size = buf->offsets_size; |
| 274 | __entry->extra_buffers_size = buf->extra_buffers_size; |
| 275 | ), |
| 276 | TP_printk("transaction=%d data_size=%zd offsets_size=%zd extra_buffers_size=%zd" , |
| 277 | __entry->debug_id, __entry->data_size, __entry->offsets_size, |
| 278 | __entry->extra_buffers_size) |
| 279 | ); |
| 280 | |
| 281 | DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf, |
| 282 | TP_PROTO(struct binder_buffer *buffer), |
| 283 | TP_ARGS(buffer)); |
| 284 | |
| 285 | DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release, |
| 286 | TP_PROTO(struct binder_buffer *buffer), |
| 287 | TP_ARGS(buffer)); |
| 288 | |
| 289 | DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release, |
| 290 | TP_PROTO(struct binder_buffer *buffer), |
| 291 | TP_ARGS(buffer)); |
| 292 | |
| 293 | DEFINE_EVENT(binder_buffer_class, binder_transaction_update_buffer_release, |
| 294 | TP_PROTO(struct binder_buffer *buffer), |
| 295 | TP_ARGS(buffer)); |
| 296 | |
| 297 | TRACE_EVENT(binder_update_page_range, |
| 298 | TP_PROTO(struct binder_alloc *alloc, bool allocate, |
| 299 | unsigned long start, unsigned long end), |
| 300 | TP_ARGS(alloc, allocate, start, end), |
| 301 | TP_STRUCT__entry( |
| 302 | __field(int, proc) |
| 303 | __field(bool, allocate) |
| 304 | __field(size_t, offset) |
| 305 | __field(size_t, size) |
| 306 | ), |
| 307 | TP_fast_assign( |
| 308 | __entry->proc = alloc->pid; |
| 309 | __entry->allocate = allocate; |
| 310 | __entry->offset = start - alloc->vm_start; |
| 311 | __entry->size = end - start; |
| 312 | ), |
| 313 | TP_printk("proc=%d allocate=%d offset=%zu size=%zu" , |
| 314 | __entry->proc, __entry->allocate, |
| 315 | __entry->offset, __entry->size) |
| 316 | ); |
| 317 | |
| 318 | DECLARE_EVENT_CLASS(binder_lru_page_class, |
| 319 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), |
| 320 | TP_ARGS(alloc, page_index), |
| 321 | TP_STRUCT__entry( |
| 322 | __field(int, proc) |
| 323 | __field(size_t, page_index) |
| 324 | ), |
| 325 | TP_fast_assign( |
| 326 | __entry->proc = alloc->pid; |
| 327 | __entry->page_index = page_index; |
| 328 | ), |
| 329 | TP_printk("proc=%d page_index=%zu" , |
| 330 | __entry->proc, __entry->page_index) |
| 331 | ); |
| 332 | |
| 333 | DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start, |
| 334 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), |
| 335 | TP_ARGS(alloc, page_index)); |
| 336 | |
| 337 | DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end, |
| 338 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), |
| 339 | TP_ARGS(alloc, page_index)); |
| 340 | |
| 341 | DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start, |
| 342 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), |
| 343 | TP_ARGS(alloc, page_index)); |
| 344 | |
| 345 | DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end, |
| 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_page_start, |
| 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_alloc_page_end, |
| 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_unmap_user_start, |
| 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_unmap_user_end, |
| 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_unmap_kernel_start, |
| 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_kernel_end, |
| 370 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), |
| 371 | TP_ARGS(alloc, page_index)); |
| 372 | |
| 373 | TRACE_EVENT(binder_command, |
| 374 | TP_PROTO(uint32_t cmd), |
| 375 | TP_ARGS(cmd), |
| 376 | TP_STRUCT__entry( |
| 377 | __field(uint32_t, cmd) |
| 378 | ), |
| 379 | TP_fast_assign( |
| 380 | __entry->cmd = cmd; |
| 381 | ), |
| 382 | TP_printk("cmd=0x%x %s" , |
| 383 | __entry->cmd, |
| 384 | _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ? |
| 385 | binder_command_strings[_IOC_NR(__entry->cmd)] : |
| 386 | "unknown" ) |
| 387 | ); |
| 388 | |
| 389 | TRACE_EVENT(binder_return, |
| 390 | TP_PROTO(uint32_t cmd), |
| 391 | TP_ARGS(cmd), |
| 392 | TP_STRUCT__entry( |
| 393 | __field(uint32_t, cmd) |
| 394 | ), |
| 395 | TP_fast_assign( |
| 396 | __entry->cmd = cmd; |
| 397 | ), |
| 398 | TP_printk("cmd=0x%x %s" , |
| 399 | __entry->cmd, |
| 400 | _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ? |
| 401 | binder_return_strings[_IOC_NR(__entry->cmd)] : |
| 402 | "unknown" ) |
| 403 | ); |
| 404 | |
| 405 | TRACE_EVENT(binder_netlink_report, |
| 406 | TP_PROTO(const char *context, |
| 407 | struct binder_transaction *t, |
| 408 | u32 data_size, |
| 409 | u32 error), |
| 410 | TP_ARGS(context, t, data_size, error), |
| 411 | TP_STRUCT__entry( |
| 412 | __field(const char *, context) |
| 413 | __field(u32, error) |
| 414 | __field(int, from_pid) |
| 415 | __field(int, from_tid) |
| 416 | __field(int, to_pid) |
| 417 | __field(int, to_tid) |
| 418 | __field(bool, is_reply) |
| 419 | __field(unsigned int, flags) |
| 420 | __field(unsigned int, code) |
| 421 | __field(size_t, data_size) |
| 422 | ), |
| 423 | TP_fast_assign( |
| 424 | __entry->context = context; |
| 425 | __entry->error = error; |
| 426 | __entry->from_pid = t->from_pid; |
| 427 | __entry->from_tid = t->from_tid; |
| 428 | __entry->to_pid = t->to_proc ? t->to_proc->pid : 0; |
| 429 | __entry->to_tid = t->to_thread ? t->to_thread->pid : 0; |
| 430 | __entry->is_reply = t->is_reply; |
| 431 | __entry->flags = t->flags; |
| 432 | __entry->code = t->code; |
| 433 | __entry->data_size = data_size; |
| 434 | ), |
| 435 | TP_printk("from %d:%d to %d:%d context=%s error=%d is_reply=%d flags=0x%x code=0x%x size=%zu" , |
| 436 | __entry->from_pid, __entry->from_tid, |
| 437 | __entry->to_pid, __entry->to_tid, |
| 438 | __entry->context, __entry->error, __entry->is_reply, |
| 439 | __entry->flags, __entry->code, __entry->data_size) |
| 440 | ); |
| 441 | |
| 442 | #endif /* _BINDER_TRACE_H */ |
| 443 | |
| 444 | #undef TRACE_INCLUDE_PATH |
| 445 | #undef TRACE_INCLUDE_FILE |
| 446 | #define TRACE_INCLUDE_PATH . |
| 447 | #define TRACE_INCLUDE_FILE binder_trace |
| 448 | #include <trace/define_trace.h> |
| 449 | |