mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] drm/amdgpu: use KMEM_CACHE instead of kmem_cache_create
@ 2025-09-02  7:27 Longlong Xia
  2025-09-02 11:39 ` Christian König
  0 siblings, 1 reply; 2+ messages in thread
From: Longlong Xia @ 2025-09-02  7:27 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig
  Cc: amd-gfx, dri-devel, linux-kernel, Longlong Xia

Use KMEM_CACHE() instead of kmem_cache_create() to simplify the code.

Signed-off-by: Longlong Xia <xialonglong@kylinos.cn>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
index c2a983ff23c9..51f51064685f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -37,11 +37,7 @@ static struct kmem_cache *amdgpu_userq_fence_slab;
 
 int amdgpu_userq_fence_slab_init(void)
 {
-	amdgpu_userq_fence_slab = kmem_cache_create("amdgpu_userq_fence",
-						    sizeof(struct amdgpu_userq_fence),
-						    0,
-						    SLAB_HWCACHE_ALIGN,
-						    NULL);
+	amdgpu_userq_fence_slab = KMEM_CACHE(amdgpu_userq_fence, SLAB_HWCACHE_ALIGN);
 	if (!amdgpu_userq_fence_slab)
 		return -ENOMEM;
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] drm/amdgpu: use KMEM_CACHE instead of kmem_cache_create
  2025-09-02  7:27 [PATCH 1/1] drm/amdgpu: use KMEM_CACHE instead of kmem_cache_create Longlong Xia
@ 2025-09-02 11:39 ` Christian König
  0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2025-09-02 11:39 UTC (permalink / raw)
  To: Longlong Xia, alexander.deucher; +Cc: amd-gfx, dri-devel, linux-kernel

On 02.09.25 09:27, Longlong Xia wrote:
> Use KMEM_CACHE() instead of kmem_cache_create() to simplify the code.

In general a good cleanup, but why are we using a separate kmem_cache here in the first place?

SLAB_HWCACHE_ALIGN rounds up the struct size to 128 bytes and that is something kzalloc() can return as well.

Regards,
Christian.

> 
> Signed-off-by: Longlong Xia <xialonglong@kylinos.cn>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> index c2a983ff23c9..51f51064685f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> @@ -37,11 +37,7 @@ static struct kmem_cache *amdgpu_userq_fence_slab;
>  
>  int amdgpu_userq_fence_slab_init(void)
>  {
> -	amdgpu_userq_fence_slab = kmem_cache_create("amdgpu_userq_fence",
> -						    sizeof(struct amdgpu_userq_fence),
> -						    0,
> -						    SLAB_HWCACHE_ALIGN,
> -						    NULL);
> +	amdgpu_userq_fence_slab = KMEM_CACHE(amdgpu_userq_fence, SLAB_HWCACHE_ALIGN);
>  	if (!amdgpu_userq_fence_slab)
>  		return -ENOMEM;
>  


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-02 11:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-02  7:27 [PATCH 1/1] drm/amdgpu: use KMEM_CACHE instead of kmem_cache_create Longlong Xia
2025-09-02 11:39 ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®