Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nirmoy Das <nirmoy.das@linux.intel.com>
To: intel-gfx@lists.freedesktop.org, andi.shyti@linux.intel.com
Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	dri-devel@lists.freedesktop.org,
	Nirmoy Das <nirmoy.das@intel.com>
Subject: Re: [Intel-gfx] [PATCH v3] drm/i915/gem: Make i915_gem_shrinker multi-gt aware
Date: Tue, 26 Sep 2023 11:24:16 +0200	[thread overview]
Message-ID: <78ce5784-b74f-e693-d376-e171e986b517@linux.intel.com> (raw)
In-Reply-To: <20230925171048.19245-1-nirmoy.das@intel.com>

[-- Attachment #1: Type: text/plain, Size: 4185 bytes --]


On 9/25/2023 7:10 PM, Nirmoy Das wrote:
> From: Jonathan Cavitt<jonathan.cavitt@intel.com>
>
> Where applicable, use for_each_gt instead of to_gt in the
> i915_gem_shrinker functions to make them apply to more than just the
> primary GT.  Specifically, this ensure i915_gem_shrink_all retires all
> requests across all GTs, and this makes i915_gem_shrinker_vmap unmap
> VMAs from all GTs.
>
> v2: Pass correct GT to intel_gt_retire_requests(Andrzej).
> v3: Remove unnecessary braces(Andi)
eh I will resend the v2 with your r-b, Andi.

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c: In function ‘i915_gem_shrink’:
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c:152:5: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=dangling-else]
   152 |  if (shrink & I915_SHRINK_ACTIVE)
       |     ^

>
> Signed-off-by: Jonathan Cavitt<jonathan.cavitt@intel.com>
> Signed-off-by: Nirmoy Das<nirmoy.das@intel.com>
> Reviewed-by: Andrzej Hajda<andrzej.hajda@intel.com>
> Reviewed-by: Andi Shyti<andi.shyti@linux.intel.com>
> ---
>   drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 41 ++++++++++++--------
>   1 file changed, 24 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> index 214763942aa2..e79fcbdfab25 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> @@ -14,6 +14,7 @@
>   #include <linux/vmalloc.h>
>   
>   #include "gt/intel_gt_requests.h"
> +#include "gt/intel_gt.h"
>   
>   #include "i915_trace.h"
>   
> @@ -119,7 +120,8 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
>   	intel_wakeref_t wakeref = 0;
>   	unsigned long count = 0;
>   	unsigned long scanned = 0;
> -	int err = 0;
> +	int err = 0, i = 0;
> +	struct intel_gt *gt;
>   
>   	/* CHV + VTD workaround use stop_machine(); need to trylock vm->mutex */
>   	bool trylock_vm = !ww && intel_vm_no_concurrent_access_wa(i915);
> @@ -148,8 +150,9 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
>   	 * contexts around longer than is necessary.
>   	 */
>   	if (shrink & I915_SHRINK_ACTIVE)
> -		/* Retire requests to unpin all idle contexts */
> -		intel_gt_retire_requests(to_gt(i915));
> +		for_each_gt(gt, i915, i)
> +			/* Retire requests to unpin all idle contexts */
> +			intel_gt_retire_requests(gt);
>   
>   	/*
>   	 * As we may completely rewrite the (un)bound list whilst unbinding
> @@ -389,6 +392,8 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
>   	struct i915_vma *vma, *next;
>   	unsigned long freed_pages = 0;
>   	intel_wakeref_t wakeref;
> +	struct intel_gt *gt;
> +	int i;
>   
>   	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
>   		freed_pages += i915_gem_shrink(NULL, i915, -1UL, NULL,
> @@ -397,24 +402,26 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
>   					       I915_SHRINK_VMAPS);
>   
>   	/* We also want to clear any cached iomaps as they wrap vmap */
> -	mutex_lock(&to_gt(i915)->ggtt->vm.mutex);
> -	list_for_each_entry_safe(vma, next,
> -				 &to_gt(i915)->ggtt->vm.bound_list, vm_link) {
> -		unsigned long count = i915_vma_size(vma) >> PAGE_SHIFT;
> -		struct drm_i915_gem_object *obj = vma->obj;
> -
> -		if (!vma->iomap || i915_vma_is_active(vma))
> -			continue;
> +	for_each_gt(gt, i915, i) {
> +		mutex_lock(&gt->ggtt->vm.mutex);
> +		list_for_each_entry_safe(vma, next,
> +					 &gt->ggtt->vm.bound_list, vm_link) {
> +			unsigned long count = i915_vma_size(vma) >> PAGE_SHIFT;
> +			struct drm_i915_gem_object *obj = vma->obj;
> +
> +			if (!vma->iomap || i915_vma_is_active(vma))
> +				continue;
>   
> -		if (!i915_gem_object_trylock(obj, NULL))
> -			continue;
> +			if (!i915_gem_object_trylock(obj, NULL))
> +				continue;
>   
> -		if (__i915_vma_unbind(vma) == 0)
> -			freed_pages += count;
> +			if (__i915_vma_unbind(vma) == 0)
> +				freed_pages += count;
>   
> -		i915_gem_object_unlock(obj);
> +			i915_gem_object_unlock(obj);
> +		}
> +		mutex_unlock(&gt->ggtt->vm.mutex);
>   	}
> -	mutex_unlock(&to_gt(i915)->ggtt->vm.mutex);
>   
>   	*(unsigned long *)ptr += freed_pages;
>   	return NOTIFY_DONE;

[-- Attachment #2: Type: text/html, Size: 6125 bytes --]

      parent reply	other threads:[~2023-09-26  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-25 17:10 [Intel-gfx] [PATCH v3] drm/i915/gem: Make i915_gem_shrinker multi-gt aware Nirmoy Das
2023-09-26  3:47 ` kernel test robot
2023-09-26  4:07 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915/gem: Make i915_gem_shrinker multi-gt aware (rev3) Patchwork
2023-09-26  9:24 ` Nirmoy Das [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=78ce5784-b74f-e693-d376-e171e986b517@linux.intel.com \
    --to=nirmoy.das@linux.intel.com \
    --cc=andi.shyti@linux.intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=nirmoy.das@intel.com \
    /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