From: Shirley Ma <mashirle@us.ibm.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: David Miller <davem@davemloft.net>,
Eric Dumazet <eric.dumazet@gmail.com>,
Avi Kivity <avi@redhat.com>, Arnd Bergmann <arnd@arndb.de>,
netdev@vger.kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [TEST PATCH net-next] vhost: accumulate multiple used and sigal in vhost TX test
Date: Tue, 17 May 2011 13:46:21 -0700 [thread overview]
Message-ID: <1305665181.10756.29.camel@localhost.localdomain> (raw)
In-Reply-To: <1305646444.10756.16.camel@localhost.localdomain>
Hello Michael,
Here is the patch I used to test out of order before: add used in a pend
array, and swap the last two ids.
I used to hit an issue, but now it seems working well.
This won't impact zero-copy patch since we need to maintain the pend
used ids anyway.
Signed-off-by: Shirley Ma <xma@us.ibm.com>
---
drivers/vhost/net.c | 24 +++++++++++++++++++++++-
drivers/vhost/vhost.c | 11 +++++++++++
drivers/vhost/vhost.h | 1 +
3 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 2f7c76a..19e1baa 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -32,6 +32,8 @@
* Using this limit prevents one virtqueue from starving others. */
#define VHOST_NET_WEIGHT 0x80000
+#define VHOST_MAX_PEND 128
+
enum {
VHOST_NET_VQ_RX = 0,
VHOST_NET_VQ_TX = 1,
@@ -198,13 +200,33 @@ static void handle_tx(struct vhost_net *net)
if (err != len)
pr_debug("Truncated TX packet: "
" len %d != %zd\n", err, len);
- vhost_add_used_and_signal(&net->dev, vq, head, 0);
+ vq->heads[vq->pend_idx].id = head;
+ vq->heads[vq->pend_idx].len = 0;
+ ++vq->pend_idx;
+ if (vq->pend_idx >= VHOST_MAX_PEND) {
+ int id;
+ id = vq->heads[vq->pend_idx-1].id;
+ vq->heads[vq->pend_idx-1].id = vq->heads[vq->pend_idx-2].id;
+ vq->heads[vq->pend_idx-2].id = id;
+ vhost_add_used_and_signal_n(&net->dev, vq, vq->heads,
+ vq->pend_idx);
+ vq->pend_idx = 0;
+ }
total_len += len;
if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
vhost_poll_queue(&vq->poll);
break;
}
}
+ if (vq->pend_idx >= VHOST_MAX_PEND) {
+ int id;
+ id = vq->heads[vq->pend_idx-1].id;
+ vq->heads[vq->pend_idx-1].id = vq->heads[vq->pend_idx-2].id;
+ vq->heads[vq->pend_idx-2].id = id;
+ vhost_add_used_and_signal_n(&net->dev, vq, vq->heads,
+ vq->pend_idx);
+ vq->pend_idx = 0;
+ }
mutex_unlock(&vq->mutex);
}
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 2ab2912..7eea6b3 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -174,6 +174,7 @@ static void vhost_vq_reset(struct vhost_dev *dev,
vq->call_ctx = NULL;
vq->call = NULL;
vq->log_ctx = NULL;
+ vq->pend_idx = 0;
}
static int vhost_worker(void *data)
@@ -395,6 +396,11 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
vhost_poll_stop(&dev->vqs[i].poll);
vhost_poll_flush(&dev->vqs[i].poll);
}
+ if (dev->vqs[i].pend_idx != 0) {
+ vhost_add_used_and_signal_n(dev, &dev->vqs[i],
+ dev->vqs[i].heads, dev->vqs[i].pend_idx);
+ dev->vqs[i].pend_idx = 0;
+ }
if (dev->vqs[i].error_ctx)
eventfd_ctx_put(dev->vqs[i].error_ctx);
if (dev->vqs[i].error)
@@ -603,6 +609,11 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
mutex_lock(&vq->mutex);
+ if (vq->pend_idx != 0) {
+ vhost_add_used_and_signal_n(d, vq, vq->heads, vq->pend_idx);
+ vq->pend_idx = 0;
+ }
+
switch (ioctl) {
case VHOST_SET_VRING_NUM:
/* Resizing ring with an active backend?
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index b3363ae..44a412d 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -108,6 +108,7 @@ struct vhost_virtqueue {
/* Log write descriptors */
void __user *log_base;
struct vhost_log *log;
+ int pend_idx;
};
struct vhost_dev {
next prev parent reply other threads:[~2011-05-17 20:46 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-16 19:34 [PATCH V5 4/6 net-next] vhost: vhost TX zero-copy support Shirley Ma
2011-05-16 20:45 ` Michael S. Tsirkin
2011-05-16 20:56 ` Shirley Ma
2011-05-16 21:24 ` Michael S. Tsirkin
2011-05-16 21:30 ` Shirley Ma
2011-05-17 4:31 ` Shirley Ma
2011-05-17 5:55 ` Michael S. Tsirkin
2011-05-17 15:22 ` Shirley Ma
2011-05-17 15:28 ` Michael S. Tsirkin
2011-05-17 15:34 ` Shirley Ma
2011-05-17 20:46 ` Shirley Ma [this message]
2011-05-17 20:52 ` [TEST PATCH net-next] vhost: accumulate multiple used and sigal in vhost TX test Michael S. Tsirkin
2011-05-17 20:50 ` [PATCH V5 4/6 net-next] vhost: vhost TX zero-copy support Shirley Ma
2011-05-17 20:58 ` Michael S. Tsirkin
2011-05-17 21:01 ` Shirley Ma
2011-05-17 21:28 ` Michael S. Tsirkin
2011-05-17 22:21 ` Shirley Ma
2011-05-18 5:14 ` Shirley Ma
2011-05-18 6:16 ` [PATCH V6 " Shirley Ma
2011-05-18 8:43 ` Michael S. Tsirkin
2011-05-18 8:32 ` [PATCH V5 " Michael S. Tsirkin
2011-05-18 8:45 ` Michael S. Tsirkin
2011-05-16 21:27 ` Michael S. Tsirkin
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=1305665181.10756.29.camel@localhost.localdomain \
--to=mashirle@us.ibm.com \
--cc=arnd@arndb.de \
--cc=avi@redhat.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.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).