[PATCH] Enabling Threaded NAPI by Default

Mirco Barone mirco.barone.3 at gmail.com
Tue Sep 10 06:34:06 UTC 2024


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>


More information about the WireGuard mailing list