[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1311182592.8573.45.camel@localhost.localdomain>
Date: Wed, 20 Jul 2011 10:23:12 -0700
From: Shirley Ma <mashirle@...ibm.com>
To: mst@...hat.com
Cc: David Miller <davem@...emloft.net>, netdev@...r.kernel.org,
jasowang@...hat.com
Subject: [PATCH V2] vhost: fix check for # of outstanding buffers
Fix the check for number of outstanding buffers returns incorrect
results due to vq->pend_idx wrap around;
Signed-off-by: Shirley Ma <xma@...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;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists