From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 08/11] drm/i915: Track active vma requests
Date: Thu, 17 Dec 2015 12:26:28 +0000 [thread overview]
Message-ID: <5672A9F4.4000801@linux.intel.com> (raw)
In-Reply-To: <1450093012-14955-8-git-send-email-chris@chris-wilson.co.uk>
Hi,
On 14/12/15 11:36, Chris Wilson wrote:
> Hook the vma itself into the i915_gem_request_retire() so that we can
> accurately track when a solitary vma is inactive (as opposed to having
s/solitary/individual/ ?
> to wait for the entire object to be idle). This improves the interaction
> when using multiple contexts (with full-ppgtt) and eliminates some
> frequent list walking.
What list walking are you referring to? Maybe clarify in the commit message.
Anyway, looks surprisingly simple. Almost suspiciously simple, but I
can't fault it:
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
>
> A side-effect is that we get an active vma reference for free. The
> consequence of this is shown in the next patch...
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 2 +-
> drivers/gpu/drm/i915/i915_gem.c | 36 ++++++++++++++++--------------
> drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 ++
> drivers/gpu/drm/i915/i915_gem_gtt.c | 20 +++++++++++++++++
> drivers/gpu/drm/i915/i915_gem_gtt.h | 5 +++++
> 5 files changed, 47 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 179e3c5c5022..4df4ebbd56d6 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -356,7 +356,7 @@ static int per_file_stats(int id, void *ptr, void *data)
> continue;
> }
>
> - if (obj->active) /* XXX per-vma statistic */
> + if (vma->active)
> stats->active += vma->node.size;
> else
> stats->inactive += vma->node.size;
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 8a824c5d5348..1d21c5b79215 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2040,7 +2040,6 @@ i915_gem_object_retire__read(struct drm_i915_gem_request_active *active,
> int ring = request->engine->id;
> struct drm_i915_gem_object *obj =
> container_of(active, struct drm_i915_gem_object, last_read[ring]);
> - struct i915_vma *vma;
>
> RQ_BUG_ON((obj->flags & (1 << (ring + I915_BO_ACTIVE_SHIFT))) == 0);
>
> @@ -2052,12 +2051,9 @@ i915_gem_object_retire__read(struct drm_i915_gem_request_active *active,
> * so that we don't steal from recently used but inactive objects
> * (unless we are forced to ofc!)
> */
> - list_move_tail(&obj->global_list, &request->i915->mm.bound_list);
> -
> - list_for_each_entry(vma, &obj->vma_list, obj_link) {
> - if (!list_empty(&vma->vm_link))
> - list_move_tail(&vma->vm_link, &vma->vm->inactive_list);
> - }
> + if (!list_empty(&obj->vma_list))
> + list_move_tail(&obj->global_list,
> + &request->i915->mm.bound_list);
>
> drm_gem_object_unreference(&obj->base);
> }
> @@ -2567,7 +2563,19 @@ static int __i915_vma_unbind(struct i915_vma *vma, bool wait)
> {
> struct drm_i915_gem_object *obj = vma->obj;
> struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
> - int ret;
> + int ret, i;
> +
> + /* First wait upon any activity as retiring the request may
> + * have side-effects such as unpinning or even unbinding this vma.
> + */
> + if (vma->active && wait) {
> + for (i = 0; i < ARRAY_SIZE(vma->last_read); i++) {
> + ret = i915_wait_request(vma->last_read[i].request);
> + if (ret)
> + return ret;
> + }
> + RQ_BUG_ON(vma->active);
> + }
>
> if (list_empty(&vma->obj_link))
> return 0;
> @@ -2582,12 +2590,6 @@ static int __i915_vma_unbind(struct i915_vma *vma, bool wait)
>
> BUG_ON(obj->pages == NULL);
>
> - if (wait) {
> - ret = i915_gem_object_wait_rendering(obj, false);
> - if (ret)
> - return ret;
> - }
> -
> if (vma->is_ggtt && vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL) {
> i915_gem_object_finish_gtt(obj);
>
> @@ -3023,9 +3025,8 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)
>
> /* And bump the LRU for this access */
> vma = i915_gem_obj_to_ggtt(obj);
> - if (vma && drm_mm_node_allocated(&vma->node) && !obj->active)
> - list_move_tail(&vma->vm_link,
> - &to_i915(obj->base.dev)->gtt.base.inactive_list);
> + if (vma && drm_mm_node_allocated(&vma->node) && !vma->active)
> + list_move_tail(&vma->vm_link, &vma->vm->inactive_list);
>
> return 0;
> }
> @@ -3874,6 +3875,7 @@ struct i915_vma *i915_gem_obj_to_ggtt_view(struct drm_i915_gem_object *obj,
> void i915_gem_vma_destroy(struct i915_vma *vma)
> {
> WARN_ON(vma->node.allocated);
> + RQ_BUG_ON(vma->active);
>
> /* Keep the vma as a placeholder in the execbuffer reservation lists */
> if (!list_empty(&vma->exec_list))
> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> index 6de8681bb64c..1d4378a4501e 100644
> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -1099,6 +1099,8 @@ void i915_vma_move_to_active(struct i915_vma *vma,
> }
> }
>
> + vma->active |= 1 << engine;
> + i915_gem_request_mark_active(req, &vma->last_read[engine]);
> list_move_tail(&vma->vm_link, &vma->vm->active_list);
> }
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 130ccefb2491..5505603f52af 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -3225,12 +3225,30 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)
> i915_ggtt_flush(dev_priv);
> }
>
> +static void
> +i915_vma_retire(struct drm_i915_gem_request_active *active,
> + struct drm_i915_gem_request *rq)
> +{
> + const unsigned engine = rq->engine->id;
> + struct i915_vma *vma =
> + container_of(active, struct i915_vma, last_read[engine]);
> +
> + RQ_BUG_ON((vma->obj->active & (1 << engine)) == 0);
> +
> + vma->active &= ~(1 << engine);
> + if (vma->active)
> + return;
> +
> + list_move_tail(&vma->vm_link, &vma->vm->inactive_list);
> +}
> +
> static struct i915_vma *
> __i915_gem_vma_create(struct drm_i915_gem_object *obj,
> struct i915_address_space *vm,
> const struct i915_ggtt_view *ggtt_view)
> {
> struct i915_vma *vma;
> + int i;
>
> if (WARN_ON(i915_is_ggtt(vm) != !!ggtt_view))
> return ERR_PTR(-EINVAL);
> @@ -3242,6 +3260,8 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj,
> INIT_LIST_HEAD(&vma->vm_link);
> INIT_LIST_HEAD(&vma->obj_link);
> INIT_LIST_HEAD(&vma->exec_list);
> + for (i = 0; i < ARRAY_SIZE(vma->last_read); i++)
> + init_request_active(&vma->last_read[i], i915_vma_retire);
> vma->vm = vm;
> vma->obj = obj;
> vma->is_ggtt = i915_is_ggtt(vm);
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
> index 4e9553ace33f..c2f2c62ac88d 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.h
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
> @@ -34,6 +34,8 @@
> #ifndef __I915_GEM_GTT_H__
> #define __I915_GEM_GTT_H__
>
> +#include "i915_gem_request.h"
> +
> struct drm_i915_file_private;
>
> typedef uint32_t gen6_pte_t;
> @@ -180,10 +182,13 @@ struct i915_vma {
> struct drm_i915_gem_object *obj;
> struct i915_address_space *vm;
>
> + struct drm_i915_gem_request_active last_read[I915_NUM_RINGS];
> +
> /** Flags and address space this VMA is bound to */
> #define GLOBAL_BIND (1<<0)
> #define LOCAL_BIND (1<<1)
> unsigned int bound : 4;
> + unsigned int active : I915_NUM_RINGS;
> bool is_ggtt : 1;
>
> /**
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-12-17 12:26 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-14 11:36 [PATCH 01/11] drm/i915: Introduce drm_i915_gem_request_node for request tracking Chris Wilson
2015-12-14 11:36 ` [PATCH 02/11] drm/i915: Refactor activity tracking for requests Chris Wilson
2015-12-16 17:16 ` Tvrtko Ursulin
2015-12-16 17:31 ` Chris Wilson
2015-12-14 11:36 ` [PATCH 03/11] drm/i915: Rename vma->*_list to *_link for consistency Chris Wilson
2015-12-17 11:14 ` Tvrtko Ursulin
2015-12-17 11:24 ` Chris Wilson
2015-12-17 11:45 ` Chris Wilson
2015-12-14 11:36 ` [PATCH 04/11] drm/i915: Amalgamate GGTT/ppGTT vma debug list walkers Chris Wilson
2015-12-17 11:21 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 05/11] drm/i915: Reduce the pointer dance of i915_is_ggtt() Chris Wilson
2015-12-17 11:31 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 06/11] drm/i915: Store owning file on the i915_address_space Chris Wilson
2015-12-17 11:52 ` Tvrtko Ursulin
2015-12-17 13:25 ` Chris Wilson
2015-12-14 11:36 ` [PATCH 07/11] drm/i915: i915_vma_move_to_active prep patch Chris Wilson
2015-12-17 12:04 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 08/11] drm/i915: Track active vma requests Chris Wilson
2015-12-17 12:26 ` Tvrtko Ursulin [this message]
2015-12-14 11:36 ` [PATCH 09/11] drm/i915: Release vma when the handle is closed Chris Wilson
2015-12-17 13:46 ` Tvrtko Ursulin
2015-12-17 14:11 ` Chris Wilson
2015-12-17 14:21 ` Chris Wilson
2015-12-17 14:32 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 10/11] drm/i915: Mark the context and address space as closed Chris Wilson
2015-12-17 12:37 ` Tvrtko Ursulin
2015-12-17 12:39 ` Tvrtko Ursulin
2015-12-17 12:48 ` Chris Wilson
2015-12-17 13:26 ` Tvrtko Ursulin
2015-12-17 14:15 ` Tvrtko Ursulin
2015-12-17 14:26 ` Chris Wilson
2015-12-17 14:35 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 11/11] Revert "drm/i915: Clean up associated VMAs on context destruction" Chris Wilson
2015-12-14 15:58 ` [PATCH 01/11] drm/i915: Introduce drm_i915_gem_request_node for request tracking Tvrtko Ursulin
2015-12-14 16:11 ` Chris Wilson
2015-12-15 10:51 ` [PATCH v2] drm/i915: Introduce drm_i915_gem_request_active " Chris Wilson
2015-12-17 14:48 ` ✗ failure: UK.CI.checkpatch.pl Patchwork
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=5672A9F4.4000801@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.