[PATCH ipsec-next] xfrm: Simplify the allocation of slab caches in xfrm_policy_init

Kunwu Chan posted 1 patch 1 year, 10 months ago
net/xfrm/xfrm_policy.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
[PATCH ipsec-next] xfrm: Simplify the allocation of slab caches in xfrm_policy_init
Posted by Kunwu Chan 1 year, 10 months ago
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>
---
 net/xfrm/xfrm_policy.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 7351f32052dc..6ac97e0b66cb 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -4025,10 +4025,7 @@ static int __net_init xfrm_policy_init(struct net *net)
 	int dir, err;
 
 	if (net_eq(net, &init_net)) {
-		xfrm_dst_cache = kmem_cache_create("xfrm_dst_cache",
-					   sizeof(struct xfrm_dst),
-					   0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
-					   NULL);
+		xfrm_dst_cache = KMEM_CACHE(xfrm_dst, SLAB_HWCACHE_ALIGN | SLAB_PANIC);
 		err = rhashtable_init(&xfrm_policy_inexact_table,
 				      &xfrm_pol_inexact_params);
 		BUG_ON(err);
-- 
2.39.2
Re: [PATCH ipsec-next] xfrm: Simplify the allocation of slab caches in xfrm_policy_init
Posted by Steffen Klassert 1 year, 10 months ago
On Tue, Jan 30, 2024 at 04:14:11PM +0800, 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
> to simplify the creation of SLAB caches.
> 
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>

Applied to ipsec-next, thanks!