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 2/2] drm/i915/gem: Optimistically prune dma-resv from the shrinker.
Date: Wed, 23 Dec 2020 23:52:00 +0200 [thread overview]
Message-ID: <874kkcmbr3.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20201223122051.4624-2-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> As we shrink an object, also see if we can prune the dma-resv of idle
> fences it is maintaining a reference to.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/Makefile | 1 +
> drivers/gpu/drm/i915/dma_resv_utils.c | 17 +++++++++++++++++
> drivers/gpu/drm/i915/dma_resv_utils.h | 13 +++++++++++++
> drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 3 +++
> drivers/gpu/drm/i915/gem/i915_gem_wait.c | 8 +++-----
> 5 files changed, 37 insertions(+), 5 deletions(-)
> create mode 100644 drivers/gpu/drm/i915/dma_resv_utils.c
> create mode 100644 drivers/gpu/drm/i915/dma_resv_utils.h
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 3a439b1d0496..f1c7c3246226 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -58,6 +58,7 @@ i915-y += i915_drv.o \
>
> # core library code
> i915-y += \
> + dma_resv_utils.o \
> i915_memcpy.o \
> i915_mm.o \
> i915_sw_fence.o \
> diff --git a/drivers/gpu/drm/i915/dma_resv_utils.c b/drivers/gpu/drm/i915/dma_resv_utils.c
> new file mode 100644
> index 000000000000..9e508e7d4629
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/dma_resv_utils.c
> @@ -0,0 +1,17 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2020 Intel Corporation
> + */
> +
> +#include <linux/dma-resv.h>
> +
> +#include "dma_resv_utils.h"
> +
> +void dma_resv_prune(struct dma_resv *resv)
> +{
> + if (dma_resv_trylock(resv)) {
> + if (dma_resv_test_signaled_rcu(resv, true))
> + dma_resv_add_excl_fence(resv, NULL);
> + dma_resv_unlock(resv);
> + }
> +}
> diff --git a/drivers/gpu/drm/i915/dma_resv_utils.h b/drivers/gpu/drm/i915/dma_resv_utils.h
> new file mode 100644
> index 000000000000..b9d8fb5f8367
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/dma_resv_utils.h
> @@ -0,0 +1,13 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2020 Intel Corporation
> + */
> +
> +#ifndef DMA_RESV_UTILS_H
> +#define DMA_RESV_UTILS_H
> +
> +struct dma_resv;
> +
> +void dma_resv_prune(struct dma_resv *resv);
> +
> +#endif /* DMA_RESV_UTILS_H */
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> index dc8f052a0ffe..c2dba1cd9532 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> @@ -15,6 +15,7 @@
>
> #include "gt/intel_gt_requests.h"
>
> +#include "dma_resv_utils.h"
> #include "i915_trace.h"
>
> static bool swap_available(void)
> @@ -209,6 +210,8 @@ i915_gem_shrink(struct drm_i915_private *i915,
> mutex_unlock(&obj->mm.lock);
> }
>
> + dma_resv_prune(obj->base.resv);
> +
> scanned += obj->base.size >> PAGE_SHIFT;
> i915_gem_object_put(obj);
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c
> index 8af55cd3e690..c1b13ac50d0f 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c
> @@ -9,6 +9,7 @@
>
> #include "gt/intel_engine.h"
>
> +#include "dma_resv_utils.h"
> #include "i915_gem_ioctls.h"
> #include "i915_gem_object.h"
>
> @@ -84,11 +85,8 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,
> * Opportunistically prune the fences iff we know they have *all* been
Learned that iff is a word, proper and accurate. So prolly not typo :)
Patch is,
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> * signaled.
> */
> - if (prune_fences && dma_resv_trylock(resv)) {
> - if (dma_resv_test_signaled_rcu(resv, true))
> - dma_resv_add_excl_fence(resv, NULL);
> - dma_resv_unlock(resv);
> - }
> + if (prune_fences)
> + dma_resv_prune(resv);
>
> return timeout;
> }
> --
> 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
next prev parent reply other threads:[~2020-12-23 21:54 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 [this message]
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 ` [Intel-gfx] [PATCH 1/2] " Mika Kuoppala
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=874kkcmbr3.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