public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v5] drm/i915: Report correct GGTT space usage
Date: Wed, 1 Jul 2015 15:37:35 +0200	[thread overview]
Message-ID: <20150701133735.GL23343@phenom.ffwll.local> (raw)
In-Reply-To: <1435747870-14606-1-git-send-email-tvrtko.ursulin@linux.intel.com>

On Wed, Jul 01, 2015 at 11:51:10AM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Currently only normal views were accounted which under-accounts
> the usage as reported in debugfs.
> 
> Introduce new helper, i915_gem_obj_total_ggtt_size, and use it
> from call sites which want to know how much GGTT space are
> objects using.
> 
> v2: Single loop in i915_gem_get_aperture_ioctl. (Chris Wilson)
> 
> v3: Walk GGTT active/inactive lists in i915_gem_get_aperture_ioctl
>     for better efficiency. (Chris Wilson, Daniel Vetter)
> 
> v4: Make i915_gem_obj_total_ggtt_size private to debugfs. (Chris Wilson)
> 
> v5: Change unsigned long to u64. (Chris Wilson)
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Queued for -next, thanks for the patch.
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c | 22 ++++++++++++++++++----
>  drivers/gpu/drm/i915/i915_gem.c     | 13 ++++++++-----
>  2 files changed, 26 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 31d87685f3b9..04de6e73a57b 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -117,6 +117,20 @@ static inline const char *get_global_flag(struct drm_i915_gem_object *obj)
>  	return i915_gem_obj_to_ggtt(obj) ? "g" : " ";
>  }
>  
> +static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)

somehow I hoped we wouldn't need this, but I guess too much trouble to
rework them all ...
-Daniel

> +{
> +	u64 size = 0;
> +	struct i915_vma *vma;
> +
> +	list_for_each_entry(vma, &obj->vma_list, vma_link) {
> +		if (i915_is_ggtt(vma->vm) &&
> +		    drm_mm_node_allocated(&vma->node))
> +			size += vma->node.size;
> +	}
> +
> +	return size;
> +}
> +
>  static void
>  describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
>  {
> @@ -269,7 +283,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
>  		list_add(&obj->obj_exec_link, &stolen);
>  
>  		total_obj_size += obj->base.size;
> -		total_gtt_size += i915_gem_obj_ggtt_size(obj);
> +		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
>  		count++;
>  	}
>  	list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
> @@ -299,7 +313,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
>  
>  #define count_objects(list, member) do { \
>  	list_for_each_entry(obj, list, member) { \
> -		size += i915_gem_obj_ggtt_size(obj); \
> +		size += i915_gem_obj_total_ggtt_size(obj); \
>  		++count; \
>  		if (obj->map_and_fenceable) { \
>  			mappable_size += i915_gem_obj_ggtt_size(obj); \
> @@ -405,7 +419,7 @@ static void print_batch_pool_stats(struct seq_file *m,
>  
>  #define count_vmas(list, member) do { \
>  	list_for_each_entry(vma, list, member) { \
> -		size += i915_gem_obj_ggtt_size(vma->obj); \
> +		size += i915_gem_obj_total_ggtt_size(vma->obj); \
>  		++count; \
>  		if (vma->obj->map_and_fenceable) { \
>  			mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
> @@ -535,7 +549,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void *data)
>  		describe_obj(m, obj);
>  		seq_putc(m, '\n');
>  		total_obj_size += obj->base.size;
> -		total_gtt_size += i915_gem_obj_ggtt_size(obj);
> +		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
>  		count++;
>  	}
>  
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index a2a4a271555c..49016e01da6c 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -149,14 +149,18 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct drm_i915_gem_get_aperture *args = data;
> -	struct drm_i915_gem_object *obj;
> +	struct i915_gtt *ggtt = &dev_priv->gtt;
> +	struct i915_vma *vma;
>  	size_t pinned;
>  
>  	pinned = 0;
>  	mutex_lock(&dev->struct_mutex);
> -	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
> -		if (i915_gem_obj_is_pinned(obj))
> -			pinned += i915_gem_obj_ggtt_size(obj);
> +	list_for_each_entry(vma, &ggtt->base.active_list, mm_list)
> +		if (vma->pin_count)
> +			pinned += vma->node.size;
> +	list_for_each_entry(vma, &ggtt->base.inactive_list, mm_list)
> +		if (vma->pin_count)
> +			pinned += vma->node.size;
>  	mutex_unlock(&dev->struct_mutex);
>  
>  	args->aper_size = dev_priv->gtt.base.total;
> @@ -5468,4 +5472,3 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
>  
>  	return false;
>  }
> -
> -- 
> 2.4.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-07-01 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01 10:51 [PATCH v5] drm/i915: Report correct GGTT space usage Tvrtko Ursulin
2015-07-01 13:37 ` Daniel Vetter [this message]
2015-07-03  7:40 ` shuang.he

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=20150701133735.GL23343@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=tvrtko.ursulin@linux.intel.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