Skip to contentSkip to conversation

vhost: call rte_vhost_enable_guest_notification only on enabled queues

PATCH Applied Rich Lane 6 participants 11 messages Apr 7, 2016 – Apr 8, 2016 Network drivers

lore
Share & tools
lore

Rich Lane

author
#0 lore raw

PATCH 1/1 vhost: call rte_vhost_enable_guest_notification only on enabled queues

If the vhost PMD were configured with more queues than the guest, the old code would segfault in rte_vhost_enable_guest_notification due to a NULL virtqueue pointer.

Fixes ee584e9710b9 ("vhost: add driver on top of the library")
---
 drivers/net/vhost/rte_eth_vhost.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/vhost/rte_eth_vhost.c +3 -2
index b1eb082..310cbef 100644
@@ -265,7 +265,6 @@ new_device(struct virtio_net *dev)
 		vq->device = dev;
 		vq->internal = internal;
 		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq->virtqueue_id, 0);
 	}
 	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
 		vq = eth_dev->data->tx_queues[i];
@@ -274,9 +273,11 @@ new_device(struct virtio_net *dev)
 		vq->device = dev;
 		vq->internal = internal;
 		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq->virtqueue_id, 0);
 	}
 
+	for (i = 0; i < dev->virt_qp_nb * VIRTIO_QNUM; i++)
+		rte_vhost_enable_guest_notification(dev, i, 0);
+
 	dev->flags |= VIRTIO_DEV_RUNNING;
 	dev->priv = eth_dev;
 	eth_dev->data->dev_link.link_status = ETH_LINK_UP;
Signature · 1 line
1.9.1
Tested-by on v1 1/1
#1 lore raw
Quoted 38 lines

If the vhost PMD were configured with more queues than the guest, the old code would segfault in rte_vhost_enable_guest_notification due to a NULL virtqueue pointer.

Fixes ee584e9710b9 ("vhost: add driver on top of the library")
---
 drivers/net/vhost/rte_eth_vhost.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/vhost/rte_eth_vhost.c +0 -1
index b1eb082..310cbef 100644
@@ -265,7 +265,6 @@ new_device(struct virtio_net *dev)
 		vq->device = dev;
 		vq->internal = internal;
 		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq-
 >virtqueue_id, 0);
 	}
 	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
drivers/net/vhost/rte_eth_vhost.c +3 -1
 		vq = eth_dev->data->tx_queues[i];
@@ -274,9 +273,11 @@ new_device(struct virtio_net *dev)
 		vq->device = dev;
 		vq->internal = internal;
 		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq-
 >virtqueue_id, 0);
 	}
 
+	for (i = 0; i < dev->virt_qp_nb * VIRTIO_QNUM; i++)
+		rte_vhost_enable_guest_notification(dev, i, 0);
+
 	dev->flags |= VIRTIO_DEV_RUNNING;
 	dev->priv = eth_dev;
Quoted 3 lines

eth_dev->data->dev_link.link_status = ETH_LINK_UP;
--
1.9.1

I see the same issue, and verified that this patch solves it. Thanks!

Thanks,
Ciara

#2 lore raw
In reply to Rich Lane

Hi,

Quoted 25 lines · Rich Lane

If the vhost PMD were configured with more queues than the guest, the old code would segfault in rte_vhost_enable_guest_notification due to a NULL virtqueue pointer.

Fixes ee584e9710b9 ("vhost: add driver on top of the library")
---
  drivers/net/vhost/rte_eth_vhost.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/vhost/rte_eth_vhost.c +0 -1
index b1eb082..310cbef 100644
@@ -265,7 +265,6 @@ new_device(struct virtio_net *dev)
  		vq->device = dev;
  		vq->internal = internal;
  		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq->virtqueue_id, 0);
  	}
  	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
  		vq = eth_dev->data->tx_queues[i];
@@ -274,9 +273,11 @@ new_device(struct virtio_net *dev)
  		vq->device = dev;
  		vq->internal = internal;

drivers/net/vhost/rte_eth_vhost.c new_device(struct virtio_net *dev) · line 283

Quoted 10 lines
drivers/net/vhost/rte_eth_vhost.c +3 -1
  		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq->virtqueue_id, 0);
  	}
 
+	for (i = 0; i < dev->virt_qp_nb * VIRTIO_QNUM; i++)
+		rte_vhost_enable_guest_notification(dev, i, 0);
+
  	dev->flags |= VIRTIO_DEV_RUNNING;
  	dev->priv = eth_dev;
  	eth_dev->data->dev_link.link_status = ETH_LINK_UP;

