From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: netdev@vger.kernel.org
Cc: mst@redhat.com, jasowang@redhat.com,
Willem de Bruijn <willemb@google.com>
Subject: [PATCH RFC 3/3] vhost_net: support tun zerocopy stats
Date: Fri, 6 Oct 2017 18:25:16 -0400 [thread overview]
Message-ID: <20171006222516.90654-4-willemdebruijn.kernel@gmail.com> (raw)
In-Reply-To: <20171006222516.90654-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
Allow the tun device to intercept zerocopy completions to increment
its counters.
Pass an array of two struct ubuf_info to the device. The first is
initialized as usual and used to notify vhost_net. The second is
granted to the tun device for its callback.
Use the existing per-device ubuf_info pool, but take out two
elements at a time, so double the size.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
drivers/vhost/net.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 58585ec8699e..22988a7df656 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -47,6 +47,7 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"
/* MAX number of TX used buffers for outstanding zerocopy */
#define VHOST_MAX_PEND 128
#define VHOST_GOODCOPY_LEN 256
+#define UBUFLEN 2 /* Number of consecutive ubuf_info passed to tun */
/*
* For transmit, used buffer len is unused; we override it to track buffer
@@ -254,7 +255,7 @@ static int vhost_net_set_ubuf_info(struct vhost_net *n)
if (!zcopy)
continue;
n->vqs[i].ubuf_info = kmalloc(sizeof(*n->vqs[i].ubuf_info) *
- UIO_MAXIOV, GFP_KERNEL);
+ UIO_MAXIOV * UBUFLEN, GFP_KERNEL);
if (!n->vqs[i].ubuf_info)
goto err;
}
@@ -526,7 +527,7 @@ static void handle_tx(struct vhost_net *net)
/* use msg_control to pass vhost zerocopy ubuf info to skb */
if (zcopy_used) {
struct ubuf_info *ubuf;
- ubuf = nvq->ubuf_info + nvq->upend_idx;
+ ubuf = nvq->ubuf_info + (nvq->upend_idx * UBUFLEN);
vq->heads[nvq->upend_idx].id = cpu_to_vhost32(vq, head);
vq->heads[nvq->upend_idx].len = VHOST_DMA_IN_PROGRESS;
@@ -535,7 +536,7 @@ static void handle_tx(struct vhost_net *net)
ubuf->desc = nvq->upend_idx;
refcount_set(&ubuf->refcnt, 1);
msg.msg_control = ubuf;
- msg.msg_controllen = sizeof(ubuf);
+ msg.msg_controllen = sizeof(*ubuf) * UBUFLEN;
ubufs = nvq->ubufs;
atomic_inc(&ubufs->refcount);
nvq->upend_idx = (nvq->upend_idx + 1) % UIO_MAXIOV;
--
2.14.2.920.gcf0c67979c-goog
next prev parent reply other threads:[~2017-10-06 22:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 22:25 [PATCH RFC 0/3] tun zerocopy stats Willem de Bruijn
2017-10-06 22:25 ` [PATCH RFC 1/3] tun: ethtool stats Willem de Bruijn
2017-10-06 22:30 ` Stephen Hemminger
2017-10-06 22:37 ` Willem de Bruijn
2017-10-06 23:12 ` Stephen Hemminger
2017-10-06 23:26 ` David Miller
2017-10-06 22:25 ` [PATCH RFC 2/3] tun: expand ethtool stats with zerocopy Willem de Bruijn
2017-10-06 22:32 ` Willem de Bruijn
2017-10-06 22:25 ` Willem de Bruijn [this message]
2017-10-10 3:52 ` [PATCH RFC 0/3] tun zerocopy stats David Miller
2017-10-10 15:29 ` Willem de Bruijn
2017-10-10 17:23 ` Stephen Hemminger
2017-10-10 17:39 ` David Miller
2017-10-10 19:11 ` Willem de Bruijn
2017-10-11 3:15 ` Jason Wang
2017-10-11 21:44 ` Willem de Bruijn
2017-10-12 11:21 ` 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=20171006222516.90654-4-willemdebruijn.kernel@gmail.com \
--to=willemdebruijn.kernel@gmail.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/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).