Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: [Intel-gfx] [PATCH 1/2] drm/i915/gt: Prefer recycling an idle fence
Date: Wed, 23 Dec 2020 23:20:38 +0200	[thread overview]
Message-ID: <877dp8md7d.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20201223122051.4624-1-chris@chris-wilson.co.uk>

Chris Wilson <chris@chris-wilson.co.uk> writes:

> If we want to reuse a fence that is in active use by the GPU, we have to
> wait an uncertain amount of time, but if we reuse an inactive fence, we
> can change it right away. Loop through the list of available fences
> twice, ignoring any active fences on the first pass.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c | 22 ++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c b/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
> index 7fb36b12fe7a..a357bb431815 100644
> --- a/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
> +++ b/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
> @@ -320,13 +320,31 @@ void i915_vma_revoke_fence(struct i915_vma *vma)
>  		fence_write(fence);
>  }
>  
> +static bool fence_is_active(const struct i915_fence_reg *fence)
> +{
> +	return fence->vma && i915_vma_is_active(fence->vma);
> +}
> +
>  static struct i915_fence_reg *fence_find(struct i915_ggtt *ggtt)
>  {
> -	struct i915_fence_reg *fence;
> +	struct i915_fence_reg *active = NULL;
> +	struct i915_fence_reg *fence, *fn;
>  
> -	list_for_each_entry(fence, &ggtt->fence_list, link) {
> +	list_for_each_entry_safe(fence, fn, &ggtt->fence_list, link) {
>  		GEM_BUG_ON(fence->vma && fence->vma->fence != fence);
>  
> +		if (fence == active) /* now seen this fence twice */
> +			active = ERR_PTR(-EAGAIN);
> +
> +		/* Prefer idle fences so we do not have to wait on the GPU */
> +		if (active != ERR_PTR(-EAGAIN) && fence_is_active(fence)) {
> +			if (!active)
> +				active = fence;
> +
> +			list_move_tail(&fence->link, &ggtt->fence_list);
> +			continue;
> +		}
> +
>  		if (atomic_read(&fence->pin_count))
>  			continue;
>  
> -- 
> 2.20.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

      parent reply	other threads:[~2020-12-23 21:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 12:20 [Intel-gfx] [PATCH 1/2] drm/i915/gt: Prefer recycling an idle fence Chris Wilson
2020-12-23 12:20 ` [Intel-gfx] [PATCH 2/2] drm/i915/gem: Optimistically prune dma-resv from the shrinker Chris Wilson
2020-12-23 21:52   ` Mika Kuoppala
2020-12-23 14:55 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/gt: Prefer recycling an idle fence Patchwork
2020-12-23 15:25 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-12-23 18:50 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2020-12-23 21:20 ` Mika Kuoppala [this message]

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=877dp8md7d.fsf@gaia.fi.intel.com \
    --to=mika.kuoppala@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