patch 'net/vhost: fix deadlock on vring state change' has been queued to stable release 21.11.2

luca.boccassi at gmail.com luca.boccassi at gmail.com
Wed Jul 6 22:34:48 CEST 2022


Hi,

FYI, your patch has been queued to stable release 21.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/08/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/5991d25b7489739b2b8d7c9af1c264f6a7f2988d

Thanks.

Luca Boccassi

---
>From 5991d25b7489739b2b8d7c9af1c264f6a7f2988d Mon Sep 17 00:00:00 2001
From: Yuan Wang <yuanx.wang at intel.com>
Date: Mon, 27 Jun 2022 13:51:25 +0800
Subject: [PATCH] net/vhost: fix deadlock on vring state change

[ upstream commit 193edd75a94fe8d0d633d1702109779fd7b7d6a0 ]

If vring state changes after pmd starts working, the locked vring
notifies pmd, thus calling update_queuing_status(), the latter
will wait for pmd to finish accessing vring, while pmd is also
waiting for vring to be unlocked, thus causing deadlock.

Actually, update_queuing_status() only needs to wait while
destroy/stopping the device, but not in other cases.

This patch adds a flag for whether or not to wait to fix this issue.

Fixes: 1ce3c7fe149f ("net/vhost: emulate device start/stop behavior")

Signed-off-by: Yuan Wang <yuanx.wang at intel.com>
Reviewed-by: Chenbo Xia <chenbo.xia at intel.com>
---
 drivers/net/vhost/rte_eth_vhost.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index a248a65df4..a280e788fb 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -716,7 +716,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
 }
 
 static void
-update_queuing_status(struct rte_eth_dev *dev)
+update_queuing_status(struct rte_eth_dev *dev, bool wait_queuing)
 {
 	struct pmd_internal *internal = dev->data->dev_private;
 	struct vhost_queue *vq;
@@ -742,7 +742,7 @@ update_queuing_status(struct rte_eth_dev *dev)
 			rte_atomic32_set(&vq->allow_queuing, 1);
 		else
 			rte_atomic32_set(&vq->allow_queuing, 0);
-		while (rte_atomic32_read(&vq->while_queuing))
+		while (wait_queuing && rte_atomic32_read(&vq->while_queuing))
 			rte_pause();
 	}
 
@@ -754,7 +754,7 @@ update_queuing_status(struct rte_eth_dev *dev)
 			rte_atomic32_set(&vq->allow_queuing, 1);
 		else
 			rte_atomic32_set(&vq->allow_queuing, 0);
-		while (rte_atomic32_read(&vq->while_queuing))
+		while (wait_queuing && rte_atomic32_read(&vq->while_queuing))
 			rte_pause();
 	}
 }
@@ -836,7 +836,7 @@ new_device(int vid)
 	eth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP;
 
 	rte_atomic32_set(&internal->dev_attached, 1);
-	update_queuing_status(eth_dev);
+	update_queuing_status(eth_dev, false);
 
 	VHOST_LOG(INFO, "Vhost device %d created\n", vid);
 
@@ -866,7 +866,7 @@ destroy_device(int vid)
 	internal = eth_dev->data->dev_private;
 
 	rte_atomic32_set(&internal->dev_attached, 0);
-	update_queuing_status(eth_dev);
+	update_queuing_status(eth_dev, true);
 
 	eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
 
@@ -976,7 +976,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
 	state->max_vring = RTE_MAX(vring, state->max_vring);
 	rte_spinlock_unlock(&state->lock);
 
-	update_queuing_status(eth_dev);
+	update_queuing_status(eth_dev, false);
 
 	VHOST_LOG(INFO, "vring%u is %s\n",
 			vring, enable ? "enabled" : "disabled");
@@ -1163,7 +1163,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
 	}
 
 	rte_atomic32_set(&internal->started, 1);
-	update_queuing_status(eth_dev);
+	update_queuing_status(eth_dev, false);
 
 	return 0;
 }
@@ -1175,7 +1175,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 
 	dev->data->dev_started = 0;
 	rte_atomic32_set(&internal->started, 0);
-	update_queuing_status(dev);
+	update_queuing_status(dev, true);
 
 	return 0;
 }
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-07-06 21:07:54.015964700 +0100
+++ 0013-net-vhost-fix-deadlock-on-vring-state-change.patch	2022-07-06 21:07:53.543518707 +0100
@@ -1 +1 @@
-From 193edd75a94fe8d0d633d1702109779fd7b7d6a0 Mon Sep 17 00:00:00 2001
+From 5991d25b7489739b2b8d7c9af1c264f6a7f2988d Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 193edd75a94fe8d0d633d1702109779fd7b7d6a0 ]
+
@@ -17 +18,0 @@
-Cc: stable at dpdk.org
@@ -26 +27 @@
-index d75d256040..7e512d94bf 100644
+index a248a65df4..a280e788fb 100644
@@ -29 +30 @@
-@@ -741,7 +741,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
+@@ -716,7 +716,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
@@ -38 +39 @@
-@@ -767,7 +767,7 @@ update_queuing_status(struct rte_eth_dev *dev)
+@@ -742,7 +742,7 @@ update_queuing_status(struct rte_eth_dev *dev)
@@ -47 +48 @@
-@@ -779,7 +779,7 @@ update_queuing_status(struct rte_eth_dev *dev)
+@@ -754,7 +754,7 @@ update_queuing_status(struct rte_eth_dev *dev)
@@ -56,2 +57,2 @@
-@@ -868,7 +868,7 @@ new_device(int vid)
- 	vhost_dev_csum_configure(eth_dev);
+@@ -836,7 +836,7 @@ new_device(int vid)
+ 	eth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP;
@@ -65 +66 @@
-@@ -898,7 +898,7 @@ destroy_device(int vid)
+@@ -866,7 +866,7 @@ destroy_device(int vid)
@@ -74 +75 @@
-@@ -1008,7 +1008,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
+@@ -976,7 +976,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
@@ -83 +84 @@
-@@ -1197,7 +1197,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
+@@ -1163,7 +1163,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
@@ -92 +93 @@
-@@ -1209,7 +1209,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
+@@ -1175,7 +1175,7 @@ eth_dev_stop(struct rte_eth_dev *dev)


More information about the stable mailing list