diff options
author | Martijn Coenen <maco@android.com> | 2017-06-29 15:01:52 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-07-17 08:47:29 -0400 |
commit | b05a68e94b97eae2ae671ed703416f8dd21e4257 (patch) | |
tree | dc42ccce785423efbc6f2c1d2e33b30be4b5fa95 /drivers/android/binder_alloc.c | |
parent | 53d311cfa19ad35beba74d706effee02c86d198f (diff) |
binder: add more debug info when allocation fails.
Display information about allocated/free space whenever
binder buffer allocation fails on synchronous
transactions.
Signed-off-by: Martijn Coenen <maco@android.com>
Signed-off-by: Siqi Lin <siqilin@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android/binder_alloc.c')
-rw-r--r-- | drivers/android/binder_alloc.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index 2a2e41b13de5..40f31df60580 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c | |||
@@ -337,8 +337,36 @@ struct binder_buffer *binder_alloc_new_buf_locked(struct binder_alloc *alloc, | |||
337 | } | 337 | } |
338 | } | 338 | } |
339 | if (best_fit == NULL) { | 339 | if (best_fit == NULL) { |
340 | size_t allocated_buffers = 0; | ||
341 | size_t largest_alloc_size = 0; | ||
342 | size_t total_alloc_size = 0; | ||
343 | size_t free_buffers = 0; | ||
344 | size_t largest_free_size = 0; | ||
345 | size_t total_free_size = 0; | ||
346 | |||
347 | for (n = rb_first(&alloc->allocated_buffers); n != NULL; | ||
348 | n = rb_next(n)) { | ||
349 | buffer = rb_entry(n, struct binder_buffer, rb_node); | ||
350 | buffer_size = binder_alloc_buffer_size(alloc, buffer); | ||
351 | allocated_buffers++; | ||
352 | total_alloc_size += buffer_size; | ||
353 | if (buffer_size > largest_alloc_size) | ||
354 | largest_alloc_size = buffer_size; | ||
355 | } | ||
356 | for (n = rb_first(&alloc->free_buffers); n != NULL; | ||
357 | n = rb_next(n)) { | ||
358 | buffer = rb_entry(n, struct binder_buffer, rb_node); | ||
359 | buffer_size = binder_alloc_buffer_size(alloc, buffer); | ||
360 | free_buffers++; | ||
361 | total_free_size += buffer_size; | ||
362 | if (buffer_size > largest_free_size) | ||
363 | largest_free_size = buffer_size; | ||
364 | } | ||
340 | pr_err("%d: binder_alloc_buf size %zd failed, no address space\n", | 365 | pr_err("%d: binder_alloc_buf size %zd failed, no address space\n", |
341 | alloc->pid, size); | 366 | alloc->pid, size); |
367 | pr_err("allocated: %zd (num: %zd largest: %zd), free: %zd (num: %zd largest: %zd)\n", | ||
368 | total_alloc_size, allocated_buffers, largest_alloc_size, | ||
369 | total_free_size, free_buffers, largest_free_size); | ||
342 | return ERR_PTR(-ENOSPC); | 370 | return ERR_PTR(-ENOSPC); |
343 | } | 371 | } |
344 | if (n == NULL) { | 372 | if (n == NULL) { |
@@ -698,9 +726,10 @@ void binder_alloc_deferred_release(struct binder_alloc *alloc) | |||
698 | static void print_binder_buffer(struct seq_file *m, const char *prefix, | 726 | static void print_binder_buffer(struct seq_file *m, const char *prefix, |
699 | struct binder_buffer *buffer) | 727 | struct binder_buffer *buffer) |
700 | { | 728 | { |
701 | seq_printf(m, "%s %d: %pK size %zd:%zd %s\n", | 729 | seq_printf(m, "%s %d: %pK size %zd:%zd:%zd %s\n", |
702 | prefix, buffer->debug_id, buffer->data, | 730 | prefix, buffer->debug_id, buffer->data, |
703 | buffer->data_size, buffer->offsets_size, | 731 | buffer->data_size, buffer->offsets_size, |
732 | buffer->extra_buffers_size, | ||
704 | buffer->transaction ? "active" : "delivered"); | 733 | buffer->transaction ? "active" : "delivered"); |
705 | } | 734 | } |
706 | 735 | ||