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

christian.ehrhardt at canonical.com christian.ehrhardt at canonical.com
Thu Jul 7 09:55:19 CEST 2022


Hi,

FYI, your patch has been queued to stable release 19.11.13

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/09/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/cpaelzer/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/cpaelzer/dpdk-stable-queue/commit/48e451fe409e603da6e21b72163cb53c25284dd1

Thanks.

Christian Ehrhardt <christian.ehrhardt at canonical.com>

---
>From 48e451fe409e603da6e21b72163cb53c25284dd1 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 35dcd84b8b..bb714a5c90 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -652,7 +652,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;
@@ -678,7 +678,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();
 	}
 
@@ -690,7 +690,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();
 	}
 }
@@ -772,7 +772,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);
 
@@ -802,7 +802,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;
 
@@ -863,7 +863,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");
@@ -1050,7 +1050,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;
 }
@@ -1061,7 +1061,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 	struct pmd_internal *internal = dev->data->dev_private;
 
 	rte_atomic32_set(&internal->started, 0);
-	update_queuing_status(dev);
+	update_queuing_status(dev, true);
 }
 
 static void
-- 
2.37.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-07-07 09:54:14.600465371 +0200
+++ 0084-net-vhost-fix-deadlock-on-vring-state-change.patch	2022-07-07 09:54:11.025824987 +0200
@@ -1 +1 @@
-From 193edd75a94fe8d0d633d1702109779fd7b7d6a0 Mon Sep 17 00:00:00 2001
+From 48e451fe409e603da6e21b72163cb53c25284dd1 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 35dcd84b8b..bb714a5c90 100644
@@ -29 +30 @@
-@@ -741,7 +741,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
+@@ -652,7 +652,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
@@ -38 +39 @@
-@@ -767,7 +767,7 @@ update_queuing_status(struct rte_eth_dev *dev)
+@@ -678,7 +678,7 @@ update_queuing_status(struct rte_eth_dev *dev)
@@ -47 +48 @@
-@@ -779,7 +779,7 @@ update_queuing_status(struct rte_eth_dev *dev)
+@@ -690,7 +690,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);
+@@ -772,7 +772,7 @@ new_device(int vid)
+ 	eth_dev->data->dev_link.link_status = ETH_LINK_UP;
@@ -65 +66 @@
-@@ -898,7 +898,7 @@ destroy_device(int vid)
+@@ -802,7 +802,7 @@ destroy_device(int vid)
@@ -72 +73 @@
- 	eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
+ 	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
@@ -74 +75 @@
-@@ -1008,7 +1008,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
+@@ -863,7 +863,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)
+@@ -1050,7 +1050,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
@@ -92 +93,2 @@
-@@ -1209,7 +1209,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
+@@ -1061,7 +1061,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
+ 	struct pmd_internal *internal = dev->data->dev_private;
@@ -94 +95,0 @@
- 	dev->data->dev_started = 0;
@@ -98,2 +98,0 @@
- 
- 	return 0;
@@ -100,0 +100,2 @@
+ 
+ static void


More information about the stable mailing list