Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [PATCH] drm/xe: skip rebind_list if vma destroyed
Date: Tue, 8 Aug 2023 17:19:55 -0400	[thread overview]
Message-ID: <ZNKxe3dUcaZ5/L5+@intel.com> (raw)
In-Reply-To: <20230808091208.112793-2-matthew.auld@intel.com>

On Tue, Aug 08, 2023 at 10:12:09AM +0100, Matthew Auld wrote:
> If we are closing a vm, mark each vma as XE_VMA_DESTROYED and skip
> touching the rebind_list if this is seen on the eviction path. That way
> we can safely drop the vm dma-resv lock on the close path without
> needing to worry about racing with the eviction path trying to add stuff
> to the rebind_list which can corrupt our contended list, since the
> destroy and rebind links are the same list entry underneath.
> 
> References: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/514
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>

it looks right to me. Although it would still be good to take
Matthew's eyes here,

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_bo.c | 10 ++++++----
>  drivers/gpu/drm/xe/xe_vm.c |  1 +
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index 284c86107a5f..6a7dc14feab0 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -504,15 +504,17 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo,
>  				vm_resv_locked = true;
>  			else if (ctx->resv != &vm->resv) {
>  				spin_lock(&vm->notifier.list_lock);
> -				list_move_tail(&vma->notifier.rebind_link,
> -					       &vm->notifier.rebind_list);
> +				if (!(vma->gpuva.flags & XE_VMA_DESTROYED))
> +					list_move_tail(&vma->notifier.rebind_link,
> +						       &vm->notifier.rebind_list);
>  				spin_unlock(&vm->notifier.list_lock);
>  				continue;
>  			}
>  
>  			xe_vm_assert_held(vm);
> -			if (list_empty(&vma->combined_links.rebind) &&
> -			    vma->tile_present)
> +			if (vma->tile_present &&
> +			    !(vma->gpuva.flags & XE_VMA_DESTROYED) &&
> +			    list_empty(&vma->combined_links.rebind))
>  				list_add_tail(&vma->combined_links.rebind,
>  					      &vm->rebind_list);
>  
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index 936492915ecb..aef032ba8e27 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -1450,6 +1450,7 @@ void xe_vm_close_and_put(struct xe_vm *vm)
>  		}
>  
>  		list_move_tail(&vma->combined_links.destroy, &contested);
> +		vma->gpuva.flags |= XE_VMA_DESTROYED;
>  	}
>  
>  	/*
> -- 
> 2.41.0
> 

      parent reply	other threads:[~2023-08-08 21:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08  9:12 [Intel-xe] [PATCH] drm/xe: skip rebind_list if vma destroyed Matthew Auld
2023-08-08  9:45 ` [Intel-xe] ✓ CI.Patch_applied: success for " Patchwork
2023-08-08  9:45 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-08-08  9:46 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-08-08  9:50 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-08-08  9:50 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-08-08  9:51 ` [Intel-xe] ✗ CI.checksparse: warning " Patchwork
2023-08-08 10:26 ` [Intel-xe] ✗ CI.BAT: failure " Patchwork
2023-08-08 21:19 ` Rodrigo Vivi [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=ZNKxe3dUcaZ5/L5+@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@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