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

Xueming Li xuemingl at nvidia.com
Wed Jul 20 10:21:27 CEST 2022


Hi,

FYI, your patch has been queued to stable release 20.11.6

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/22/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/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/fc9be6c79aebaa183e80f7faf2c7ff45114edcf8

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From fc9be6c79aebaa183e80f7faf2c7ff45114edcf8 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
Cc: Xueming Li <xuemingl at nvidia.com>

[ 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 2df516ec21..c994f2429b 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -715,7 +715,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;
@@ -741,7 +741,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();
 	}
 
@@ -753,7 +753,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();
 	}
 }
@@ -835,7 +835,7 @@ new_device(int vid)
 	eth_dev->data->dev_link.link_status = 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);
 
@@ -865,7 +865,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 = ETH_LINK_DOWN;
 
@@ -972,7 +972,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");
@@ -1159,7 +1159,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;
 }
@@ -1171,7 +1171,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.35.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-07-20 15:01:01.470868002 +0800
+++ 0058-net-vhost-fix-deadlock-on-vring-state-change.patch	2022-07-20 15:00:58.804333679 +0800
@@ -1 +1 @@
-From 193edd75a94fe8d0d633d1702109779fd7b7d6a0 Mon Sep 17 00:00:00 2001
+From fc9be6c79aebaa183e80f7faf2c7ff45114edcf8 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 193edd75a94fe8d0d633d1702109779fd7b7d6a0 ]
@@ -17 +19,0 @@
-Cc: stable at dpdk.org
@@ -26 +28 @@
-index d75d256040..7e512d94bf 100644
+index 2df516ec21..c994f2429b 100644
@@ -29 +31 @@
-@@ -741,7 +741,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
+@@ -715,7 +715,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
@@ -38 +40 @@
-@@ -767,7 +767,7 @@ update_queuing_status(struct rte_eth_dev *dev)
+@@ -741,7 +741,7 @@ update_queuing_status(struct rte_eth_dev *dev)
@@ -47 +49 @@
-@@ -779,7 +779,7 @@ update_queuing_status(struct rte_eth_dev *dev)
+@@ -753,7 +753,7 @@ update_queuing_status(struct rte_eth_dev *dev)
@@ -56,2 +58,2 @@
-@@ -868,7 +868,7 @@ new_device(int vid)
- 	vhost_dev_csum_configure(eth_dev);
+@@ -835,7 +835,7 @@ new_device(int vid)
+ 	eth_dev->data->dev_link.link_status = ETH_LINK_UP;
@@ -65 +67 @@
-@@ -898,7 +898,7 @@ destroy_device(int vid)
+@@ -865,7 +865,7 @@ destroy_device(int vid)
@@ -72 +74 @@
- 	eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
+ 	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
@@ -74 +76 @@
-@@ -1008,7 +1008,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
+@@ -972,7 +972,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
@@ -83 +85 @@
-@@ -1197,7 +1197,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
+@@ -1159,7 +1159,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
@@ -92 +94 @@
-@@ -1209,7 +1209,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
+@@ -1171,7 +1171,7 @@ eth_dev_stop(struct rte_eth_dev *dev)


More information about the stable mailing list