linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sherry Yang <sherryy@android.com>
To: linux-kernel@vger.kernel.org
Cc: tkjos@google.com, maco@google.com,
	"Sherry Yang" <sherryy@android.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Riley Andrews" <riandrews@android.com>,
	devel@driverdev.osuosl.org (open list:ANDROID DRIVERS)
Subject: [PATCH v3 6/6] android: binder: Add page usage in binder stats
Date: Tue, 29 Aug 2017 17:47:02 -0700	[thread overview]
Message-ID: <20170830004702.120371-7-sherryy@android.com> (raw)
In-Reply-To: <20170830004702.120371-1-sherryy@android.com>

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 fc5a4b9f3d97..7210e0dba3ef 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.342.g6490525c54-goog

      parent reply	other threads:[~2017-08-30  0:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30  0:46 [PATCH 0/6] android: binder: move allocator metadata and add shrinker Sherry Yang
2017-08-30  0:46 ` [PATCH v3 1/6] android: binder: Refactor prev and next buffer into a helper function Sherry Yang
2017-08-30  6:07   ` Greg Kroah-Hartman
2017-08-30 19:46     ` Sherry Yang
2017-08-30 20:08       ` Dan Carpenter
2017-08-31  4:28       ` Greg Kroah-Hartman
2017-08-31 17:26         ` [PATCH] android: binder: fixup crash introduced by moving buffer hdr Sherry Yang
2017-09-01  6:52           ` Greg KH
2017-08-31 17:30         ` [PATCH v3 1/6] android: binder: Refactor prev and next buffer into a helper function Sherry Yang
2017-08-31 18:47           ` Greg Kroah-Hartman
2017-08-31 18:56             ` [PATCH] android: binder: Add page usage in binder stats Sherry Yang
2017-08-30  0:46 ` [PATCH v3 2/6] android: binder: Add allocator selftest Sherry Yang
2017-08-30  0:46 ` [PATCH v3 3/6] android: binder: Move buffer out of area shared with user space Sherry Yang
2017-08-30  9:29   ` Dan Carpenter
2017-08-30 20:04     ` Arve Hjønnevåg
2017-08-30 20:20       ` Dan Carpenter
2017-08-30 21:03         ` Todd Kjos
2017-08-30  0:47 ` [PATCH v3 4/6] android: binder: Add global lru shrinker to binder Sherry Yang
2017-08-30  0:47 ` [PATCH v3 5/6] android: binder: Add shrinker tracepoints Sherry Yang
2017-08-30  0:47 ` Sherry Yang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170830004702.120371-7-sherryy@android.com \
    --to=sherryy@android.com \
    --cc=arve@android.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maco@google.com \
    --cc=riandrews@android.com \
    --cc=tkjos@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).