Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 25/34] drm/i915: Track active timelines
Date: Tue, 22 Jan 2019 14:56:32 +0000	[thread overview]
Message-ID: <03e15be3-1cfc-5d50-cabe-de9be5300992@linux.intel.com> (raw)
In-Reply-To: <20190121222117.23305-26-chris@chris-wilson.co.uk>


On 21/01/2019 22:21, Chris Wilson wrote:
> Now that we pin timelines around use, we have a clearly defined lifetime
> and convenient points at which we can track only the active timelines.
> This allows us to reduce the list iteration to only consider those
> active timelines and not all.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/i915_drv.h      |  2 +-
>   drivers/gpu/drm/i915/i915_gem.c      |  4 +--
>   drivers/gpu/drm/i915/i915_reset.c    |  2 +-
>   drivers/gpu/drm/i915/i915_timeline.c | 39 ++++++++++++++++++----------
>   4 files changed, 29 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index c00eaf2889fb..5577e0e1034f 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1977,7 +1977,7 @@ struct drm_i915_private {
>   
>   		struct i915_gt_timelines {
>   			struct mutex mutex; /* protects list, tainted by GPU */
> -			struct list_head list;
> +			struct list_head active_list;
>   
>   			/* Pack multiple timelines' seqnos into the same page */
>   			spinlock_t hwsp_lock;
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 4e0de22f0166..9c499edb4c13 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -3246,7 +3246,7 @@ wait_for_timelines(struct drm_i915_private *i915,
>   		return timeout;
>   
>   	mutex_lock(&gt->mutex);
> -	list_for_each_entry(tl, &gt->list, link) {
> +	list_for_each_entry(tl, &gt->active_list, link) {
>   		struct i915_request *rq;
>   
>   		rq = i915_gem_active_get_unlocked(&tl->last_request);
> @@ -3274,7 +3274,7 @@ wait_for_timelines(struct drm_i915_private *i915,
>   
>   		/* restart after reacquiring the lock */
>   		mutex_lock(&gt->mutex);
> -		tl = list_entry(&gt->list, typeof(*tl), link);
> +		tl = list_entry(&gt->active_list, typeof(*tl), link);
>   	}
>   	mutex_unlock(&gt->mutex);
>   
> diff --git a/drivers/gpu/drm/i915/i915_reset.c b/drivers/gpu/drm/i915/i915_reset.c
> index 09edf488f711..9b9169508139 100644
> --- a/drivers/gpu/drm/i915/i915_reset.c
> +++ b/drivers/gpu/drm/i915/i915_reset.c
> @@ -852,7 +852,7 @@ bool i915_gem_unset_wedged(struct drm_i915_private *i915)
>   	 * No more can be submitted until we reset the wedged bit.
>   	 */
>   	mutex_lock(&i915->gt.timelines.mutex);
> -	list_for_each_entry(tl, &i915->gt.timelines.list, link) {
> +	list_for_each_entry(tl, &i915->gt.timelines.active_list, link) {
>   		struct i915_request *rq;
>   		long timeout;
>   
> diff --git a/drivers/gpu/drm/i915/i915_timeline.c b/drivers/gpu/drm/i915/i915_timeline.c
> index 69ee33dfa340..007348b1b469 100644
> --- a/drivers/gpu/drm/i915/i915_timeline.c
> +++ b/drivers/gpu/drm/i915/i915_timeline.c
> @@ -117,7 +117,6 @@ int i915_timeline_init(struct drm_i915_private *i915,
>   		       const char *name,
>   		       struct i915_vma *hwsp)
>   {
> -	struct i915_gt_timelines *gt = &i915->gt.timelines;
>   	void *vaddr;
>   
>   	/*
> @@ -161,10 +160,6 @@ int i915_timeline_init(struct drm_i915_private *i915,
>   
>   	i915_syncmap_init(&timeline->sync);
>   
> -	mutex_lock(&gt->mutex);
> -	list_add(&timeline->link, &gt->list);
> -	mutex_unlock(&gt->mutex);
> -
>   	return 0;
>   }
>   
> @@ -173,7 +168,7 @@ void i915_timelines_init(struct drm_i915_private *i915)
>   	struct i915_gt_timelines *gt = &i915->gt.timelines;
>   
>   	mutex_init(&gt->mutex);
> -	INIT_LIST_HEAD(&gt->list);
> +	INIT_LIST_HEAD(&gt->active_list);
>   
>   	spin_lock_init(&gt->hwsp_lock);
>   	INIT_LIST_HEAD(&gt->hwsp_free_list);
> @@ -182,6 +177,24 @@ void i915_timelines_init(struct drm_i915_private *i915)
>   	i915_gem_shrinker_taints_mutex(i915, &gt->mutex);
>   }
>   
> +static void timeline_active(struct i915_timeline *tl)
> +{
> +	struct i915_gt_timelines *gt = &tl->i915->gt.timelines;
> +
> +	mutex_lock(&gt->mutex);
> +	list_add(&tl->link, &gt->active_list);
> +	mutex_unlock(&gt->mutex);
> +}
> +
> +static void timeline_inactive(struct i915_timeline *tl)
> +{
> +	struct i915_gt_timelines *gt = &tl->i915->gt.timelines;
> +
> +	mutex_lock(&gt->mutex);
> +	list_del(&tl->link);
> +	mutex_unlock(&gt->mutex);
> +}

Bike shedding comments only:
Would it be better to use a verb suffix? Even though timeline_activate 
also wouldn't sound perfect. Since it is file local - activate_timeline? 
Or even just inline to pin/unpin. Unless more gets put into them later..

> +
>   /**
>    * i915_timelines_park - called when the driver idles
>    * @i915: the drm_i915_private device
> @@ -198,7 +211,7 @@ void i915_timelines_park(struct drm_i915_private *i915)
>   	struct i915_timeline *timeline;
>   
>   	mutex_lock(&gt->mutex);
> -	list_for_each_entry(timeline, &gt->list, link) {
> +	list_for_each_entry(timeline, &gt->active_list, link) {
>   		/*
>   		 * All known fences are completed so we can scrap
>   		 * the current sync point tracking and start afresh,
> @@ -212,15 +225,9 @@ void i915_timelines_park(struct drm_i915_private *i915)
>   
>   void i915_timeline_fini(struct i915_timeline *timeline)
>   {
> -	struct i915_gt_timelines *gt = &timeline->i915->gt.timelines;
> -
>   	GEM_BUG_ON(timeline->pin_count);
>   	GEM_BUG_ON(!list_empty(&timeline->requests));
>   
> -	mutex_lock(&gt->mutex);
> -	list_del(&timeline->link);
> -	mutex_unlock(&gt->mutex);
> -
>   	i915_syncmap_free(&timeline->sync);
>   	hwsp_free(timeline);
>   
> @@ -263,6 +270,8 @@ int i915_timeline_pin(struct i915_timeline *tl)
>   	if (err)
>   		goto unpin;
>   
> +	timeline_active(tl);
> +
>   	return 0;
>   
>   unpin:
> @@ -276,6 +285,8 @@ void i915_timeline_unpin(struct i915_timeline *tl)
>   	if (--tl->pin_count)
>   		return;
>   
> +	timeline_inactive(tl);
> +
>   	/*
>   	 * Since this timeline is idle, all bariers upon which we were waiting
>   	 * must also be complete and so we can discard the last used barriers
> @@ -299,7 +310,7 @@ void i915_timelines_fini(struct drm_i915_private *i915)
>   {
>   	struct i915_gt_timelines *gt = &i915->gt.timelines;
>   
> -	GEM_BUG_ON(!list_empty(&gt->list));
> +	GEM_BUG_ON(!list_empty(&gt->active_list));
>   	GEM_BUG_ON(!list_empty(&gt->hwsp_free_list));
>   
>   	mutex_destroy(&gt->mutex);
> 

Never mind the bikeshedding comments:

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-01-22 14:56 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-21 22:20 HWSP for HW semaphores Chris Wilson
2019-01-21 22:20 ` [PATCH 01/34] drm/i915/execlists: Mark up priority boost on preemption Chris Wilson
2019-01-21 22:20 ` [PATCH 02/34] drm/i915/execlists: Suppress preempting self Chris Wilson
2019-01-22 22:18   ` John Harrison
2019-01-22 22:38     ` Chris Wilson
2019-01-21 22:20 ` [PATCH 03/34] drm/i915: Show all active engines on hangcheck Chris Wilson
2019-01-22 12:33   ` Mika Kuoppala
2019-01-22 12:42     ` Chris Wilson
2019-01-21 22:20 ` [PATCH 04/34] drm/i915/selftests: Refactor common live_test framework Chris Wilson
2019-01-22 12:37   ` Matthew Auld
2019-01-21 22:20 ` [PATCH 05/34] drm/i915/selftests: Track evict objects explicitly Chris Wilson
2019-01-22 11:53   ` Matthew Auld
2019-01-21 22:20 ` [PATCH 06/34] drm/i915/selftests: Create a clean GGTT for vma/gtt selftesting Chris Wilson
2019-01-22 12:07   ` Matthew Auld
2019-01-21 22:20 ` [PATCH 07/34] drm/i915: Refactor out intel_context_init() Chris Wilson
2019-01-22 12:32   ` Matthew Auld
2019-01-22 12:39   ` Mika Kuoppala
2019-01-22 12:48     ` Chris Wilson
2019-01-21 22:20 ` [PATCH 08/34] drm/i915: Make all GPU resets atomic Chris Wilson
2019-01-22 22:19   ` John Harrison
2019-01-22 22:27     ` Chris Wilson
2019-01-23  8:52     ` Mika Kuoppala
2019-01-21 22:20 ` [PATCH 09/34] drm/i915/guc: Disable global reset Chris Wilson
2019-01-22 22:23   ` John Harrison
2019-01-21 22:20 ` [PATCH 10/34] drm/i915: Remove GPU reset dependence on struct_mutex Chris Wilson
2019-01-24 12:06   ` Mika Kuoppala
2019-01-24 12:50     ` Chris Wilson
2019-01-24 13:12       ` Chris Wilson
2019-01-24 14:10       ` Chris Wilson
2019-01-21 22:20 ` [PATCH 11/34] drm/i915/selftests: Trim struct_mutex duration for set-wedged selftest Chris Wilson
2019-01-21 22:20 ` [PATCH 12/34] drm/i915: Issue engine resets onto idle engines Chris Wilson
2019-01-23  1:18   ` John Harrison
2019-01-23  1:31     ` Chris Wilson
2019-01-21 22:20 ` [PATCH 13/34] drm/i915: Stop tracking MRU activity on VMA Chris Wilson
2019-01-21 22:20 ` [PATCH 14/34] drm/i915: Pull VM lists under the VM mutex Chris Wilson
2019-01-22  9:09   ` Tvrtko Ursulin
2019-01-21 22:20 ` [PATCH 15/34] drm/i915: Move vma lookup to its own lock Chris Wilson
2019-01-21 22:20 ` [PATCH 16/34] drm/i915: Always allocate an object/vma for the HWSP Chris Wilson
2019-01-21 22:21 ` [PATCH 17/34] drm/i915: Move list of timelines under its own lock Chris Wilson
2019-01-21 22:21 ` [PATCH 18/34] drm/i915/selftests: Use common mock_engine::advance Chris Wilson
2019-01-22  9:33   ` Tvrtko Ursulin
2019-01-21 22:21 ` [PATCH 19/34] drm/i915: Tidy common test_bit probing of i915_request->fence.flags Chris Wilson
2019-01-22  9:35   ` Tvrtko Ursulin
2019-01-21 22:21 ` [PATCH 20/34] drm/i915: Introduce concept of per-timeline (context) HWSP Chris Wilson
2019-01-23  1:35   ` John Harrison
2019-01-21 22:21 ` [PATCH 21/34] drm/i915: Enlarge vma->pin_count Chris Wilson
2019-01-21 22:21 ` [PATCH 22/34] drm/i915: Allocate a status page for each timeline Chris Wilson
2019-01-21 22:21 ` [PATCH 23/34] drm/i915: Share per-timeline HWSP using a slab suballocator Chris Wilson
2019-01-22 10:47   ` Tvrtko Ursulin
2019-01-22 11:12     ` Chris Wilson
2019-01-22 11:33       ` Tvrtko Ursulin
2019-01-21 22:21 ` [PATCH 24/34] drm/i915: Track the context's seqno in its own timeline HWSP Chris Wilson
2019-01-22 12:24   ` Tvrtko Ursulin
2019-01-21 22:21 ` [PATCH 25/34] drm/i915: Track active timelines Chris Wilson
2019-01-22 14:56   ` Tvrtko Ursulin [this message]
2019-01-22 15:17     ` Chris Wilson
2019-01-23 22:32       ` John Harrison
2019-01-23 23:08         ` Chris Wilson
2019-01-21 22:21 ` [PATCH 26/34] drm/i915: Identify active requests Chris Wilson
2019-01-22 15:34   ` Tvrtko Ursulin
2019-01-22 15:45     ` Chris Wilson
2019-01-21 22:21 ` [PATCH 27/34] drm/i915: Remove the intel_engine_notify tracepoint Chris Wilson
2019-01-22 15:50   ` Tvrtko Ursulin
2019-01-23 12:54     ` Chris Wilson
2019-01-23 13:18       ` Tvrtko Ursulin
2019-01-23 13:24         ` Chris Wilson
2019-01-21 22:21 ` [PATCH 28/34] drm/i915: Replace global breadcrumbs with per-context interrupt tracking Chris Wilson
2019-01-23  9:21   ` Tvrtko Ursulin
2019-01-23 10:01     ` Chris Wilson
2019-01-23 16:28       ` Tvrtko Ursulin
2019-01-23 11:41   ` [PATCH] " Chris Wilson
2019-01-21 22:21 ` [PATCH 29/34] drm/i915: Drop fake breadcrumb irq Chris Wilson
2019-01-24 17:55   ` Tvrtko Ursulin
2019-01-24 18:18     ` Chris Wilson
2019-01-21 22:21 ` [PATCH 30/34] drm/i915: Keep timeline HWSP allocated until the system is idle Chris Wilson
2019-01-21 22:37   ` Chris Wilson
2019-01-21 22:48     ` Chris Wilson
2019-01-21 22:21 ` [PATCH 31/34] drm/i915/execlists: Refactor out can_merge_rq() Chris Wilson
2019-01-21 22:21 ` [PATCH 32/34] drm/i915: Use HW semaphores for inter-engine synchronisation on gen8+ Chris Wilson
2019-01-21 22:21 ` [PATCH 33/34] drm/i915: Prioritise non-busywait semaphore workloads Chris Wilson
2019-01-23  0:33   ` Chris Wilson
2019-01-21 22:21 ` [PATCH 34/34] drm/i915: Replace global_seqno with a hangcheck heartbeat seqno Chris Wilson
2019-01-22  0:09 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/34] drm/i915/execlists: Mark up priority boost on preemption Patchwork
2019-01-22  0:22 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-22  0:30 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-22  1:35 ` ✗ Fi.CI.IGT: failure " Patchwork
2019-01-23 12:00 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/34] drm/i915/execlists: Mark up priority boost on preemption (rev2) Patchwork
2019-01-23 12:11 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-23 12:48 ` ✗ Fi.CI.BAT: failure " 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=03e15be3-1cfc-5d50-cabe-de9be5300992@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox