Re: [PATCH 2/2] drm/i915/gem: Optimistically prune dma-resv from the shrinker.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxxxx>

>  	 * 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@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux