Skip to contentSkip to conversation

net/vhost: add queue status check

PATCH In review Miao Li 2 participants 5 messages Nov 16, 2021 – Jan 31, 2022 Network drivers

lore
Share & tools
lore

Miao Li

author
#0 lore raw

PATCH 1/1 net/vhost: add queue status check

This patch adds queue status check to make sure that vhost monitor address will not be got until the link between backend and frontend up and the packets are allowed to be queued.

---
 drivers/net/vhost/rte_eth_vhost.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/vhost/rte_eth_vhost.c +2 -0
index 070f0e6dfd..9d600054d8 100644
@@ -1415,6 +1415,8 @@ vhost_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
 	int ret;
 	if (vq == NULL)
 		return -EINVAL;
+	if (unlikely(rte_atomic32_read(&vq->allow_queuing) == 0))
+		return -EINVAL;
 	ret = rte_vhost_get_monitor_addr(vq->vid, vq->virtqueue_id,
 			&vhost_pmc);
 	if (ret < 0)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Miao Li

This patch adds queue status check to make sure that vhost monitor address will not be got until the link between backend and frontend

s/got/gone/?

Quoted 1 line

up and the packets are allowed to be queued.

It needs a fixes tag.

Quoted 10 lines
---
  drivers/net/vhost/rte_eth_vhost.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/net/vhost/rte_eth_vhost.c +0 -0
index 070f0e6dfd..9d600054d8 100644

drivers/net/vhost/rte_eth_vhost.c vhost_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) · line 1419

Quoted 5 lines
drivers/net/vhost/rte_eth_vhost.c +2 -0
@@ -1415,6 +1415,8 @@ vhost_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
  	int ret;
  	if (vq == NULL)
  		return -EINVAL;
+	if (unlikely(rte_atomic32_read(&vq->allow_queuing) == 0))
+		return -EINVAL;

How does it help?
What does prevent allow_queuing to become zero between the check and the call to rte_vhost_get_monitor_addr?

I think you need to implement the same logic as in eth_vhost_rx(), i.e. check allow_queueing, set while_queueing, check allow_queueing, do your stuff and clear while_queuing.

drivers/net/vhost/rte_eth_vhost.c vhost_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) · line 1422

Quoted 4 lines
drivers/net/vhost/rte_eth_vhost.c +0 -0
  	ret = rte_vhost_get_monitor_addr(vq->vid, vq->virtqueue_id,
  			&vhost_pmc);
  	if (ret < 0)

Maxime

#2 lore raw
Quoted 15 lines · Maxime Coquelin
Quoted 2 lines · Miao Li

This patch adds queue status check to make sure that vhost monitor address will not be got until the link between backend and frontend

s/got/gone/?

Quoted 1 line

up and the packets are allowed to be queued.

It needs a fixes tag.

Quoted 5 lines

---
  drivers/net/vhost/rte_eth_vhost.c | 2 ++

  1 file changed, 2 insertions(+)
Quoted 11 lines

