linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Felix Kuehling <felix.kuehling@amd.com>, amd-gfx@lists.freedesktop.org
Cc: linux-mm@kvack.org, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v2] drm/amdkfd: Fix sparse __rcu annotation warnings
Date: Mon, 8 Jan 2024 07:40:28 +0100	[thread overview]
Message-ID: <64bad53c-2bde-4277-ab41-548dca48eb05@amd.com> (raw)
In-Reply-To: <20240105230015.492870-1-felix.kuehling@amd.com>

Am 06.01.24 um 00:00 schrieb Felix Kuehling:
> Properly mark kfd_process->ef as __rcu and consistently use the right
> accessor functions.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202312052245.yFpBSgNH-lkp@intel.com/
> Signed-off-by: Felix Kuehling <felix.kuehling@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h       | 2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--
>   drivers/gpu/drm/amd/amdkfd/kfd_priv.h            | 2 +-
>   drivers/gpu/drm/amd/amdkfd/kfd_process.c         | 7 +++++--
>   4 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
> index cf6ed5fce291..f262b9d89541 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
> @@ -311,7 +311,7 @@ void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct kgd_mem *mem);
>   int amdgpu_amdkfd_map_gtt_bo_to_gart(struct amdgpu_device *adev, struct amdgpu_bo *bo);
>   
>   int amdgpu_amdkfd_gpuvm_restore_process_bos(void *process_info,
> -					    struct dma_fence **ef);
> +					    struct dma_fence __rcu **ef);
>   int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct amdgpu_device *adev,
>   					      struct kfd_vm_fault_info *info);
>   int amdgpu_amdkfd_gpuvm_import_dmabuf_fd(struct amdgpu_device *adev, int fd,
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 48697b789342..5f445d856769 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -2802,7 +2802,7 @@ static void amdgpu_amdkfd_restore_userptr_worker(struct work_struct *work)
>   	put_task_struct(usertask);
>   }
>   
> -static void replace_eviction_fence(struct dma_fence **ef,
> +static void replace_eviction_fence(struct dma_fence __rcu **ef,
>   				   struct dma_fence *new_ef)
>   {
>   	struct dma_fence *old_ef = rcu_replace_pointer(*ef, new_ef, true
> @@ -2837,7 +2837,7 @@ static void replace_eviction_fence(struct dma_fence **ef,
>    * 7.  Add fence to all PD and PT BOs.
>    * 8.  Unreserve all BOs
>    */
> -int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
> +int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence __rcu **ef)
>   {
>   	struct amdkfd_process_info *process_info = info;
>   	struct amdgpu_vm *peer_vm;
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> index 745024b31340..17fbedbf3651 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> @@ -917,7 +917,7 @@ struct kfd_process {
>   	 * fence will be triggered during eviction and new one will be created
>   	 * during restore
>   	 */
> -	struct dma_fence *ef;
> +	struct dma_fence __rcu *ef;
>   
>   	/* Work items for evicting and restoring BOs */
>   	struct delayed_work eviction_work;
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index 71df51fcc1b0..717a60d7a4ea 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -1110,6 +1110,7 @@ static void kfd_process_wq_release(struct work_struct *work)
>   {
>   	struct kfd_process *p = container_of(work, struct kfd_process,
>   					     release_work);
> +	struct dma_fence *ef;
>   
>   	kfd_process_dequeue_from_all_devices(p);
>   	pqm_uninit(&p->pqm);
> @@ -1118,7 +1119,9 @@ static void kfd_process_wq_release(struct work_struct *work)
>   	 * destroyed. This allows any BOs to be freed without
>   	 * triggering pointless evictions or waiting for fences.
>   	 */
> -	dma_fence_signal(p->ef);
> +	synchronize_rcu();
> +	ef = rcu_access_pointer(p->ef);
> +	dma_fence_signal(ef);
>   
>   	kfd_process_remove_sysfs(p);
>   
> @@ -1127,7 +1130,7 @@ static void kfd_process_wq_release(struct work_struct *work)
>   	svm_range_list_fini(p);
>   
>   	kfd_process_destroy_pdds(p);
> -	dma_fence_put(p->ef);
> +	dma_fence_put(ef);
>   
>   	kfd_event_free_process(p);
>   



      reply	other threads:[~2024-01-08  6:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05 23:00 Felix Kuehling
2024-01-08  6:40 ` Christian König [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=64bad53c-2bde-4277-ab41-548dca48eb05@amd.com \
    --to=christian.koenig@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=felix.kuehling@amd.com \
    --cc=linux-mm@kvack.org \
    --cc=lkp@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