patch 'vhost: fix async access' has been queued to stable release 20.11.6

Xueming Li xuemingl at nvidia.com
Tue Jun 21 10:02:59 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 06/23/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/ee29f5fa6b16c19ab2d8cb1fdeffabe0b95f0aa2

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From ee29f5fa6b16c19ab2d8cb1fdeffabe0b95f0aa2 Mon Sep 17 00:00:00 2001
From: David Marchand <david.marchand at redhat.com>
Date: Fri, 17 Jun 2022 07:52:27 +0200
Subject: [PATCH] vhost: fix async access
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 2d47fd3dfb596d266b89d82c2c4b2351c3d6fe20 ]

vq->async accesses must be protected with vq->access_lock.

Fixes: eb666d24085f ("vhost: fix async unregister deadlock")
Fixes: 0c0935c5f794 ("vhost: allow to check in-flight packets for async vhost")

Signed-off-by: David Marchand <david.marchand at redhat.com>
Acked-by: Sunil Pai G <sunil.pai.g at intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/librte_vhost/vhost.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index e76929d81b..93f0aa240b 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -1697,31 +1697,26 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)
 	if (vq == NULL)
 		return ret;
 
-	ret = 0;
-
-	if (!vq->async_registered)
-		return ret;
-
 	if (!rte_spinlock_trylock(&vq->access_lock)) {
 		VHOST_LOG_CONFIG(ERR, "Failed to unregister async channel. "
 			"virt queue busy.\n");
-		return -1;
+		return ret;
 	}
 
-	if (vq->async_pkts_inflight_n) {
+	if (!vq->async_registered) {
+		ret = 0;
+	} else if (vq->async_pkts_inflight_n) {
 		VHOST_LOG_CONFIG(ERR, "Failed to unregister async channel. "
 			"async inflight packets must be completed before unregistration.\n");
-		ret = -1;
-		goto out;
-	}
-
-	vhost_free_async_mem(vq);
+	} else {
+		ret = 0;
+		vhost_free_async_mem(vq);
 
-	vq->async_ops.transfer_data = NULL;
-	vq->async_ops.check_completed_copies = NULL;
-	vq->async_registered = false;
+		vq->async_ops.transfer_data = NULL;
+		vq->async_ops.check_completed_copies = NULL;
+		vq->async_registered = false;
+	}
 
-out:
 	rte_spinlock_unlock(&vq->access_lock);
 
 	return ret;
-- 
2.35.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-06-21 15:37:54.254313139 +0800
+++ 0113-vhost-fix-async-access.patch	2022-06-21 15:37:49.237785294 +0800
@@ -1 +1 @@
-From 2d47fd3dfb596d266b89d82c2c4b2351c3d6fe20 Mon Sep 17 00:00:00 2001
+From ee29f5fa6b16c19ab2d8cb1fdeffabe0b95f0aa2 Mon Sep 17 00:00:00 2001
@@ -3 +3 @@
-Date: Mon, 11 Apr 2022 13:00:08 +0200
+Date: Fri, 17 Jun 2022 07:52:27 +0200
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 2d47fd3dfb596d266b89d82c2c4b2351c3d6fe20 ]
@@ -10 +12,0 @@
-Cc: stable at dpdk.org
@@ -16,2 +18,2 @@
- lib/vhost/vhost.c | 25 ++++++++++---------------
- 1 file changed, 10 insertions(+), 15 deletions(-)
+ lib/librte_vhost/vhost.c | 27 +++++++++++----------------
+ 1 file changed, 11 insertions(+), 16 deletions(-)
@@ -19,5 +21,5 @@
-diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
-index df0bb9d043..14863144f3 100644
---- a/lib/vhost/vhost.c
-+++ b/lib/vhost/vhost.c
-@@ -1753,27 +1753,23 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)
+diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
+index e76929d81b..93f0aa240b 100644
+--- a/lib/librte_vhost/vhost.c
++++ b/lib/librte_vhost/vhost.c
+@@ -1697,31 +1697,26 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)
@@ -29 +31 @@
--	if (!vq->async)
+-	if (!vq->async_registered)
@@ -33,2 +35,2 @@
- 		VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel, virtqueue busy.\n",
- 				dev->ifname);
+ 		VHOST_LOG_CONFIG(ERR, "Failed to unregister async channel. "
+ 			"virt queue busy.\n");
@@ -39,2 +41,2 @@
--	if (vq->async->pkts_inflight_n) {
-+	if (!vq->async) {
+-	if (vq->async_pkts_inflight_n) {
++	if (!vq->async_registered) {
@@ -42,4 +44,3 @@
-+	} else if (vq->async->pkts_inflight_n) {
- 		VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel.\n", dev->ifname);
- 		VHOST_LOG_CONFIG(ERR, "(%s) inflight packets must be completed before unregistration.\n",
- 			dev->ifname);
++	} else if (vq->async_pkts_inflight_n) {
+ 		VHOST_LOG_CONFIG(ERR, "Failed to unregister async channel. "
+ 			"async inflight packets must be completed before unregistration.\n");
@@ -47,0 +49,3 @@
+-	}
+-
+-	vhost_free_async_mem(vq);
@@ -49 +52,0 @@
-+		vhost_free_async_mem(vq);
@@ -51,10 +54 @@
- 	}
- 
--	vhost_free_async_mem(vq);
--out:
- 	rte_spinlock_unlock(&vq->access_lock);
- 
- 	return ret;
-@@ -1891,9 +1887,6 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)
- 	if (vq == NULL)
- 		return ret;
++		vhost_free_async_mem(vq);
@@ -62,9 +56,7 @@
--	if (!vq->async)
--		return ret;
--
- 	if (!rte_spinlock_trylock(&vq->access_lock)) {
- 		VHOST_LOG_CONFIG(DEBUG,
- 			"(%s) failed to check in-flight packets. virtqueue busy.\n",
-@@ -1901,7 +1894,9 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)
- 		return ret;
- 	}
+-	vq->async_ops.transfer_data = NULL;
+-	vq->async_ops.check_completed_copies = NULL;
+-	vq->async_registered = false;
++		vq->async_ops.transfer_data = NULL;
++		vq->async_ops.check_completed_copies = NULL;
++		vq->async_registered = false;
++	}
@@ -72,4 +64 @@
--	ret = vq->async->pkts_inflight_n;
-+	if (vq->async)
-+		ret = vq->async->pkts_inflight_n;
-+
+-out:


More information about the stable mailing list