diff mbox series

amdgpu/fence: replace call_rcu by kfree_rcu for simple kmem_cache_free callback

Message ID 20241025035110.10854-1-zenghongling@kylinos.cn (mailing list archive)
State New
Headers show
Series amdgpu/fence: replace call_rcu by kfree_rcu for simple kmem_cache_free callback | expand

Commit Message

Hongling Zeng Oct. 25, 2024, 3:51 a.m. UTC
Since SLOB was removed and since
commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"),
it is not necessary to use call_rcu when the callback only performs
kmem_cache_free. Use kfree_rcu() directly.

Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

Comments

Christian König Oct. 28, 2024, 11:55 a.m. UTC | #1
Am 25.10.24 um 05:51 schrieb Hongling Zeng:
> Since SLOB was removed and since
> commit 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"),
> it is not necessary to use call_rcu when the callback only performs
> kmem_cache_free. Use kfree_rcu() directly.

I would rather prefer to completely remove the use of kmem_cache here 
and for all other dma_fence implementations.

The object can live longer than the module which has caused us quite 
some headache already.

Regards,
Christian.

>
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 16 +---------------
>   1 file changed, 1 insertion(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> index 2f24a6a..d047afe 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> @@ -818,20 +818,6 @@ static bool amdgpu_job_fence_enable_signaling(struct dma_fence *f)
>   	return true;
>   }
>   
> -/**
> - * amdgpu_fence_free - free up the fence memory
> - *
> - * @rcu: RCU callback head
> - *
> - * Free up the fence memory after the RCU grace period.
> - */
> -static void amdgpu_fence_free(struct rcu_head *rcu)
> -{
> -	struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);
> -
> -	/* free fence_slab if it's separated fence*/
> -	kmem_cache_free(amdgpu_fence_slab, to_amdgpu_fence(f));
> -}
>   
>   /**
>    * amdgpu_job_fence_free - free up the job with embedded fence
> @@ -858,7 +844,7 @@ static void amdgpu_job_fence_free(struct rcu_head *rcu)
>    */
>   static void amdgpu_fence_release(struct dma_fence *f)
>   {
> -	call_rcu(&f->rcu, amdgpu_fence_free);
> +	kfree_rcu(f, rcu);
>   }
>   
>   /**
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 2f24a6a..d047afe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -818,20 +818,6 @@  static bool amdgpu_job_fence_enable_signaling(struct dma_fence *f)
 	return true;
 }
 
-/**
- * amdgpu_fence_free - free up the fence memory
- *
- * @rcu: RCU callback head
- *
- * Free up the fence memory after the RCU grace period.
- */
-static void amdgpu_fence_free(struct rcu_head *rcu)
-{
-	struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);
-
-	/* free fence_slab if it's separated fence*/
-	kmem_cache_free(amdgpu_fence_slab, to_amdgpu_fence(f));
-}
 
 /**
  * amdgpu_job_fence_free - free up the job with embedded fence
@@ -858,7 +844,7 @@  static void amdgpu_job_fence_free(struct rcu_head *rcu)
  */
 static void amdgpu_fence_release(struct dma_fence *f)
 {
-	call_rcu(&f->rcu, amdgpu_fence_free);
+	kfree_rcu(f, rcu);
 }
 
 /**