Skip to content

Commit

Permalink
android: binder: Add page usage in binder stats
Browse files Browse the repository at this point in the history
Add the number of active, lru, and free pages for
each binder process in binder stats

Signed-off-by: Sherry Yang <sherryy@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Sherry Yang authored and Greg Kroah-Hartman committed Sep 1, 2017
1 parent 957ccc2 commit 8ef4665
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -5047,6 +5047,8 @@ static void print_binder_proc_stats(struct seq_file *m,
count = binder_alloc_get_allocated_count(&proc->alloc);
seq_printf(m, " buffers: %d\n", count);

binder_alloc_print_pages(m, &proc->alloc);

count = 0;
binder_inner_proc_lock(proc);
list_for_each_entry(w, &proc->todo, entry) {
Expand Down
28 changes: 28 additions & 0 deletions drivers/android/binder_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,34 @@ void binder_alloc_print_allocated(struct seq_file *m,
mutex_unlock(&alloc->mutex);
}

/**
* binder_alloc_print_pages() - print page usage
* @m: seq_file for output via seq_printf()
* @alloc: binder_alloc for this proc
*/
void binder_alloc_print_pages(struct seq_file *m,
struct binder_alloc *alloc)
{
struct binder_lru_page *page;
int i;
int active = 0;
int lru = 0;
int free = 0;

mutex_lock(&alloc->mutex);
for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
page = &alloc->pages[i];
if (!page->page_ptr)
free++;
else if (list_empty(&page->lru))
active++;
else
lru++;
}
mutex_unlock(&alloc->mutex);
seq_printf(m, " pages: %d:%d:%d\n", active, lru, free);
}

/**
* binder_alloc_get_allocated_count() - return count of buffers
* @alloc: binder_alloc for this proc
Expand Down
2 changes: 2 additions & 0 deletions drivers/android/binder_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ extern void binder_alloc_deferred_release(struct binder_alloc *alloc);
extern int binder_alloc_get_allocated_count(struct binder_alloc *alloc);
extern void binder_alloc_print_allocated(struct seq_file *m,
struct binder_alloc *alloc);
void binder_alloc_print_pages(struct seq_file *m,
struct binder_alloc *alloc);

/**
* binder_alloc_get_free_async_space() - get free space available for async
Expand Down

0 comments on commit 8ef4665

Please sign in to comment.