net/vhost: add queue status check
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
@@ -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
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
Signed-off-by Miao Li <[email protected]>--- drivers/net/vhost/rte_eth_vhost.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/vhost/rte_eth_vhost.c +0
-0
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
-0ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, &vhost_pmc);if (ret <0 )
Maxime
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
Signed-off-by Miao Li <[email protected]>---
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@@ -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 preventallow_queuingto become zero between the check and the call torte_vhost_get_monitor_addr?I think you need to implement the same logic as in
eth_vhost_rx(), i.e. checkallow_queueing, setwhile_queueing, checkallow_queueing, do your stuff and clearwhile_queuing.Quoted 4 lines
drivers/net/vhost/rte_eth_vhost.c +0
-0ret = rte_vhost_get_monitor_addr(vq->vid, vq->virtqueue_id, &vhost_pmc);if (ret < 0)
Maxime
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
Signed-off-by Miao Li <[email protected]>---
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--- a/drivers/net/vhost/rte_eth_vhost.cQuoted 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.cdrivers/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 preventallow_queuingto become zero between the check and the call torte_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. checkallow_queueing, setwhile_queueing, checkallow_queueing, do your stuff and clearwhile_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
-0ret = rte_vhost_get_monitor_addr(vq->vid, vq->virtqueue_id, &vhost_pmc);if (ret < 0)
Maxime
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 checkQuoted 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_addrwill return-EINVALwhen 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-EINVALbefore callrte_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
Signed-off-by Miao Li <[email protected]>--- 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--- a/drivers/net/vhost/rte_eth_vhost.cQuoted 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.cdrivers/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 preventallow_queuingto become zero between the check and the call torte_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. checkallow_queueing, setwhile_queueing, checkallow_queueing, do your stuff and clearwhile_queuing.I think the
while_queuingis unnecessary because we only read the value in vq and this API will only be called as a callback of RX.Thanks,
MiaoQuoted 7 lines
Quoted 7 lines
Quoted 5 lines
drivers/net/vhost/rte_eth_vhost.c +0
-0ret = rte_vhost_get_monitor_addr(vq->vid, vq->virtqueue_id, &vhost_pmc);if (ret < 0)
Maxime