Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1724498

[PATCH] android: binder: Add page usage in binder stats

From Sherry Yang <sherryy@android.com>
Newsgroups linux.kernel
Subject [PATCH] android: binder: Add page usage in binder stats
Date 2017-08-31 21:00 +0200
Message-ID <ukCR4-Ul-15@gated-at.bofh.it> (permalink)
References <ukCHo-Qu-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add the number of active, lru, and free pages for
each binder process in binder stats

Signed-off-by: Sherry Yang <sherryy@android.com>
---
 drivers/android/binder.c       |  2 ++
 drivers/android/binder_alloc.c | 28 ++++++++++++++++++++++++++++
 drivers/android/binder_alloc.h |  2 ++
 3 files changed, 32 insertions(+)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index ba9e613b42d6..56b380292cc5 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -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) {
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 2624a502fcde..8fe165844e47 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -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
diff --git a/drivers/android/binder_alloc.h b/drivers/android/binder_alloc.h
index fa707cc63393..a3a3602c689c 100644
--- a/drivers/android/binder_alloc.h
+++ b/drivers/android/binder_alloc.h
@@ -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
-- 
2.14.1.581.gf28d330327-goog

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] android: binder: move allocator metadata and add shrinker Sherry Yang <sherryy@android.com> - 2017-08-30 02:50 +0200
  [PATCH v3 2/6] android: binder: Add allocator selftest Sherry Yang <sherryy@android.com> - 2017-08-30 02:50 +0200
  [PATCH v3 1/6] android: binder: Refactor prev and next buffer into a helper function Sherry Yang <sherryy@android.com> - 2017-08-30 02:50 +0200
    Re: [PATCH v3 1/6] android: binder: Refactor prev and next buffer  into a helper function Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-30 08:20 +0200
      Re: [PATCH v3 1/6] android: binder: Refactor prev and next buffer  into a helper function Sherry Yang <sherryy@android.com> - 2017-08-30 21:50 +0200
        Re: [PATCH v3 1/6] android: binder: Refactor prev and next buffer  into a helper function Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-30 22:10 +0200
        Re: [PATCH v3 1/6] android: binder: Refactor prev and next buffer  into a helper function Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-31 06:30 +0200
          [PATCH] android: binder: fixup crash introduced by moving buffer hdr Sherry Yang <sherryy@android.com> - 2017-08-31 19:30 +0200
            Re: [PATCH] android: binder: fixup crash introduced by moving buffer  hdr Greg KH <gregkh@linuxfoundation.org> - 2017-09-01 09:00 +0200
          Re: [PATCH v3 1/6] android: binder: Refactor prev and next buffer  into a helper function Sherry Yang <sherryy@android.com> - 2017-08-31 19:40 +0200
            Re: [PATCH v3 1/6] android: binder: Refactor prev and next buffer  into a helper function Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-31 20:50 +0200
              [PATCH] android: binder: Add page usage in binder stats Sherry Yang <sherryy@android.com> - 2017-08-31 21:00 +0200
  [PATCH v3 6/6] android: binder: Add page usage in binder stats Sherry Yang <sherryy@android.com> - 2017-08-30 02:50 +0200
  [PATCH v3 3/6] android: binder: Move buffer out of area shared with user space Sherry Yang <sherryy@android.com> - 2017-08-30 02:50 +0200
    Re: [PATCH v3 3/6] android: binder: Move buffer out of area shared  with user space Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-30 11:40 +0200
      Re: [PATCH v3 3/6] android: binder: Move buffer out of area shared  with user space Arve Hjønnevåg <arve@android.com> - 2017-08-30 22:10 +0200
        Re: [PATCH v3 3/6] android: binder: Move buffer out of area shared  with user space Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-30 22:30 +0200
          Re: [PATCH v3 3/6] android: binder: Move buffer out of area shared  with user space Todd Kjos <tkjos@google.com> - 2017-08-30 23:10 +0200
  [PATCH v3 4/6] android: binder: Add global lru shrinker to binder Sherry Yang <sherryy@android.com> - 2017-08-30 02:50 +0200
  [PATCH v3 5/6] android: binder: Add shrinker tracepoints Sherry Yang <sherryy@android.com> - 2017-08-30 02:50 +0200

csiph-web