Just one question, when qemu starts a vm, usually, only one queue is enabled, then only 1 tx and 1 rx are called rte_vhost_enable_guest_notification; but after system is up, we use "ethtool -K eth0 combined x" to enable multiqueues, there's no chance to call rte_vhost_enable_guest_notification for other queues, right?

Thanks,
Jianfeng

#3 lore raw
Quoted 34 lines · Rich Lane
Quoted 1 line

If the vhost PMD were configured with more queues than the guest, the

old

Review

Quoted 10 lines

code would segfault in rte_vhost_enable_guest_notification due to a NULL virtqueue pointer.

Fixes ee584e9710b9 ("vhost: add driver on top of the library")
---
  drivers/net/vhost/rte_eth_vhost.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/vhost/rte_eth_vhost.c

Quoted 20 lines

index b1eb082..310cbef 100644

drivers/net/vhost/rte_eth_vhost.c +0 -1
@@ -265,7 +265,6 @@ new_device(struct virtio_net *dev)
  		vq->device = dev;
  		vq->internal = internal;
  		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq-
 virtqueue_id, 0);
  	}
  	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
  		vq = eth_dev->data->tx_queues[i];
drivers/net/vhost/rte_eth_vhost.c +0 -1
@@ -274,9 +273,11 @@ new_device(struct virtio_net *dev)
  		vq->device = dev;
  		vq->internal = internal;
  		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq-
 virtqueue_id, 0);
  	}
 
Quoted 12 lines
Quoted 6 lines
drivers/net/vhost/rte_eth_vhost.c +3 -0
+	for (i = 0; i < dev->virt_qp_nb * VIRTIO_QNUM; i++)
+		rte_vhost_enable_guest_notification(dev, i, 0);
+
  	dev->flags |= VIRTIO_DEV_RUNNING;
  	dev->priv = eth_dev;
  	eth_dev->data->dev_link.link_status = ETH_LINK_UP;

Just one question, when qemu starts a vm, usually, only one queue is enabled, then only 1 tx and 1 rx are called rte_vhost_enable_guest_notification; but after system is up, we use "ethtool -K eth0 combined x" to enable multiqueues, there's no chance to call rte_vhost_enable_guest_notification for other queues, right?

As far as I know, virt_qp_nb will report the number of queues available, regardless of their state enabled/disabled. So for example if we have 4 queues, but only one enabled, virt_qp_nb should still = 4 and rte_vhost_enable_guest_notification() will be called for all of these queues.

Thanks,
Ciara

Quoted 3 lines

Thanks,
Jianfeng

#4 lore raw
Quoted 47 lines · Ciara
Quoted 34 lines · Rich Lane
Quoted 1 line

If the vhost PMD were configured with more queues than the guest, the

old

Review

Quoted 10 lines

code would segfault in rte_vhost_enable_guest_notification due to a NULL virtqueue pointer.

Fixes ee584e9710b9 ("vhost: add driver on top of the library")
---
  drivers/net/vhost/rte_eth_vhost.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/vhost/rte_eth_vhost.c

Quoted 20 lines

index b1eb082..310cbef 100644

drivers/net/vhost/rte_eth_vhost.c +0 -1
@@ -265,7 +265,6 @@ new_device(struct virtio_net *dev)
  		vq->device = dev;
  		vq->internal = internal;
  		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq-
 virtqueue_id, 0);
  	}
  	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
  		vq = eth_dev->data->tx_queues[i];
drivers/net/vhost/rte_eth_vhost.c +0 -1
@@ -274,9 +273,11 @@ new_device(struct virtio_net *dev)
  		vq->device = dev;
  		vq->internal = internal;
  		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq-
 virtqueue_id, 0);
  	}
 
Quoted 12 lines
Quoted 6 lines
drivers/net/vhost/rte_eth_vhost.c +3 -0
+	for (i = 0; i < dev->virt_qp_nb * VIRTIO_QNUM; i++)
+		rte_vhost_enable_guest_notification(dev, i, 0);
+
  	dev->flags |= VIRTIO_DEV_RUNNING;
  	dev->priv = eth_dev;
  	eth_dev->data->dev_link.link_status = ETH_LINK_UP;

Just one question, when qemu starts a vm, usually, only one queue is enabled, then only 1 tx and 1 rx are called rte_vhost_enable_guest_notification; but after system is up, we use "ethtool -K eth0 combined x" to enable multiqueues, there's no chance to call rte_vhost_enable_guest_notification for other queues, right?

Quoted 1 line

As far as I know, virt_qp_nb will report the number of queues available, regardless of their state enabled/disabled. So for example if we have 4 queues, but only one enabled, virt_qp_nb should still = 4 and rte_vhost_enable_guest_notification() will be called for all of these queues.

