|
|
|
@ -30,6 +30,7 @@ |
|
|
|
|
#include <linux/list_lru.h> |
|
|
|
|
#include <linux/uaccess.h> |
|
|
|
|
#include <linux/highmem.h> |
|
|
|
|
#include <linux/ratelimit.h> |
|
|
|
|
#include "binder_alloc.h" |
|
|
|
|
#include "binder_trace.h" |
|
|
|
|
|
|
|
|
@ -43,7 +44,7 @@ enum { |
|
|
|
|
BINDER_DEBUG_BUFFER_ALLOC = 1U << 2, |
|
|
|
|
BINDER_DEBUG_BUFFER_ALLOC_ASYNC = 1U << 3, |
|
|
|
|
}; |
|
|
|
|
static uint32_t binder_alloc_debug_mask; |
|
|
|
|
static uint32_t binder_alloc_debug_mask = BINDER_DEBUG_USER_ERROR; |
|
|
|
|
|
|
|
|
|
module_param_named(debug_mask, binder_alloc_debug_mask, |
|
|
|
|
uint, 0644); |
|
|
|
@ -51,7 +52,7 @@ module_param_named(debug_mask, binder_alloc_debug_mask, |
|
|
|
|
#define binder_alloc_debug(mask, x...) \ |
|
|
|
|
do { \
|
|
|
|
|
if (binder_alloc_debug_mask & mask) \
|
|
|
|
|
pr_info(x); \
|
|
|
|
|
pr_info_ratelimited(x); \
|
|
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
static struct binder_buffer *binder_buffer_next(struct binder_buffer *buffer) |
|
|
|
@ -224,8 +225,9 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!vma && need_mm) { |
|
|
|
|
pr_err("%d: binder_alloc_buf failed to map pages in userspace, no vma\n", |
|
|
|
|
alloc->pid); |
|
|
|
|
binder_alloc_debug(BINDER_DEBUG_USER_ERROR, |
|
|
|
|
"%d: binder_alloc_buf failed to map pages in userspace, no vma\n", |
|
|
|
|
alloc->pid); |
|
|
|
|
goto err_no_vma; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -405,8 +407,9 @@ static struct binder_buffer *binder_alloc_new_buf_locked( |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
if (!binder_alloc_get_vma(alloc)) { |
|
|
|
|
pr_err("%d: binder_alloc_buf, no vma\n", |
|
|
|
|
alloc->pid); |
|
|
|
|
binder_alloc_debug(BINDER_DEBUG_USER_ERROR, |
|
|
|
|
"%d: binder_alloc_buf, no vma\n", |
|
|
|
|
alloc->pid); |
|
|
|
|
return ERR_PTR(-ESRCH); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -478,11 +481,14 @@ static struct binder_buffer *binder_alloc_new_buf_locked( |
|
|
|
|
if (buffer_size > largest_free_size) |
|
|
|
|
largest_free_size = buffer_size; |
|
|
|
|
} |
|
|
|
|
pr_err("%d: binder_alloc_buf size %zd failed, no address space\n", |
|
|
|
|
alloc->pid, size); |
|
|
|
|
pr_err("allocated: %zd (num: %zd largest: %zd), free: %zd (num: %zd largest: %zd)\n", |
|
|
|
|
total_alloc_size, allocated_buffers, largest_alloc_size, |
|
|
|
|
total_free_size, free_buffers, largest_free_size); |
|
|
|
|
binder_alloc_debug(BINDER_DEBUG_USER_ERROR, |
|
|
|
|
"%d: binder_alloc_buf size %zd failed, no address space\n", |
|
|
|
|
alloc->pid, size); |
|
|
|
|
binder_alloc_debug(BINDER_DEBUG_USER_ERROR, |
|
|
|
|
"allocated: %zd (num: %zd largest: %zd), free: %zd (num: %zd largest: %zd)\n", |
|
|
|
|
total_alloc_size, allocated_buffers, |
|
|
|
|
largest_alloc_size, total_free_size, |
|
|
|
|
free_buffers, largest_free_size); |
|
|
|
|
return ERR_PTR(-ENOSPC); |
|
|
|
|
} |
|
|
|
|
if (n == NULL) { |
|
|
|
@ -800,8 +806,10 @@ err_alloc_pages_failed: |
|
|
|
|
alloc->buffer = NULL; |
|
|
|
|
err_already_mapped: |
|
|
|
|
mutex_unlock(&binder_alloc_mmap_lock); |
|
|
|
|
pr_err("%s: %d %lx-%lx %s failed %d\n", __func__, |
|
|
|
|
alloc->pid, vma->vm_start, vma->vm_end, failure_string, ret); |
|
|
|
|
binder_alloc_debug(BINDER_DEBUG_USER_ERROR, |
|
|
|
|
"%s: %d %lx-%lx %s failed %d\n", __func__, |
|
|
|
|
alloc->pid, vma->vm_start, vma->vm_end, |
|
|
|
|
failure_string, ret); |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|