[dpdk-dev] [PATCH 4/4] net/vhost: add memory checking to support client mode

Zhiyong Yang zhiyong.yang at intel.com
Wed Feb 14 15:53:30 CET 2018


When vhost user PMD works in client mode to connect/reconnect virtio
user in server mode, new thread sometimes may run to new_device before
queue_setup has been done, So have to wait until memory allocation
is done.

Signed-off-by: Zhiyong Yang <zhiyong.yang at intel.com>
---
 drivers/net/vhost/rte_eth_vhost.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 3aae01c39..cd67bc7c5 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -580,6 +580,15 @@ new_device(int vid)
 		eth_dev->data->numa_node = newnode;
 #endif
 
+	/* The thread may run here before eth_dev->data->rx_queues or
+	 * eth_dev->data->tx_queues have gotten valid memory, so have to
+	 * wait until memory allocation is done.
+	 */
+	while (!eth_dev->data->rx_queues ||
+	       !eth_dev->data->tx_queues) {
+		;
+	}
+
 	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
 		vq = eth_dev->data->rx_queues[i];
 		if (vq == NULL)
-- 
2.13.3



More information about the dev mailing list