[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240618072121.67838-1-lihongfu@kylinos.cn>
Date: Tue, 18 Jun 2024 15:21:21 +0800
From: Hongfu Li <lihongfu@...inos.cn>
To: yanjun.zhu@...ux.dev
Cc: allison.henderson@...cle.com,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
lihongfu@...inos.cn,
linux-kernel@...r.kernel.org,
linux-rdma@...r.kernel.org,
netdev@...r.kernel.org,
pabeni@...hat.com,
rds-devel@....oracle.com
Subject: [PATCH] rds:Simplify the allocation of slab caches
>> Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
>> to simplify the creation of SLAB caches.
>>
>> Signed-off-by: Hongfu Li <lihongfu@...inos.cn>
>> ---
>> net/rds/tcp.c | 4 +---
>> net/rds/tcp_recv.c | 4 +---
>> 2 files changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/net/rds/tcp.c b/net/rds/tcp.c
>> index d8111ac83bb6..3dc6956f66f8 100644
>> --- a/net/rds/tcp.c
>> +++ b/net/rds/tcp.c
>> @@ -719,9 +719,7 @@ static int __init rds_tcp_init(void)
>> {
>> int ret;
>>
>> - rds_tcp_conn_slab = kmem_cache_create("rds_tcp_connection",
>> - sizeof(struct rds_tcp_connection),
>> - 0, 0, NULL);
>> + rds_tcp_conn_slab = KMEM_CACHE(rds_tcp_connection, 0);
>KMEM_CACHE is declared as below:
>
>/*
> * Please use this macro to create slab caches. Simply specify the
> * name of the structure and maybe some flags that are listed above.
> *
> * The alignment of the struct determines object alignment. If you
> * f.e. add ____cacheline_aligned_in_smp to the struct declaration
> * then the objects will be properly aligned in SMP configurations.
> */
>#define KMEM_CACHE(__struct, __flags) \
> kmem_cache_create(#__struct, sizeof(struct __struct), \
> __alignof__(struct __struct), (__flags), NULL)
Sorry, I'll check it carefully next time.
Thanks,
Hongfu Li
>> if (!rds_tcp_conn_slab) {
>> ret = -ENOMEM;
>> goto out;
>> diff --git a/net/rds/tcp_recv.c b/net/rds/tcp_recv.c
>> index c00f04a1a534..7997a19d1da3 100644
>> --- a/net/rds/tcp_recv.c
>> +++ b/net/rds/tcp_recv.c
>> @@ -337,9 +337,7 @@ void rds_tcp_data_ready(struct sock *sk)
>>
>> int rds_tcp_recv_init(void)
>> {
>> - rds_tcp_incoming_slab = kmem_cache_create("rds_tcp_incoming",
>> - sizeof(struct rds_tcp_incoming),
>> - 0, 0, NULL);
>> + rds_tcp_incoming_slab = KMEM_CACHE(rds_tcp_incoming, 0);
>> if (!rds_tcp_incoming_slab)
>> return -ENOMEM;
>> return 0;
Powered by blists - more mailing lists