提交 e41e164c 编写于 作者: S Sherry Yang 提交者: Greg Kroah-Hartman

android: binder: Add shrinker tracepoints

Add tracepoints in binder transaction allocator to
record lru hits and alloc/free page.
Signed-off-by: NSherry Yang <sherryy@android.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 f2517eb7
...@@ -237,18 +237,25 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate, ...@@ -237,18 +237,25 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) { for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) {
int ret; int ret;
bool on_lru; bool on_lru;
size_t index;
page = &alloc->pages[(page_addr - alloc->buffer) / PAGE_SIZE]; index = (page_addr - alloc->buffer) / PAGE_SIZE;
page = &alloc->pages[index];
if (page->page_ptr) { if (page->page_ptr) {
trace_binder_alloc_lru_start(alloc, index);
on_lru = list_lru_del(&binder_alloc_lru, &page->lru); on_lru = list_lru_del(&binder_alloc_lru, &page->lru);
WARN_ON(!on_lru); WARN_ON(!on_lru);
trace_binder_alloc_lru_end(alloc, index);
continue; continue;
} }
if (WARN_ON(!vma)) if (WARN_ON(!vma))
goto err_page_ptr_cleared; goto err_page_ptr_cleared;
trace_binder_alloc_page_start(alloc, index);
page->page_ptr = alloc_page(GFP_KERNEL | page->page_ptr = alloc_page(GFP_KERNEL |
__GFP_HIGHMEM | __GFP_HIGHMEM |
__GFP_ZERO); __GFP_ZERO);
...@@ -278,6 +285,8 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate, ...@@ -278,6 +285,8 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
alloc->pid, user_page_addr); alloc->pid, user_page_addr);
goto err_vm_insert_page_failed; goto err_vm_insert_page_failed;
} }
trace_binder_alloc_page_end(alloc, index);
/* vm_insert_page does not seem to increment the refcount */ /* vm_insert_page does not seem to increment the refcount */
} }
if (mm) { if (mm) {
...@@ -290,11 +299,17 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate, ...@@ -290,11 +299,17 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
for (page_addr = end - PAGE_SIZE; page_addr >= start; for (page_addr = end - PAGE_SIZE; page_addr >= start;
page_addr -= PAGE_SIZE) { page_addr -= PAGE_SIZE) {
bool ret; bool ret;
size_t index;
page = &alloc->pages[(page_addr - alloc->buffer) / PAGE_SIZE]; index = (page_addr - alloc->buffer) / PAGE_SIZE;
page = &alloc->pages[index];
trace_binder_free_lru_start(alloc, index);
ret = list_lru_add(&binder_alloc_lru, &page->lru); ret = list_lru_add(&binder_alloc_lru, &page->lru);
WARN_ON(!ret); WARN_ON(!ret);
trace_binder_free_lru_end(alloc, index);
continue; continue;
err_vm_insert_page_failed: err_vm_insert_page_failed:
...@@ -888,18 +903,26 @@ enum lru_status binder_alloc_free_page(struct list_head *item, ...@@ -888,18 +903,26 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
if (!down_write_trylock(&mm->mmap_sem)) if (!down_write_trylock(&mm->mmap_sem))
goto err_down_write_mmap_sem_failed; goto err_down_write_mmap_sem_failed;
trace_binder_unmap_user_start(alloc, index);
zap_page_range(alloc->vma, zap_page_range(alloc->vma,
page_addr + alloc->user_buffer_offset, page_addr + alloc->user_buffer_offset,
PAGE_SIZE); PAGE_SIZE);
trace_binder_unmap_user_end(alloc, index);
up_write(&mm->mmap_sem); up_write(&mm->mmap_sem);
mmput(mm); mmput(mm);
} }
trace_binder_unmap_kernel_start(alloc, index);
unmap_kernel_range(page_addr, PAGE_SIZE); unmap_kernel_range(page_addr, PAGE_SIZE);
__free_page(page->page_ptr); __free_page(page->page_ptr);
page->page_ptr = NULL; page->page_ptr = NULL;
trace_binder_unmap_kernel_end(alloc, index);
list_lru_isolate(lru, item); list_lru_isolate(lru, item);
mutex_unlock(&alloc->mutex); mutex_unlock(&alloc->mutex);
......
...@@ -291,6 +291,61 @@ TRACE_EVENT(binder_update_page_range, ...@@ -291,6 +291,61 @@ TRACE_EVENT(binder_update_page_range,
__entry->offset, __entry->size) __entry->offset, __entry->size)
); );
DECLARE_EVENT_CLASS(binder_lru_page_class,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index),
TP_STRUCT__entry(
__field(int, proc)
__field(size_t, page_index)
),
TP_fast_assign(
__entry->proc = alloc->pid;
__entry->page_index = page_index;
),
TP_printk("proc=%d page_index=%zu",
__entry->proc, __entry->page_index)
);
DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_start,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_end,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_start,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_end,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_start,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_end,
TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
TP_ARGS(alloc, page_index));
TRACE_EVENT(binder_command, TRACE_EVENT(binder_command,
TP_PROTO(uint32_t cmd), TP_PROTO(uint32_t cmd),
TP_ARGS(cmd), TP_ARGS(cmd),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册