mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Feng Tang <feng.tang@intel.com>
To: Greg KH <gregkh@linuxfoundation.org>,
	John Stultz <john.stultz@linaro.org>
Cc: Colin Cross <ccross@android.com>,
	Heesub Shin <heesub.shin@samsung.com>,
	Mitchel Humpherys <mitchelh@codeaurora.org>,
	linux-kernel@vger.kernel.org, Feng Tang <feng.tang@intel.com>
Subject: [PATCH 2/2] staging: android: ion: Add pss info for each ion_client
Date: Sun,  4 Jan 2015 15:11:52 +0800	[thread overview]
Message-ID: <1420355512-31129-2-git-send-email-feng.tang@intel.com> (raw)
In-Reply-To: <1420355512-31129-1-git-send-email-feng.tang@intel.com>

In real ION buffer usage, many of the ion buffer are shared
by several clients(imported and exported), and current ion
debugfs only provides size of all buffers a client may use.
This patch will considers the sharing and adds a "pss" info
for each ion_client, which will help on profiling the ion
memory usage.

Actually we can do more aggressively in android world, in
which the "surfaceflinger" is a main proxy to help other
apps to do the ion buffer allocation, and we can consider
this and extract "surfaceflinger" related size out. And
this could be the next step.

Signed-off-by: Feng Tang <feng.tang@intel.com>
---
 drivers/staging/android/ion/ion.c |   25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 3d378ef..0b8fd56 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1386,18 +1386,25 @@ static const struct file_operations ion_fops = {
 };
 
 static size_t ion_debug_heap_total(struct ion_client *client,
-				   unsigned int id)
+				   unsigned int id, size_t *psize)
 {
 	size_t size = 0;
 	struct rb_node *n;
 
+	*psize = 0;
+
 	mutex_lock(&client->lock);
 	for (n = rb_first(&client->handles); n; n = rb_next(n)) {
 		struct ion_handle *handle = rb_entry(n,
 						     struct ion_handle,
 						     node);
-		if (handle->buffer->heap->id == id)
+		if (handle->buffer->heap->id == id) {
 			size += handle->buffer->size;
+			if (handle->buffer->handle_count)
+				*psize += handle->buffer->size /
+					handle->buffer->handle_count;
+		}
+
 	}
 	mutex_unlock(&client->lock);
 	return size;
@@ -1411,13 +1418,15 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused)
 	size_t total_size = 0;
 	size_t total_orphaned_size = 0;
 
-	seq_printf(s, "%16.s %16.s %16.s\n", "client", "pid", "size");
+	seq_printf(s, "%16.s %16.s %16.s %16.s\n",
+			"client", "pid", "size", "psize");
 	seq_puts(s, "----------------------------------------------------\n");
 
 	for (n = rb_first(&dev->clients); n; n = rb_next(n)) {
 		struct ion_client *client = rb_entry(n, struct ion_client,
 						     node);
-		size_t size = ion_debug_heap_total(client, heap->id);
+		size_t psize;
+		size_t size = ion_debug_heap_total(client, heap->id, &psize);
 
 		if (!size)
 			continue;
@@ -1425,11 +1434,11 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused)
 			char task_comm[TASK_COMM_LEN];
 
 			get_task_comm(task_comm, client->task);
-			seq_printf(s, "%16.s %16u %16zu\n", task_comm,
-				   client->pid, size);
+			seq_printf(s, "%16.s %16u %16zu %16zu\n", task_comm,
+				   client->pid, size, psize);
 		} else {
-			seq_printf(s, "%16.s %16u %16zu\n", client->name,
-				   client->pid, size);
+			seq_printf(s, "%16.s %16u %16zu %16zu\n", client->name,
+				   client->pid, size, psize);
 		}
 	}
 	seq_puts(s, "----------------------------------------------------\n");
-- 
1.7.9.5


  reply	other threads:[~2015-01-04  7:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-04  7:11 [PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function Feng Tang
2015-01-04  7:11 ` Feng Tang [this message]
2015-01-05 14:24 ` One Thousand Gnomes
2015-01-05 15:51   ` Tang, Feng
2015-01-18  0:04     ` Greg KH
2015-01-19  1:14       ` Tang, Feng
2015-01-19  1:58         ` Greg KH
2015-01-19  2:00 [PATCH 2/2] staging: android: ion: Add pss info for each ion_client Feng Tang
2015-01-19  2:23 ` Greg KH

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=1420355512-31129-2-git-send-email-feng.tang@intel.com \
    --to=feng.tang@intel.com \
    --cc=ccross@android.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heesub.shin@samsung.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mitchelh@codeaurora.org \
    /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

all inboxes | Powered by JetHome®