All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: timur.kristof@gmail.com, natalie.vock@gmx.de,
	amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/amdgpu: nuke most amdgpu_vm_eviction_(try)lock uses
Date: Fri, 11 Sep 2026 18:54:06 +0200	[thread overview]
Message-ID: <04ced8a4-d5c0-4733-bd7b-6bd71f9d7157@amd.com> (raw)
In-Reply-To: <20260911164801.50175-1-christian.koenig@amd.com>

Hi Honglei,

this is just to unblock your SVM work, the rest of my patch set needs more work than I thought because of the new ualink files.

Regards,
Christian.

On 9/11/26 18:48, Christian König wrote:
> Use scoped_guard/scoped_cond_guard instead.
> 
> Saving and restoring the GFP flags is not necessary in those use case.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c        | 27 +++++++++----------
>  .../gpu/drm/amd/amdgpu/amdgpu_vm_internal.h   |  9 -------
>  2 files changed, 12 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 47cde54594693..7ced26c9c651b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -616,9 +616,8 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>  	 * As soon as all page tables are in place we can start updating them
>  	 * again.
>  	 */
> -	amdgpu_vm_eviction_lock(vm);
> -	vm->evicting = false;
> -	amdgpu_vm_eviction_unlock(vm);
> +	scoped_guard(mutex, &vm->eviction_lock)
> +		vm->evicting = false;
>  
>  	list_for_each_entry_safe(bo_base, tmp, &vm->always_valid.evicted,
>  				 vm_status) {
> @@ -678,9 +677,8 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)
>  
>  	amdgpu_vm_assert_locked(vm);
>  
> -	amdgpu_vm_eviction_lock(vm);
> -	ret = !vm->evicting;
> -	amdgpu_vm_eviction_unlock(vm);
> +	scoped_guard(mutex, &vm->eviction_lock)
> +		ret = !vm->evicting;
>  
>  	ret &= list_empty(&vm->kernel.evicted);
>  
> @@ -2274,6 +2272,7 @@ void amdgpu_vm_bo_del(struct amdgpu_device *adev,
>  bool amdgpu_vm_evictable(struct amdgpu_bo *bo)
>  {
>  	struct amdgpu_vm_bo_base *bo_base = bo->vm_bo;
> +	struct amdgpu_vm *vm;
>  
>  	/* Page tables of a destroyed VM can go away immediately */
>  	if (!bo_base || !bo_base->vm)
> @@ -2284,17 +2283,15 @@ bool amdgpu_vm_evictable(struct amdgpu_bo *bo)
>  		return false;
>  
>  	/* Try to block ongoing updates */
> -	if (!amdgpu_vm_eviction_trylock(bo_base->vm))
> -		return false;
> +	vm = bo_base->vm;
> +	scoped_cond_guard(mutex_try, return false, &vm->eviction_lock) {
>  
> -	/* Don't evict VM page tables while they are updated */
> -	if (!dma_fence_is_signaled(bo_base->vm->last_unlocked)) {
> -		amdgpu_vm_eviction_unlock(bo_base->vm);
> -		return false;
> -	}
> +		/* Don't evict VM page tables while they are updated */
> +		if (!dma_fence_is_signaled(vm->last_unlocked))
> +			return false;
>  
> -	bo_base->vm->evicting = true;
> -	amdgpu_vm_eviction_unlock(bo_base->vm);
> +		vm->evicting = true;
> +	}
>  	return true;
>  }
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> index 447195cc45932..ca86eaac75235 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> @@ -137,15 +137,6 @@ static inline void amdgpu_vm_eviction_lock(struct amdgpu_vm *vm)
>  	vm->saved_flags = memalloc_noreclaim_save();
>  }
>  
> -static inline bool amdgpu_vm_eviction_trylock(struct amdgpu_vm *vm)
> -{
> -	if (mutex_trylock(&vm->eviction_lock)) {
> -		vm->saved_flags = memalloc_noreclaim_save();
> -		return true;
> -	}
> -	return false;
> -}
> -
>  static inline void amdgpu_vm_eviction_unlock(struct amdgpu_vm *vm)
>  {
>  	memalloc_noreclaim_restore(vm->saved_flags);


  parent reply	other threads:[~2026-09-11 16:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 16:48 [PATCH 1/2] drm/amdgpu: nuke most amdgpu_vm_eviction_(try)lock uses Christian König
2026-09-11 16:48 ` [PATCH 2/2] drm/amdgpu: rework eviction lock handling into critical section v2 Christian König
2026-09-17  8:11   ` Natalie Vock
2026-09-11 16:54 ` Christian König [this message]
2026-09-14  8:04 ` [PATCH 1/2] drm/amdgpu: nuke most amdgpu_vm_eviction_(try)lock uses Huang, Honglei
2026-09-15 10:58   ` Huang, Honglei

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=04ced8a4-d5c0-4733-bd7b-6bd71f9d7157@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Honglei1.Huang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=natalie.vock@gmx.de \
    --cc=timur.kristof@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.