diff mbox

[2/2] drm/i915: Print how many objects are shared in per-process stats

Message ID 1395236746-15093-2-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson March 19, 2014, 1:45 p.m. UTC
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Ben Widawsky March 20, 2014, 4:42 a.m. UTC | #1
On Wed, Mar 19, 2014 at 01:45:46PM +0000, Chris Wilson wrote:
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Any clue how you intend to use this for a commit message (I'm actually
curious)? Also, the subject is wrong, you're counting size, not
quantity. Anyhoo, looks correct.

Reviewed-by: Ben Widawsky <ben@bwidawsk.net>

> ---
>  drivers/gpu/drm/i915/i915_debugfs.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 4e1787ee8f37..9cc1c9360238 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -301,7 +301,9 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
>  struct file_stats {
>  	struct drm_i915_file_private *file_priv;
>  	int count;
> -	size_t total, global, active, inactive, unbound;
> +	size_t total, unbound;
> +	size_t global, shared;
> +	size_t active, inactive;
>  };
>  
>  static int per_file_stats(int id, void *ptr, void *data)
> @@ -313,6 +315,9 @@ static int per_file_stats(int id, void *ptr, void *data)
>  	stats->count++;
>  	stats->total += obj->base.size;
>  
> +	if (obj->base.name || obj->base.dma_buf)
> +		stats->shared += obj->base.size;
> +
>  	if (USES_FULL_PPGTT(obj->base.dev)) {
>  		list_for_each_entry(vma, &obj->vma_list, vma_link) {
>  			struct i915_hw_ppgtt *ppgtt;
> @@ -450,13 +455,14 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
>  		 */
>  		rcu_read_lock();
>  		task = pid_task(file->pid, PIDTYPE_PID);
> -		seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu unbound)\n",
> +		seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n",
>  			   task ? task->comm : "<unknown>",
>  			   stats.count,
>  			   stats.total,
>  			   stats.active,
>  			   stats.inactive,
>  			   stats.global,
> +			   stats.shared,
>  			   stats.unbound);
>  		rcu_read_unlock();
>  	}
> -- 
> 1.9.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson March 20, 2014, 7:40 a.m. UTC | #2
On Wed, Mar 19, 2014 at 09:42:49PM -0700, Ben Widawsky wrote:
> On Wed, Mar 19, 2014 at 01:45:46PM +0000, Chris Wilson wrote:
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Any clue how you intend to use this for a commit message (I'm actually
> curious)? Also, the subject is wrong, you're counting size, not
> quantity. Anyhoo, looks correct.

Knowing how much of the allocated objects are shared between processes
helps gauge whether a process is leaking private objects, or if it
simply a display server suffering memory pressure from lots of clients.

> Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Daniel Vetter March 20, 2014, 2:11 p.m. UTC | #3
On Thu, Mar 20, 2014 at 07:40:37AM +0000, Chris Wilson wrote:
> On Wed, Mar 19, 2014 at 09:42:49PM -0700, Ben Widawsky wrote:
> > On Wed, Mar 19, 2014 at 01:45:46PM +0000, Chris Wilson wrote:
> > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > 
> > Any clue how you intend to use this for a commit message (I'm actually
> > curious)? Also, the subject is wrong, you're counting size, not
> > quantity. Anyhoo, looks correct.
> 
> Knowing how much of the allocated objects are shared between processes
> helps gauge whether a process is leaking private objects, or if it
> simply a display server suffering memory pressure from lots of clients.

I've added something along these lines here.
> 
> > Reviewed-by: Ben Widawsky <ben@bwidawsk.net>

Both patches merged, thanks.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 4e1787ee8f37..9cc1c9360238 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -301,7 +301,9 @@  static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
 struct file_stats {
 	struct drm_i915_file_private *file_priv;
 	int count;
-	size_t total, global, active, inactive, unbound;
+	size_t total, unbound;
+	size_t global, shared;
+	size_t active, inactive;
 };
 
 static int per_file_stats(int id, void *ptr, void *data)
@@ -313,6 +315,9 @@  static int per_file_stats(int id, void *ptr, void *data)
 	stats->count++;
 	stats->total += obj->base.size;
 
+	if (obj->base.name || obj->base.dma_buf)
+		stats->shared += obj->base.size;
+
 	if (USES_FULL_PPGTT(obj->base.dev)) {
 		list_for_each_entry(vma, &obj->vma_list, vma_link) {
 			struct i915_hw_ppgtt *ppgtt;
@@ -450,13 +455,14 @@  static int i915_gem_object_info(struct seq_file *m, void* data)
 		 */
 		rcu_read_lock();
 		task = pid_task(file->pid, PIDTYPE_PID);
-		seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu unbound)\n",
+		seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n",
 			   task ? task->comm : "<unknown>",
 			   stats.count,
 			   stats.total,
 			   stats.active,
 			   stats.inactive,
 			   stats.global,
+			   stats.shared,
 			   stats.unbound);
 		rcu_read_unlock();
 	}