[PATCH] dlm: use KMEM_CACHE in dlm_memory_init

Hongfu Li posted 1 patch 1 year, 7 months ago
There is a newer version of this series
fs/dlm/memory.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
[PATCH] dlm: use KMEM_CACHE in dlm_memory_init
Posted by Hongfu Li 1 year, 7 months ago
Using KMEM_CACHE() macro makes the code more concise and easy to read.

Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
---
 fs/dlm/memory.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c
index 15a8b1cee433..829cc4fe7bf1 100644
--- a/fs/dlm/memory.c
+++ b/fs/dlm/memory.c
@@ -34,8 +34,7 @@ int __init dlm_memory_init(void)
 	if (!mhandle_cache)
 		goto mhandle;
 
-	lkb_cache = kmem_cache_create("dlm_lkb", sizeof(struct dlm_lkb),
-				__alignof__(struct dlm_lkb), 0, NULL);
+	lkb_cache = KMEM_CACHE(dlm_lkb, 0);
 	if (!lkb_cache)
 		goto lkb;
 
@@ -43,14 +42,11 @@ int __init dlm_memory_init(void)
 	if (!msg_cache)
 		goto msg;
 
-	rsb_cache = kmem_cache_create("dlm_rsb", sizeof(struct dlm_rsb),
-				__alignof__(struct dlm_rsb), 0, NULL);
+	rsb_cache = KMEM_CACHE(dlm_rsb, 0);
 	if (!rsb_cache)
 		goto rsb;
 
-	cb_cache = kmem_cache_create("dlm_cb", sizeof(struct dlm_callback),
-				     __alignof__(struct dlm_callback), 0,
-				     NULL);
+	cb_cache = KMEM_CACHE(dlm_callback, 0);
 	if (!cb_cache)
 		goto cb;
 
-- 
2.25.1
Re: [PATCH] dlm: use KMEM_CACHE() in dlm_memory_init()
Posted by Markus Elfring 1 year, 7 months ago
> Using KMEM_CACHE() macro makes the code more concise and easy to read.

Can the three passed name strings matter still for the identification
of the created caches from this function implementation?
https://elixir.bootlin.com/linux/v6.10-rc4/source/fs/dlm/memory.c#L27
https://elixir.bootlin.com/linux/v6.10-rc4/source/mm/slab_common.c#L362

Regards,
Markus
Re: [PATCH] dlm: use KMEM_CACHE() in dlm_memory_init()
Posted by Alexander Aring 1 year, 7 months ago
Hi,

On Wed, Jun 19, 2024 at 4:54 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> > Using KMEM_CACHE() macro makes the code more concise and easy to read.
>
> Can the three passed name strings matter still for the identification
> of the created caches from this function implementation?
> https://elixir.bootlin.com/linux/v6.10-rc4/source/fs/dlm/memory.c#L27
> https://elixir.bootlin.com/linux/v6.10-rc4/source/mm/slab_common.c#L362

probably only for "dlm_cb" that turns into "dlm_callback". The only
place for me would be /proc/slabinfo, but I usually do `cat
/proc/slabinfo | grep dlm` to get an overview. If you are very strict
and "/proc/slabinfo" is not just "debugging" only and allowed to be
screen scraped (which I don't believe) it might can indeed break some
userspace applications.

- Alex
Re: dlm: use KMEM_CACHE() in dlm_memory_init()
Posted by Markus Elfring 1 year, 7 months ago
>> Can the three passed name strings matter still for the identification
>> of the created caches from this function implementation?
>> https://elixir.bootlin.com/linux/v6.10-rc4/source/fs/dlm/memory.c#L27
>> https://elixir.bootlin.com/linux/v6.10-rc4/source/mm/slab_common.c#L362
>
> probably only for "dlm_cb" that turns into "dlm_callback".
…

Will the development attention grow for deviations of passed name strings
from applied data structure identifiers?

Regards,
Markus