Skip to contentSkip to conversation

vhost: correctly check the iova range when waking virtqueue

PATCH In review Jason Wang 4 participants 7 messages Aug 24, 2018 – Aug 26, 2018

Subsystems (5)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 vhost: correctly check the iova range when waking virtqueue

We don't wakeup the virtqueue if the first byte of pending iova range is the last byte of the range we just got updated. This will lead a virtqueue to wait for IOTLB updating forever. Fixing by correct the check and wake up the virtqueue in this case.

Fixes 6b1e6cc7855b ("vhost: new device IOTLB API")

---
The patch is needed for -stable.

---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +1 -1
index 96c1d8400822..b13c6b4b2c66 100644
@@ -952,7 +952,7 @@ static void vhost_iotlb_notify_vq(struct vhost_dev *d,
 	list_for_each_entry_safe(node, n, &d->pending_list, node) {
 		struct vhost_iotlb_msg *vq_msg = &node->msg.iotlb;
 		if (msg->iova <= vq_msg->iova &&
-		    msg->iova + msg->size - 1 > vq_msg->iova &&
+		    msg->iova + msg->size - 1 >= vq_msg->iova &&
 		    vq_msg->type == VHOST_IOTLB_MISS) {
 			vhost_poll_queue(&node->vq->poll);
 			list_del(&node->node);
Signature · 1 line
2.17.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jason Wang

We don't wakeup the virtqueue if the first byte of pending iova range is the last byte of the range we just got updated. This will lead a virtqueue to wait for IOTLB updating forever. Fixing by correct the check and wake up the virtqueue in this case.

Fixes 6b1e6cc7855b ("vhost: new device IOTLB API")

Without this patch, this command will trigger the IO hang merely every time from host to guest:

netperf -H 1.2.3.4 -l 5 -t TCP_RR -- -b 100

After applying, I can run it 10 times continuously without a problem.

Thanks,

Signature · 1 line
Peter Xu
Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Jason Wang
Quoted 8 lines · Jason Wang

We don't wakeup the virtqueue if the first byte of pending iova range is the last byte of the range we just got updated. This will lead a virtqueue to wait for IOTLB updating forever. Fixing by correct the check and wake up the virtqueue in this case.

Fixes 6b1e6cc7855b ("vhost: new device IOTLB API")

Without this patch, this command will trigger the IO hang merely every time from host to guest:

netperf -H 1.2.3.4 -l 5 -t TCP_RR -- -b 100

After applying, I can run it 10 times continuously without a problem.

Thanks,

Signature · 1 line
Peter Xu
maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Jason Wang
Quoted 8 lines · Jason Wang

We don't wakeup the virtqueue if the first byte of pending iova range is the last byte of the range we just got updated. This will lead a virtqueue to wait for IOTLB updating forever. Fixing by correct the check and wake up the virtqueue in this case.

Fixes 6b1e6cc7855b ("vhost: new device IOTLB API")
Quoted 21 lines

---
The patch is needed for -stable.

---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +1 -1
index 96c1d8400822..b13c6b4b2c66 100644
@@ -952,7 +952,7 @@ static void vhost_iotlb_notify_vq(struct vhost_dev *d,
 	list_for_each_entry_safe(node, n, &d->pending_list, node) {
 		struct vhost_iotlb_msg *vq_msg = &node->msg.iotlb;
 		if (msg->iova <= vq_msg->iova &&
-		    msg->iova + msg->size - 1 > vq_msg->iova &&
+		    msg->iova + msg->size - 1 >= vq_msg->iova &&
 		    vq_msg->type == VHOST_IOTLB_MISS) {
 			vhost_poll_queue(&node->vq->poll);
 			list_del(&node->node);
Signature · 1 line
2.17.1
maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Jason Wang
Quoted 8 lines · Jason Wang

We don't wakeup the virtqueue if the first byte of pending iova range is the last byte of the range we just got updated. This will lead a virtqueue to wait for IOTLB updating forever. Fixing by correct the check and wake up the virtqueue in this case.

Fixes 6b1e6cc7855b ("vhost: new device IOTLB API")
Quoted 21 lines

---
The patch is needed for -stable.

---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +1 -1
index 96c1d8400822..b13c6b4b2c66 100644
@@ -952,7 +952,7 @@ static void vhost_iotlb_notify_vq(struct vhost_dev *d,
 	list_for_each_entry_safe(node, n, &d->pending_list, node) {
 		struct vhost_iotlb_msg *vq_msg = &node->msg.iotlb;
 		if (msg->iova <= vq_msg->iova &&
-		    msg->iova + msg->size - 1 > vq_msg->iova &&
+		    msg->iova + msg->size - 1 >= vq_msg->iova &&
 		    vq_msg->type == VHOST_IOTLB_MISS) {
 			vhost_poll_queue(&node->vq->poll);
 			list_del(&node->node);
Signature · 1 line
2.17.1
maintainer
#5 lore raw
In reply to Jason Wang

From: Jason Wang <[email protected]>
Date: Fri, 24 Aug 2018 16:53:13 +0800

Quoted 10 lines

We don't wakeup the virtqueue if the first byte of pending iova range is the last byte of the range we just got updated. This will lead a virtqueue to wait for IOTLB updating forever. Fixing by correct the check and wake up the virtqueue in this case.

Fixes 6b1e6cc7855b ("vhost: new device IOTLB API")

---
The patch is needed for -stable.

Applied and queued up for -stable, thanks Jason.

maintainer
#6 lore raw
In reply to Jason Wang

From: Jason Wang <[email protected]>
Date: Fri, 24 Aug 2018 16:53:13 +0800

Quoted 10 lines

We don't wakeup the virtqueue if the first byte of pending iova range is the last byte of the range we just got updated. This will lead a virtqueue to wait for IOTLB updating forever. Fixing by correct the check and wake up the virtqueue in this case.

Fixes 6b1e6cc7855b ("vhost: new device IOTLB API")

---
The patch is needed for -stable.

Applied and queued up for -stable, thanks Jason.