[dpdk-stable] patch 'vhost: fix deadlock on port deletion' has been queued to LTS release 18.11.7

Kevin Traynor ktraynor at redhat.com
Fri Feb 14 18:02:57 CET 2020


Hi,

FYI, your patch has been queued to LTS release 18.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/20/20. 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-queue

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

Thanks.

Kevin.

---
>From c21000078301fe353500546d53ef6d53bc1c5c05 Mon Sep 17 00:00:00 2001
From: Maxime Coquelin <maxime.coquelin at redhat.com>
Date: Tue, 14 Jan 2020 19:53:57 +0100
Subject: [PATCH] vhost: fix deadlock on port deletion

[ upstream commit 5efb18e85f7fdb436d3e56591656051c16802066 ]

If the vhost-user application (e.g. OVS) deletes the vhost-user
port while Qemu sends a vhost-user request, a deadlock can
happen if the request handler tries to acquire vhost-user's
global mutex, which is also locked by the vhost-user port
deletion API (rte_vhost_driver_unregister).

This patch prevents the deadlock by making
rte_vhost_driver_unregister() to release the mutex and try
again if a request is being handled to give a chance to
the request handler to complete.

Fixes: 8b4b949144b8 ("vhost: fix dead lock on closing in server mode")
Fixes: 5fbb3941da9f ("vhost: introduce driver features related APIs")

Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Reviewed-by: Tiwei Bie <tiwei.bie at intel.com>
Acked-by: Eelco Chaudron <echaudro at redhat.com>
---
 lib/librte_vhost/socket.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 27bfd21fc4..ea2fdb5529 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -999,7 +999,8 @@ again:
 
 				/*
-				 * If r/wcb is executing, release the
-				 * conn_mutex lock, and try again since
-				 * the r/wcb may use the conn_mutex lock.
+				 * If r/wcb is executing, release vsocket's
+				 * conn_mutex and vhost_user's mutex locks, and
+				 * try again since the r/wcb may use the
+				 * conn_mutex and mutex locks.
 				 */
 				if (fdset_try_del(&vhost_user.fdset,
@@ -1022,6 +1023,15 @@ again:
 
 			if (vsocket->is_server) {
-				fdset_del(&vhost_user.fdset,
-						vsocket->socket_fd);
+				/*
+				 * If r/wcb is executing, release vhost_user's
+				 * mutex lock, and try again since the r/wcb
+				 * may use the mutex lock.
+				 */
+				if (fdset_try_del(&vhost_user.fdset,
+						vsocket->socket_fd) == -1) {
+					pthread_mutex_unlock(&vhost_user.mutex);
+					goto again;
+				}
+
 				close(vsocket->socket_fd);
 				unlink(path);
-- 
2.21.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-02-14 17:02:37.224255194 +0000
+++ 0003-vhost-fix-deadlock-on-port-deletion.patch	2020-02-14 17:02:36.909408814 +0000
@@ -1 +1 @@
-From 5efb18e85f7fdb436d3e56591656051c16802066 Mon Sep 17 00:00:00 2001
+From c21000078301fe353500546d53ef6d53bc1c5c05 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 5efb18e85f7fdb436d3e56591656051c16802066 ]
+
@@ -19 +20,0 @@
-Cc: stable at dpdk.org
@@ -29 +30 @@
-index 8bc1e3a03c..9740fb3403 100644
+index 27bfd21fc4..ea2fdb5529 100644
@@ -32 +33 @@
-@@ -1053,7 +1053,8 @@ again:
+@@ -999,7 +999,8 @@ again:
@@ -44 +45 @@
-@@ -1076,6 +1077,15 @@ again:
+@@ -1022,6 +1023,15 @@ again:



More information about the stable mailing list