* [PATCH] btrfs: Simplify the allocation of slab caches in btrfs_delayed_inode_init
@ 2024-01-31 6:19 Kunwu Chan
2024-01-31 10:20 ` Johannes Thumshirn
[not found] ` <1706776227363553.10.seg@mailgw>
0 siblings, 2 replies; 5+ messages in thread
From: Kunwu Chan @ 2024-01-31 6:19 UTC (permalink / raw)
To: clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, Kunwu Chan
commit 0a31bd5f2bbb ("KMEM_CACHE(): simplify slab cache creation")
introduces a new macro.
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/btrfs/delayed-inode.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 08102883f560..8c748c6cdf6d 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -28,11 +28,7 @@ static struct kmem_cache *delayed_node_cache;
int __init btrfs_delayed_inode_init(void)
{
- delayed_node_cache = kmem_cache_create("btrfs_delayed_node",
- sizeof(struct btrfs_delayed_node),
- 0,
- SLAB_MEM_SPREAD,
- NULL);
+ delayed_node_cache = KMEM_CACHE(btrfs_delayed_node, SLAB_MEM_SPREAD);
if (!delayed_node_cache)
return -ENOMEM;
return 0;
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: Simplify the allocation of slab caches in btrfs_delayed_inode_init
2024-01-31 6:19 [PATCH] btrfs: Simplify the allocation of slab caches in btrfs_delayed_inode_init Kunwu Chan
@ 2024-01-31 10:20 ` Johannes Thumshirn
2024-01-31 18:39 ` David Sterba
[not found] ` <1706776227363553.10.seg@mailgw>
1 sibling, 1 reply; 5+ messages in thread
From: Johannes Thumshirn @ 2024-01-31 10:20 UTC (permalink / raw)
To: Kunwu Chan, clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel
On 31.01.24 07:20, Kunwu Chan wrote:
> commit 0a31bd5f2bbb ("KMEM_CACHE(): simplify slab cache creation")
> introduces a new macro.
> Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
That commit is 17 years old. Why should we switch to it _now_? I
wouldn't call it a new macro.
Don't get me wrong, I don't oppose the patch, but I'd prefer a better
explanation why now and not 17 years ago when the macro got introduced.
> to simplify the creation of SLAB caches.
>
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---
> fs/btrfs/delayed-inode.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> index 08102883f560..8c748c6cdf6d 100644
> --- a/fs/btrfs/delayed-inode.c
> +++ b/fs/btrfs/delayed-inode.c
> @@ -28,11 +28,7 @@ static struct kmem_cache *delayed_node_cache;
>
> int __init btrfs_delayed_inode_init(void)
> {
> - delayed_node_cache = kmem_cache_create("btrfs_delayed_node",
> - sizeof(struct btrfs_delayed_node),
> - 0,
> - SLAB_MEM_SPREAD,
> - NULL);
> + delayed_node_cache = KMEM_CACHE(btrfs_delayed_node, SLAB_MEM_SPREAD);
> if (!delayed_node_cache)
> return -ENOMEM;
> return 0;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: Simplify the allocation of slab caches in btrfs_delayed_inode_init
2024-01-31 10:20 ` Johannes Thumshirn
@ 2024-01-31 18:39 ` David Sterba
0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2024-01-31 18:39 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Kunwu Chan, clm, josef, dsterba, linux-btrfs, linux-kernel
On Wed, Jan 31, 2024 at 10:20:35AM +0000, Johannes Thumshirn wrote:
> On 31.01.24 07:20, Kunwu Chan wrote:
> > commit 0a31bd5f2bbb ("KMEM_CACHE(): simplify slab cache creation")
> > introduces a new macro.
> > Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
>
> That commit is 17 years old. Why should we switch to it _now_? I
> wouldn't call it a new macro.
I had the same reaction after checking the commit that added it.
>
> Don't get me wrong, I don't oppose the patch, but I'd prefer a better
> explanation why now and not 17 years ago when the macro got introduced.
We can add the macros where possible, at least it hides all the 0 or
NULL parameters, but yeah with a better changelog.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: Simplify the allocation of slab caches in btrfs_delayed_inode_init
[not found] ` <1706776227363553.10.seg@mailgw>
@ 2024-02-01 8:34 ` Kunwu Chan
2024-02-01 12:07 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Kunwu Chan @ 2024-02-01 8:34 UTC (permalink / raw)
To: Johannes Thumshirn, clm, josef, dsterba, dsterba
Cc: linux-btrfs, linux-kernel
On 2024/1/31 18:20, Johannes Thumshirn wrote:
> On 31.01.24 07:20, Kunwu Chan wrote:
>> commit 0a31bd5f2bbb ("KMEM_CACHE(): simplify slab cache creation")
>> introduces a new macro.
>> Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
>
> That commit is 17 years old. Why should we switch to it _now_? I
> wouldn't call it a new macro.
>
> Don't get me wrong, I don't oppose the patch, but I'd prefer a better
> explanation why now and not 17 years ago when the macro got introduced.
>
Thanks for your attention.
Like David say in
https://lore.kernel.org/all/20240131183929.GP31555@twin.jikos.cz/#t.
The main reason is 'it hides all the 0 or NULL parameters', makes the
code cleaner and more readable.
So i'll update the commit msg to this:
Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
to simplify the creation of SLAB caches.
Make the code cleaner and more readable.
And resend a v2 patch.
Thanks again.
>> to simplify the creation of SLAB caches.
>>
>> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
>> ---
>> fs/btrfs/delayed-inode.c | 6 +-----
>> 1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
>> index 08102883f560..8c748c6cdf6d 100644
>> --- a/fs/btrfs/delayed-inode.c
>> +++ b/fs/btrfs/delayed-inode.c
>> @@ -28,11 +28,7 @@ static struct kmem_cache *delayed_node_cache;
>>
>> int __init btrfs_delayed_inode_init(void)
>> {
>> - delayed_node_cache = kmem_cache_create("btrfs_delayed_node",
>> - sizeof(struct btrfs_delayed_node),
>> - 0,
>> - SLAB_MEM_SPREAD,
>> - NULL);
>> + delayed_node_cache = KMEM_CACHE(btrfs_delayed_node, SLAB_MEM_SPREAD);
>> if (!delayed_node_cache)
>> return -ENOMEM;
>> return 0;
>
--
Thanks,
Kunwu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: btrfs: Simplify the allocation of slab caches in btrfs_delayed_inode_init
2024-02-01 8:34 ` Kunwu Chan
@ 2024-02-01 12:07 ` Markus Elfring
0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2024-02-01 12:07 UTC (permalink / raw)
To: Kunwu Chan, linux-btrfs, kernel-janitors
Cc: linux-kernel, Chris Mason, David Sterba, Johannes Thumshirn, Josef Bacik
…
> So i'll update the commit msg to this:
>
> Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
> to simplify the creation of SLAB caches.
> Make the code cleaner and more readable.
…
* Please replace the word “new” by a reference to the commit 8eb8284b412906181357c2b0110d879d5af95e52
("usercopy: Prepare for usercopy whitelisting").
See also related background information from 2017-06-10.
* How does your response fit to the repetition of improvable change descriptions?
Example:
[PATCH] btrfs: Simplify the allocation of slab caches in btrfs_transaction_init
https://lore.kernel.org/lkml/20240201093554.208092-1-chentao@kylinos.cn/
https://lkml.org/lkml/2024/2/1/387
* How do you think about to group similar source code transformations
into patch series?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-01 12:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-31 6:19 [PATCH] btrfs: Simplify the allocation of slab caches in btrfs_delayed_inode_init Kunwu Chan
2024-01-31 10:20 ` Johannes Thumshirn
2024-01-31 18:39 ` David Sterba
[not found] ` <1706776227363553.10.seg@mailgw>
2024-02-01 8:34 ` Kunwu Chan
2024-02-01 12:07 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).