Skip to content

Commit

Permalink
Merge branch 'net-kmem-cache-create'
Browse files Browse the repository at this point in the history
Kunwu Chan says:

====================
net: Use KMEM_CACHE instead of kmem_cache_create

As Jiri Pirko suggests,
I'm using a patchset to cleanup the same issues in the 'net' module.
Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
to simplify the creation of SLAB caches.

Some cache names are changed to be the same as struct names.
This change is recorded in the changelog for easy reference.
It's harmless cause it's used in /proc/slabinfo to identify this cache.
---
Changes in v2:
	- Delete a patch as Eric said in https://lore.kernel.org/all/CANn89iLkWvum6wSqSya_K+1eqnFvp=L2WLW=kAYrZTF8Ei4b7g@mail.gmail.com/
	- No code changes,only add Reviewed-by tag
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Feb 21, 2024
2 parents a381690 + 072f88c commit 5d8956a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
5 changes: 1 addition & 4 deletions net/ipv4/ipmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3139,10 +3139,7 @@ int __init ip_mr_init(void)
{
int err;

mrt_cachep = kmem_cache_create("ip_mrt_cache",
sizeof(struct mfc_cache),
0, SLAB_HWCACHE_ALIGN | SLAB_PANIC,
NULL);
mrt_cachep = KMEM_CACHE(mfc_cache, SLAB_HWCACHE_ALIGN | SLAB_PANIC);

err = register_pernet_subsys(&ipmr_net_ops);
if (err)
Expand Down
5 changes: 2 additions & 3 deletions net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -3693,9 +3693,8 @@ int __init ip_rt_init(void)
panic("IP: failed to allocate ip_rt_acct\n");
#endif

ipv4_dst_ops.kmem_cachep =
kmem_cache_create("ip_dst_cache", sizeof(struct rtable), 0,
SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
ipv4_dst_ops.kmem_cachep = KMEM_CACHE(rtable,
SLAB_HWCACHE_ALIGN | SLAB_PANIC);

ipv4_dst_blackhole_ops.kmem_cachep = ipv4_dst_ops.kmem_cachep;

Expand Down
6 changes: 2 additions & 4 deletions net/ipv6/ip6_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2493,10 +2493,8 @@ int __init fib6_init(void)
{
int ret = -ENOMEM;

fib6_node_kmem = kmem_cache_create("fib6_nodes",
sizeof(struct fib6_node), 0,
SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT,
NULL);
fib6_node_kmem = KMEM_CACHE(fib6_node,
SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT);
if (!fib6_node_kmem)
goto out;

Expand Down
5 changes: 1 addition & 4 deletions net/ipv6/ip6mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,10 +1373,7 @@ int __init ip6_mr_init(void)
{
int err;

mrt_cachep = kmem_cache_create("ip6_mrt_cache",
sizeof(struct mfc6_cache),
0, SLAB_HWCACHE_ALIGN,
NULL);
mrt_cachep = KMEM_CACHE(mfc6_cache, SLAB_HWCACHE_ALIGN);
if (!mrt_cachep)
return -ENOMEM;

Expand Down
8 changes: 2 additions & 6 deletions net/kcm/kcmsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1878,15 +1878,11 @@ static int __init kcm_init(void)
{
int err = -ENOMEM;

kcm_muxp = kmem_cache_create("kcm_mux_cache",
sizeof(struct kcm_mux), 0,
SLAB_HWCACHE_ALIGN, NULL);
kcm_muxp = KMEM_CACHE(kcm_mux, SLAB_HWCACHE_ALIGN);
if (!kcm_muxp)
goto fail;

kcm_psockp = kmem_cache_create("kcm_psock_cache",
sizeof(struct kcm_psock), 0,
SLAB_HWCACHE_ALIGN, NULL);
kcm_psockp = KMEM_CACHE(kcm_psock, SLAB_HWCACHE_ALIGN);
if (!kcm_psockp)
goto fail;

Expand Down

0 comments on commit 5d8956a

Please sign in to comment.