drivers/net/vhost/rte_eth_vhost.c vhost_get_monitor_addr(void *rx_queue, struct · line 1420

Quoted 11 lines
drivers/net/vhost/rte_eth_vhost.c +2 -0
index 070f0e6dfd..9d600054d8 100644
@@ -1415,6 +1415,8 @@ vhost_get_monitor_addr(void *rx_queue, struct 
 rte_power_monitor_cond *pmc)
       int ret;
       if (vq == NULL)
           return -EINVAL;
+    if (unlikely(rte_atomic32_read(&vq->allow_queuing) == 0))
+        return -EINVAL;

Also, EINVAL might not be the right return value here.

Quoted 14 lines

How does it help?
What does prevent allow_queuing to become zero between the check and the call to rte_vhost_get_monitor_addr?

I think you need to implement the same logic as in eth_vhost_rx(), i.e. check allow_queueing, set while_queueing, check allow_queueing, do your stuff and clear while_queuing.

Quoted 4 lines
drivers/net/vhost/rte_eth_vhost.c +0 -0
       ret = rte_vhost_get_monitor_addr(vq->vid, vq->virtqueue_id,
               &vhost_pmc);

      if (ret < 0)

Maxime

author
#3 lore raw

Hi

Quoted 9 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, November 16, 2021 5:36 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>
Subject: Re: [PATCH v1] net/vhost: add queue status check

Quoted 10 lines
Quoted 9 lines · Maxime Coquelin
Quoted 2 lines · Miao Li

This patch adds queue status check to make sure that vhost monitor address will not be got until the link between backend and frontend

s/got/gone/?

Quoted 1 line

up and the packets are allowed to be queued.

It needs a fixes tag.

If we don't add this check, rte_vhost_get_monitor_addr will return -EINVAL when check if dev is null. But before return, get_device() will be called and print error log "device not found". So we want to add this check and return -EINVAL before call rte_vhost_get_monitor_addr. If we don't add this check, the vhost monitor address will also not be got but vhost will print error log continuously. It have no function impact, so I think it is not a fix.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

---
  drivers/net/vhost/rte_eth_vhost.c | 2 ++

  1 file changed, 2 insertions(+)
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/vhost/rte_eth_vhost.c +0 -1
index 070f0e6dfd..9d600054d8 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
Quoted 8 lines

drivers/net/vhost/rte_eth_vhost.c vhost_get_monitor_addr(void *rx_queue, struct · line 1420

Quoted 8 lines

+++ b/drivers/net/vhost/rte_eth_vhost.c

drivers/net/vhost/rte_eth_vhost.c +2 -0
@@ -1415,6 +1415,8 @@ vhost_get_monitor_addr(void *rx_queue, struct
 rte_power_monitor_cond *pmc)
       int ret;
       if (vq == NULL)
           return -EINVAL;
+    if (unlikely(rte_atomic32_read(&vq->allow_queuing) == 0))
+        return -EINVAL;

Also, EINVAL might not be the right return value here.

I don't know which return value will be better. Do you have any suggestions? Thanks!

Quoted 4 lines
Quoted 4 lines

How does it help?
What does prevent allow_queuing to become zero between the check and the call to rte_vhost_get_monitor_addr?

This check will prevent vhost to print error log continuously.

Quoted 4 lines
Quoted 4 lines

I think you need to implement the same logic as in eth_vhost_rx(), i.e. check allow_queueing, set while_queueing, check allow_queueing, do your stuff and clear while_queuing.

I think the while_queuing is unnecessary because we only read the value in vq and this API will only be called as a callback of RX.

Thanks,
Miao

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
drivers/net/vhost/rte_eth_vhost.c +0 -0
       ret = rte_vhost_get_monitor_addr(vq->vid, vq->virtqueue_id,
               &vhost_pmc);

      if (ret < 0)

Maxime

#4 lore raw
Quoted 45 lines · Miao

Hi

Quoted 9 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, November 16, 2021 5:36 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>
Subject: Re: [PATCH v1] net/vhost: add queue status check

Quoted 10 lines
Quoted 9 lines · Maxime Coquelin
Quoted 2 lines · Miao Li

This patch adds queue status check to make sure that vhost monitor address will not be got until the link between backend and frontend

s/got/gone/?

Quoted 1 line

up and the packets are allowed to be queued.

It needs a fixes tag.

If we don't add this check, rte_vhost_get_monitor_addr will return -EINVAL when check if dev is null. But before return, get_device() will be called and print error log "device not found". So we want to add this check and return -EINVAL before call rte_vhost_get_monitor_addr. If we don't add this check, the vhost monitor address will also not be got but vhost will print error log continuously. It have no function impact, so I think it is not a fix.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
   drivers/net/vhost/rte_eth_vhost.c | 2 ++
   1 file changed, 2 insertions(+)
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/vhost/rte_eth_vhost.c +0 -1
index 070f0e6dfd..9d600054d8 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
Quoted 8 lines

drivers/net/vhost/rte_eth_vhost.c vhost_get_monitor_addr(void *rx_queue, struct · line 1420

Quoted 8 lines

+++ b/drivers/net/vhost/rte_eth_vhost.c

drivers/net/vhost/rte_eth_vhost.c +2 -0
@@ -1415,6 +1415,8 @@ vhost_get_monitor_addr(void *rx_queue, struct
 rte_power_monitor_cond *pmc)
       int ret;
       if (vq == NULL)
           return -EINVAL;
+    if (unlikely(rte_atomic32_read(&vq->allow_queuing) == 0))
+        return -EINVAL;

Also, EINVAL might not be the right return value here.

Quoted 8 lines

I don't know which return value will be better. Do you have any suggestions? Thanks!

Quoted 4 lines
Quoted 4 lines

How does it help?
What does prevent allow_queuing to become zero between the check and the call to rte_vhost_get_monitor_addr?

This check will prevent vhost to print error log continuously.

You mean, it will prevent it most of the time, as there is still a window where it can happen, if allow_queueing is set between is check and the call to rte_vhost_get_monitor_addr.

Quoted 18 lines
Quoted 4 lines
Quoted 4 lines

I think you need to implement the same logic as in eth_vhost_rx(), i.e. check allow_queueing, set while_queueing, check allow_queueing, do your stuff and clear while_queuing.

I think the while_queuing is unnecessary because we only read the value in vq and this API will only be called as a callback of RX.

Thanks,
Miao

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
drivers/net/vhost/rte_eth_vhost.c +0 -0
       ret = rte_vhost_get_monitor_addr(vq->vid, vq->virtqueue_id,
               &vhost_pmc);

      if (ret < 0)

Maxime