From: Shirley Ma <mashirle@us.ibm.com>
To: mst@redhat.com
Cc: David Miller <davem@davemloft.net>,
netdev@vger.kernel.org, jasowang@redhat.com
Subject: [PATCH V2] vhost: fix check for # of outstanding buffers
Date: Wed, 20 Jul 2011 10:23:12 -0700 [thread overview]
Message-ID: <1311182592.8573.45.camel@localhost.localdomain> (raw)
Fix the check for number of outstanding buffers returns incorrect
results due to vq->pend_idx wrap around;
Signed-off-by: Shirley Ma <xma@us.ibm.com>
---
drivers/vhost/net.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 70ac604..946a71e 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -182,15 +182,21 @@ static void handle_tx(struct vhost_net *net)
break;
/* Nothing new? Wait for eventfd to tell us they refilled. */
if (head == vq->num) {
+ int num_pends;
+
wmem = atomic_read(&sock->sk->sk_wmem_alloc);
if (wmem >= sock->sk->sk_sndbuf * 3 / 4) {
tx_poll_start(net, sock);
set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
break;
}
- /* If more outstanding DMAs, queue the work */
- if (unlikely(vq->upend_idx - vq->done_idx >
- VHOST_MAX_PEND)) {
+ /* If more outstanding DMAs, queue the work
+ * handle upend_idx wrap around
+ */
+ num_pends = (vq->upend_idx >= vq->done_idx) ?
+ (vq->upend_idx - vq->done_idx) :
+ (vq->upend_idx + UIO_MAXIOV - vq->done_idx);
+ if (unlikely(num_pends > VHOST_MAX_PEND)) {
tx_poll_start(net, sock);
set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
break;
next reply other threads:[~2011-07-20 17:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-20 17:23 Shirley Ma [this message]
2011-07-21 8:06 ` [PATCH V2] vhost: fix check for # of outstanding buffers Michael S. Tsirkin
2011-07-21 16:12 ` Shirley Ma
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=1311182592.8573.45.camel@localhost.localdomain \
--to=mashirle@us.ibm.com \
--cc=davem@davemloft.net \
--cc=jasowang@redhat.com \
--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).