Yes.

	--yliu
#5 lore raw
In reply to Loftus, Ciara
Quoted 45 lines · Ciara
Quoted 34 lines · Rich Lane
Quoted 1 line

If the vhost PMD were configured with more queues than the guest, the

old

Review

Quoted 10 lines

code would segfault in rte_vhost_enable_guest_notification due to a NULL virtqueue pointer.

Fixes ee584e9710b9 ("vhost: add driver on top of the library")
---
   drivers/net/vhost/rte_eth_vhost.c | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/vhost/rte_eth_vhost.c

Quoted 20 lines

index b1eb082..310cbef 100644

drivers/net/vhost/rte_eth_vhost.c +0 -1
@@ -265,7 +265,6 @@ new_device(struct virtio_net *dev)
   		vq->device = dev;
   		vq->internal = internal;
   		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq-
 virtqueue_id, 0);
   	}
   	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
   		vq = eth_dev->data->tx_queues[i];
drivers/net/vhost/rte_eth_vhost.c +0 -1
@@ -274,9 +273,11 @@ new_device(struct virtio_net *dev)
   		vq->device = dev;
   		vq->internal = internal;
   		vq->port = eth_dev->data->port_id;
-		rte_vhost_enable_guest_notification(dev, vq-
 virtqueue_id, 0);
   	}
 
Quoted 11 lines
Quoted 6 lines
drivers/net/vhost/rte_eth_vhost.c +3 -0
+	for (i = 0; i < dev->virt_qp_nb * VIRTIO_QNUM; i++)
+		rte_vhost_enable_guest_notification(dev, i, 0);
+
   	dev->flags |= VIRTIO_DEV_RUNNING;
   	dev->priv = eth_dev;
   	eth_dev->data->dev_link.link_status = ETH_LINK_UP;

Just one question, when qemu starts a vm, usually, only one queue is enabled, then only 1 tx and 1 rx are called rte_vhost_enable_guest_notification; but after system is up, we use "ethtool -K eth0 combined x" to enable multiqueues, there's no chance to call rte_vhost_enable_guest_notification for other queues, right?

Quoted 1 line

As far as I know, virt_qp_nb will report the number of queues available, regardless of their state enabled/disabled. So for example if we have 4 queues, but only one enabled, virt_qp_nb should still = 4 and rte_vhost_enable_guest_notification() will be called for all of these queues.

Oh, yes. I failed to really get multiqueue configured right, which leads to the wrong conclusion. Sorry.

Thanks,
Jianfeng

Quoted 6 lines

Thanks,
Ciara

Quoted 2 lines

Thanks,
Jianfeng

#8 lore raw
Quoted 8 lines · Thomas Monjalon
Quoted 7 lines
Quoted 6 lines

If the vhost PMD were configured with more queues than the guest, the old code would segfault in rte_vhost_enable_guest_notification due to a NULL virtqueue pointer.

Fixes ee584e9710b9 ("vhost: add driver on top of the library")

Applied, thanks

Hi Rich and Yuanhan,

I am sorry for late reply. I was out of office yesterday. I've tested it also today, and seems to be good.

Thanks,
Tetsuya

#9 lore raw
Quoted 5 lines · Tetsuya Mukawa
Quoted 4 lines · Thomas Monjalon
Quoted 4 lines
Quoted 4 lines

If the vhost PMD were configured with more queues than the guest, the old code would segfault in rte_vhost_enable_guest_notification due to a NULL virtqueue pointer.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Fixes ee584e9710b9 ("vhost: add driver on top of the library")

Applied, thanks

Hi Rich and Yuanhan,

I am sorry for late reply. I was out of office yesterday.

Tetsuya, no worry! Man takes leaves, and isn't the reason we have 2 or more maintainers on some blocks? :)

	--yliu
Quoted 4 lines

I've tested it also today, and seems to be good.

Thanks,
Tetsuya

#10 lore raw
Quoted 9 lines · Yuanhan Liu
Quoted 8 lines · Tetsuya Mukawa
Quoted 7 lines · Thomas Monjalon
Quoted 7 lines
Quoted 6 lines

If the vhost PMD were configured with more queues than the guest, the old code would segfault in rte_vhost_enable_guest_notification due to a NULL virtqueue pointer.

Fixes ee584e9710b9 ("vhost: add driver on top of the library")
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Applied, thanks

Hi Rich and Yuanhan,

I am sorry for late reply. I was out of office yesterday.

Tetsuya, no worry! Man takes leaves, and isn't the reason we have 2 or more maintainers on some blocks? :)

	--yliu

Yeah, thanks!

Tetsuya