[PATCH ipsec-next] xfrm6_tunnel: Use KMEM_CACHE instead of kmem_cache_create

Kunwu Chan posted 1 patch 1 year, 11 months ago
net/ipv6/xfrm6_tunnel.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
[PATCH ipsec-next] xfrm6_tunnel: Use KMEM_CACHE instead of kmem_cache_create
Posted by Kunwu Chan 1 year, 11 months ago
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>
---
 net/ipv6/xfrm6_tunnel.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 1323f2f6928e..0f3df26878a3 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -355,10 +355,7 @@ static int __init xfrm6_tunnel_init(void)
 {
 	int rv;
 
-	xfrm6_tunnel_spi_kmem = kmem_cache_create("xfrm6_tunnel_spi",
-						  sizeof(struct xfrm6_tunnel_spi),
-						  0, SLAB_HWCACHE_ALIGN,
-						  NULL);
+	xfrm6_tunnel_spi_kmem = KMEM_CACHE(xfrm6_tunnel_spi, SLAB_HWCACHE_ALIGN);
 	if (!xfrm6_tunnel_spi_kmem)
 		return -ENOMEM;
 	rv = register_pernet_subsys(&xfrm6_tunnel_net_ops);
-- 
2.39.2
Re: [PATCH ipsec-next] xfrm6_tunnel: Use KMEM_CACHE() instead of kmem_cache_create()
Posted by Markus Elfring 1 year, 11 months ago
> Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
> to simplify the creation of SLAB caches.

I suggest to 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.

Regards,
Markus
Re: [PATCH ipsec-next] xfrm6_tunnel: Use KMEM_CACHE instead of kmem_cache_create
Posted by Steffen Klassert 1 year, 11 months ago
On Wed, Jan 24, 2024 at 02:31:50PM +0800, 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>

Applied, thanks a lot!