* [PATCH] rds:Simplify the allocation of slab caches
@ 2024-06-17 7:54 Hongfu Li
2024-06-17 10:34 ` Zhu Yanjun
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Hongfu Li @ 2024-06-17 7:54 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, allison.henderson
Cc: netdev, linux-rdma, rds-devel, linux-kernel, Hongfu Li
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@kylinos.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);
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] rds:Simplify the allocation of slab caches
2024-06-17 7:54 [PATCH] rds:Simplify the allocation of slab caches Hongfu Li
@ 2024-06-17 10:34 ` Zhu Yanjun
2024-06-18 7:21 ` Hongfu Li
2024-06-18 14:15 ` Allison Henderson
2024-06-19 9:50 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Zhu Yanjun @ 2024-06-17 10:34 UTC (permalink / raw)
To: Hongfu Li, davem, edumazet, kuba, pabeni, allison.henderson
Cc: netdev, linux-rdma, rds-devel, linux-kernel
在 2024/6/17 15:54, Hongfu Li 写道:
> 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@kylinos.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)
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Thanks a lot.
Zhu Yanjun
> 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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] rds:Simplify the allocation of slab caches
2024-06-17 10:34 ` Zhu Yanjun
@ 2024-06-18 7:21 ` Hongfu Li
0 siblings, 0 replies; 5+ messages in thread
From: Hongfu Li @ 2024-06-18 7:21 UTC (permalink / raw)
To: yanjun.zhu
Cc: allison.henderson, davem, edumazet, kuba, lihongfu, linux-kernel,
linux-rdma, netdev, pabeni, rds-devel
>> 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@kylinos.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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rds:Simplify the allocation of slab caches
2024-06-17 7:54 [PATCH] rds:Simplify the allocation of slab caches Hongfu Li
2024-06-17 10:34 ` Zhu Yanjun
@ 2024-06-18 14:15 ` Allison Henderson
2024-06-19 9:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Allison Henderson @ 2024-06-18 14:15 UTC (permalink / raw)
To: lihongfu@kylinos.cn, davem@davemloft.net, kuba@kernel.org,
edumazet@google.com, pabeni@redhat.com
Cc: rds-devel@oss.oracle.com, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
On Mon, 2024-06-17 at 15:54 +0800, Hongfu Li wrote:
> 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@kylinos.cn>
This change looks simple enough to me. Thanks for the clean up.
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
> ---
> 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);
> 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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rds:Simplify the allocation of slab caches
2024-06-17 7:54 [PATCH] rds:Simplify the allocation of slab caches Hongfu Li
2024-06-17 10:34 ` Zhu Yanjun
2024-06-18 14:15 ` Allison Henderson
@ 2024-06-19 9:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-19 9:50 UTC (permalink / raw)
To: Hongfu Li
Cc: davem, edumazet, kuba, pabeni, allison.henderson, netdev,
linux-rdma, rds-devel, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Mon, 17 Jun 2024 15:54:35 +0800 you wrote:
> 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@kylinos.cn>
> ---
> net/rds/tcp.c | 4 +---
> net/rds/tcp_recv.c | 4 +---
> 2 files changed, 2 insertions(+), 6 deletions(-)
Here is the summary with links:
- rds:Simplify the allocation of slab caches
https://git.kernel.org/netdev/net-next/c/9f1f70dd8500
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-19 9:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-17 7:54 [PATCH] rds:Simplify the allocation of slab caches Hongfu Li
2024-06-17 10:34 ` Zhu Yanjun
2024-06-18 7:21 ` Hongfu Li
2024-06-18 14:15 ` Allison Henderson
2024-06-19 9:50 ` patchwork-bot+netdevbpf
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).