qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jon Kohler <jon@nutanix.com>
To: qemu-devel@nongnu.org
Cc: Jon Kohler <jon@nutanix.com>, Jason Wang <jasowang@redhat.com>
Subject: [PATCH] tap: introduce IFF_NAPI
Date: Tue, 30 May 2023 23:16:45 -0400	[thread overview]
Message-ID: <20230531031645.44335-1-jon@nutanix.com> (raw)

If kernel supports IFF_NAPI, lets use it, which is especially useful
on kernels containing fb3f903769e8 ("tun: support NAPI for packets
received from batched XDP buffs"), as IFF_NAPI allows the
vhost_tx_batch path to use NAPI on XDP buffs.

Benchmark w/ iperf -c (remote srv) -P (thread count) -l (stream size)
from a guest running kernel 5.10.105 to remote bare metal running
patched code on kernel 5.10.139. Guests were configured 1x virtio-net
device with 4x queues, resulting in 4x vhost-worker threads. Hosts are
identical with Intel ICX 4314 @ 2.4 GHz with Mellanox CX5 25GbE NIC ->
Arista 25GbE switch. vhost-worker threads largely maxed out on CPU on
"Before" and around ~50-60% utilization "After".

Single Stream: iperf -P 1
iperf -l size | Before          | After          | Increase
64B           | 593 Mbits/sec   | 712 Mbits/sec  | ~20%
128B          | 1.00 Gbits/sec  | 1.18 Gbits/sec | ~18%
4KB           | 17.6 Gbits/sec  | 22.7 Gbits/sec | ~29%

Multiple Stream: iperf -P 12
iperf -l size | Before          | After          | Increase
64B           | 6.35 Gbits/sec  | 7.78 Gbits/sec | ~23%
128B          | 10.8 Gbits/sec  | 14.2 Gbits/sec | ~31%
4KB           | 23.6 Gbits/sec  | 23.6 Gbits/sec | (line speed)

Signed-off-by: Jon Kohler <jon@nutanix.com>
---
 net/tap-linux.c | 4 ++++
 net/tap-linux.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/net/tap-linux.c b/net/tap-linux.c
index f54f308d359..fd94df166e0 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -62,6 +62,10 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
         ifr.ifr_flags |= IFF_ONE_QUEUE;
     }
 
+    if (features & IFF_NAPI) {
+        ifr.ifr_flags |= IFF_NAPI;
+    }
+
     if (*vnet_hdr) {
         if (features & IFF_VNET_HDR) {
             *vnet_hdr = 1;
diff --git a/net/tap-linux.h b/net/tap-linux.h
index bbbb62c2a75..f4d8e55270b 100644
--- a/net/tap-linux.h
+++ b/net/tap-linux.h
@@ -37,6 +37,7 @@
 
 /* TUNSETIFF ifr flags */
 #define IFF_TAP          0x0002
+#define IFF_NAPI         0x0010
 #define IFF_NO_PI        0x1000
 #define IFF_ONE_QUEUE    0x2000
 #define IFF_VNET_HDR     0x4000
-- 
2.30.1 (Apple Git-130)



             reply	other threads:[~2023-05-31  3:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31  3:16 Jon Kohler [this message]
2023-05-31  3:32 ` [PATCH] tap: introduce IFF_NAPI Jason Wang
2023-05-31  3:35   ` Jason Wang
2023-05-31  3:47     ` Jon Kohler
2023-05-31  3:55       ` Jason Wang
2023-05-31  5:27         ` Jason Wang
2023-05-31 13:46           ` Jon Kohler
2023-06-01  2:48             ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230531031645.44335-1-jon@nutanix.com \
    --to=jon@nutanix.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).