summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireguard/main.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-06-04 17:17:34 +0200
committerDavid S. Miller <davem@davemloft.net>2021-06-04 23:25:14 +0200
commita4e9f8e3287c9eb6bf70df982870980dd3341863 (patch)
treed1b7068678c63f49dfec3df2ebe0570c9777baeb /drivers/net/wireguard/main.c
parentwireguard: use synchronize_net rather than synchronize_rcu (diff)
downloadlinux-a4e9f8e3287c9eb6bf70df982870980dd3341863.tar.xz
linux-a4e9f8e3287c9eb6bf70df982870980dd3341863.zip
wireguard: peer: allocate in kmem_cache
With deployments having upwards of 600k peers now, this somewhat heavy structure could benefit from more fine-grained allocations. Specifically, instead of using a 2048-byte slab for a 1544-byte object, we can now use 1544-byte objects directly, thus saving almost 25% per-peer, or with 600k peers, that's a savings of 303 MiB. This also makes wireguard's memory usage more transparent in tools like slabtop and /proc/slabinfo. Fixes: 8b5553ace83c ("wireguard: queueing: get rid of per-peer ring buffers") Suggested-by: Arnd Bergmann <arnd@arndb.de> Suggested-by: Matthew Wilcox <willy@infradead.org> Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireguard/main.c')
-rw-r--r--drivers/net/wireguard/main.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/net/wireguard/main.c b/drivers/net/wireguard/main.c
index 7a7d5f1a80fc..0a3ebfdac794 100644
--- a/drivers/net/wireguard/main.c
+++ b/drivers/net/wireguard/main.c
@@ -28,6 +28,10 @@ static int __init mod_init(void)
#endif
wg_noise_init();
+ ret = wg_peer_init();
+ if (ret < 0)
+ goto err_peer;
+
ret = wg_device_init();
if (ret < 0)
goto err_device;
@@ -44,6 +48,8 @@ static int __init mod_init(void)
err_netlink:
wg_device_uninit();
err_device:
+ wg_peer_uninit();
+err_peer:
return ret;
}
@@ -51,6 +57,7 @@ static void __exit mod_exit(void)
{
wg_genetlink_uninit();
wg_device_uninit();
+ wg_peer_uninit();
}
module_init(mod_init);