* [PATCH] dlm: use KMEM_CACHE in dlm_memory_init @ 2024-06-19 5:03 Hongfu Li 2024-06-19 20:48 ` [PATCH] dlm: use KMEM_CACHE() in dlm_memory_init() Markus Elfring 0 siblings, 1 reply; 7+ messages in thread From: Hongfu Li @ 2024-06-19 5:03 UTC (permalink / raw) To: aahringo, teigland; +Cc: gfs2, linux-kernel, Hongfu Li 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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] dlm: use KMEM_CACHE() in dlm_memory_init() 2024-06-19 5:03 [PATCH] dlm: use KMEM_CACHE in dlm_memory_init Hongfu Li @ 2024-06-19 20:48 ` Markus Elfring 2024-06-19 21:33 ` Alexander Aring 0 siblings, 1 reply; 7+ messages in thread From: Markus Elfring @ 2024-06-19 20:48 UTC (permalink / raw) To: Hongfu Li, gfs2, Alexander Aring, David Teigland; +Cc: LKML > 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] dlm: use KMEM_CACHE() in dlm_memory_init() 2024-06-19 20:48 ` [PATCH] dlm: use KMEM_CACHE() in dlm_memory_init() Markus Elfring @ 2024-06-19 21:33 ` Alexander Aring 2024-06-20 6:33 ` Markus Elfring 0 siblings, 1 reply; 7+ messages in thread From: Alexander Aring @ 2024-06-19 21:33 UTC (permalink / raw) To: Markus Elfring; +Cc: Hongfu Li, gfs2, David Teigland, LKML 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: dlm: use KMEM_CACHE() in dlm_memory_init() 2024-06-19 21:33 ` Alexander Aring @ 2024-06-20 6:33 ` Markus Elfring 2024-06-21 7:55 ` [PATCH] " Hongfu Li 0 siblings, 1 reply; 7+ messages in thread From: Markus Elfring @ 2024-06-20 6:33 UTC (permalink / raw) To: Alexander Aring, David Teigland, Hongfu Li, gfs2; +Cc: LKML >> 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] dlm: use KMEM_CACHE() in dlm_memory_init() 2024-06-20 6:33 ` Markus Elfring @ 2024-06-21 7:55 ` Hongfu Li 2024-06-21 8:40 ` Markus Elfring 0 siblings, 1 reply; 7+ messages in thread From: Hongfu Li @ 2024-06-21 7:55 UTC (permalink / raw) To: markus.elfring; +Cc: aahringo, gfs2, lihongfu, linux-kernel, teigland [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=y, Size: 752 bytes --] >>> 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? My initial purpose is to replace kmem_cache_create() with KMEM_CACHE(). In my view,there is no problem in unifying passed name strings and structure identifiers. Maybe that's wrong,I will resubmit a patch that does not change "dlm_cb" to "dlm_callback". thanks, Hongfu Li ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: dlm: use KMEM_CACHE() in dlm_memory_init() 2024-06-21 7:55 ` [PATCH] " Hongfu Li @ 2024-06-21 8:40 ` Markus Elfring 2024-06-21 10:39 ` Hongfu Li 0 siblings, 1 reply; 7+ messages in thread From: Markus Elfring @ 2024-06-21 8:40 UTC (permalink / raw) To: Hongfu Li, gfs2; +Cc: LKML, Alexander Aring, David Teigland, Julia Lawall >>>> 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? > > My initial purpose is to replace kmem_cache_create() with KMEM_CACHE(). Do you take any help from advanced analysis tools into account for such transformation attempts? Example for the semantic patch language (Coccinelle software): [PATCH v2] Coccinelle: api: Add SmPL script “use_KMEM_CACHE.cocci” https://lore.kernel.org/cocci/b08603d6-cac1-4876-a56c-30c680d5dc52@web.de/ https://sympa.inria.fr/sympa/arc/cocci/2024-02/msg00000.html > In my view,there is no problem in unifying passed name strings and > structure identifiers. > Maybe that's wrong, I suggest to take another look also at feedback which other contributors (from your Linux software distribution) got for similar change suggestions. > I will resubmit a patch that does not change "dlm_cb" to "dlm_callback". Do you see further opportunities to improve the change description accordingly? https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc4#n94 Regards, Markus ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: dlm: use KMEM_CACHE() in dlm_memory_init() 2024-06-21 8:40 ` Markus Elfring @ 2024-06-21 10:39 ` Hongfu Li 0 siblings, 0 replies; 7+ messages in thread From: Hongfu Li @ 2024-06-21 10:39 UTC (permalink / raw) To: markus.elfring Cc: aahringo, gfs2, julia.lawall, lihongfu, linux-kernel, teigland [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=y, Size: 1115 bytes --] >> My initial purpose is to replace kmem_cache_create() with KMEM_CACHE(). > >Do you take any help from advanced analysis tools into account >for such transformation attempts? > >Example for the semantic patch language (Coccinelle software): >[PATCH v2] Coccinelle: api: Add SmPL script “use_KMEM_CACHE.cocci” >https://lore.kernel.org/cocci/b08603d6-cac1-4876-a56c-30c680d5dc52@web.de/ >https://sympa.inria.fr/sympa/arc/cocci/2024-02/msg00000.html > > >> In my view,there is no problem in unifying passed name strings and >> structure identifiers. >> Maybe that's wrong, > >I suggest to take another look also at feedback which other contributors >(from your Linux software distribution) got for similar change suggestions. > > >> I will resubmit a patch that does not change "dlm_cb" to "dlm_callback". > >Do you see further opportunities to improve the change description accordingly? >https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc4#n94 So grateful for you suggestion and I will definitely consider it. thanks, Hongfu Li ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-06-21 10:45 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-06-19 5:03 [PATCH] dlm: use KMEM_CACHE in dlm_memory_init Hongfu Li 2024-06-19 20:48 ` [PATCH] dlm: use KMEM_CACHE() in dlm_memory_init() Markus Elfring 2024-06-19 21:33 ` Alexander Aring 2024-06-20 6:33 ` Markus Elfring 2024-06-21 7:55 ` [PATCH] " Hongfu Li 2024-06-21 8:40 ` Markus Elfring 2024-06-21 10:39 ` Hongfu Li
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox