* [PATCH] zonefs: Simplify the allocation of slab caches in zonefs_init_inodecache
@ 2024-02-05 8:10 Kunwu Chan
2024-02-09 4:06 ` Damien Le Moal
0 siblings, 1 reply; 3+ messages in thread
From: Kunwu Chan @ 2024-02-05 8:10 UTC (permalink / raw)
To: dlemoal, naohiro.aota, jth; +Cc: linux-fsdevel, linux-kernel, Kunwu Chan
Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
to simplify the creation of SLAB caches.
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
fs/zonefs/super.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 93971742613a..9b578e7007e9 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -1387,10 +1387,8 @@ static struct file_system_type zonefs_type = {
static int __init zonefs_init_inodecache(void)
{
- zonefs_inode_cachep = kmem_cache_create("zonefs_inode_cache",
- sizeof(struct zonefs_inode_info), 0,
- (SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD | SLAB_ACCOUNT),
- NULL);
+ zonefs_inode_cachep = KMEM_CACHE(zonefs_inode_info,
+ SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD | SLAB_ACCOUNT);
if (zonefs_inode_cachep == NULL)
return -ENOMEM;
return 0;
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] zonefs: Simplify the allocation of slab caches in zonefs_init_inodecache
2024-02-05 8:10 [PATCH] zonefs: Simplify the allocation of slab caches in zonefs_init_inodecache Kunwu Chan
@ 2024-02-09 4:06 ` Damien Le Moal
2024-02-19 8:52 ` Kunwu Chan
0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2024-02-09 4:06 UTC (permalink / raw)
To: Kunwu Chan, naohiro.aota, jth; +Cc: linux-fsdevel, linux-kernel
On 2/5/24 17:10, Kunwu Chan wrote:
> Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
> to simplify the creation of SLAB caches.
>
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---
> fs/zonefs/super.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 93971742613a..9b578e7007e9 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -1387,10 +1387,8 @@ static struct file_system_type zonefs_type = {
>
> static int __init zonefs_init_inodecache(void)
> {
> - zonefs_inode_cachep = kmem_cache_create("zonefs_inode_cache",
> - sizeof(struct zonefs_inode_info), 0,
> - (SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD | SLAB_ACCOUNT),
> - NULL);
> + zonefs_inode_cachep = KMEM_CACHE(zonefs_inode_info,
> + SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD | SLAB_ACCOUNT);
> if (zonefs_inode_cachep == NULL)
> return -ENOMEM;
> return 0;
I do not really see a meaningful simplification here. Using kmem_cache_create()
directly is not *that* complicated... Also, this changes the name of the cache
from "zonefs_inode_cache" to "zonefs_inode_info".
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] zonefs: Simplify the allocation of slab caches in zonefs_init_inodecache
2024-02-09 4:06 ` Damien Le Moal
@ 2024-02-19 8:52 ` Kunwu Chan
0 siblings, 0 replies; 3+ messages in thread
From: Kunwu Chan @ 2024-02-19 8:52 UTC (permalink / raw)
To: Damien Le Moal, naohiro.aota, jth; +Cc: linux-fsdevel, linux-kernel
Thanks for the reply.
On 2024/2/9 12:06, Damien Le Moal wrote:
> On 2/5/24 17:10, Kunwu Chan wrote:
>> Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
>> to simplify the creation of SLAB caches.
>>
>> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
>> ---
>> fs/zonefs/super.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
>> index 93971742613a..9b578e7007e9 100644
>> --- a/fs/zonefs/super.c
>> +++ b/fs/zonefs/super.c
>> @@ -1387,10 +1387,8 @@ static struct file_system_type zonefs_type = {
>>
>> static int __init zonefs_init_inodecache(void)
>> {
>> - zonefs_inode_cachep = kmem_cache_create("zonefs_inode_cache",
>> - sizeof(struct zonefs_inode_info), 0,
>> - (SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD | SLAB_ACCOUNT),
>> - NULL);
>> + zonefs_inode_cachep = KMEM_CACHE(zonefs_inode_info,
>> + SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD | SLAB_ACCOUNT);
>> if (zonefs_inode_cachep == NULL)
>> return -ENOMEM;
>> return 0;
>
> I do not really see a meaningful simplification here. Using kmem_cache_create()
The main reason is 'it hides all the 0 or NULL parameters'.
> directly is not *that* complicated... Also, this changes the name of the cache
> from "zonefs_inode_cache" to "zonefs_inode_info".
Cache name is used in /proc/slabinfo to identify this cache.
>
Thank again for taking the time to review and reply.
--
Thanks,
Kunwu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-19 8:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 8:10 [PATCH] zonefs: Simplify the allocation of slab caches in zonefs_init_inodecache Kunwu Chan
2024-02-09 4:06 ` Damien Le Moal
2024-02-19 8:52 ` Kunwu Chan
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®