Development discussion of WireGuard
 help / color / mirror / Atom feed
* [PATCH] Enabling Threaded NAPI by Default
@ 2024-09-10  6:33 Mirco Barone
  0 siblings, 0 replies; only message in thread
From: Mirco Barone @ 2024-09-10  6:33 UTC (permalink / raw)
  To: wireguard

Hi everyone,


While testing Wireguard with a large number of tunnels, we noticed a
bottleneck caused by the superimposition of multiple NAPI functions on
the same CPU core, hence preventing the system to scale effectively.
More details are described in this paper on page 3:
https://netdevconf.info/0x18/docs/netdev-0x18-paper23-talk-paper.pdf


Since each peer has its own NAPI struct, the problem can potentially
occur when many peers are created on the same machine. The simple
solution we found is to enable threaded NAPI, which improves
considerably the throughput in our testing conditions while, at the
same time, showing no drawbacks in case of traditional deployment
scenarios (i.e., single tunnel). Hence, we feel we could slightly
modify the code and move to threaded NAPI as the new default.


Any comment?

The option to revert to NAPI handled by a softirq is still preserved,
by simply changing the `/sys/class/net/<iface>/threaded` flag.

diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c

old mode 100644

new mode 100755

index 3feb36ee5bfb..60554b7c405a

--- a/drivers/net/wireguard/device.c

+++ b/drivers/net/wireguard/device.c

@@ -363,6 +363,8 @@ static int wg_newlink(struct net *src_net, struct
net_device *dev,

        ret = wg_ratelimiter_init();

        if (ret < 0)

                goto err_free_handshake_queue;

+

+       dev_set_threaded(dev,true);


        ret = register_netdevice(dev);

        if (ret < 0)



Kind regards

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Privo di virus.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-11-18 14:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-10  6:33 [PATCH] Enabling Threaded NAPI by Default Mirco Barone

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).