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

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue Feb 11 12:20:39 CET 2020


Hi,

FYI, your patch has been queued to stable release 19.11.1

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/13/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.

Thanks.

Luca Boccassi

---
>From 4e1bf3fcbafa4f23d69097d8cf2bc55d3b297e9a 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 834f0b88ad..785cea46e5 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -1052,9 +1052,10 @@ again:
 				next = TAILQ_NEXT(conn, next);
 
 				/*
-				 * 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,
 						  conn->connfd) == -1) {
@@ -1075,8 +1076,17 @@ again:
 			pthread_mutex_unlock(&vsocket->conn_mutex);
 
 			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);
 			} else if (vsocket->reconnect) {
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-02-11 11:17:42.124598769 +0000
+++ 0093-vhost-fix-deadlock-on-port-deletion.patch	2020-02-11 11:17:38.532003815 +0000
@@ -1,8 +1,10 @@
-From 5efb18e85f7fdb436d3e56591656051c16802066 Mon Sep 17 00:00:00 2001
+From 4e1bf3fcbafa4f23d69097d8cf2bc55d3b297e9a 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
@@ -16,7 +18,6 @@
 
 Fixes: 8b4b949144b8 ("vhost: fix dead lock on closing in server mode")
 Fixes: 5fbb3941da9f ("vhost: introduce driver features related APIs")
-Cc: stable at dpdk.org
 
 Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
 Reviewed-by: Tiwei Bie <tiwei.bie at intel.com>
@@ -26,7 +27,7 @@
  1 file changed, 15 insertions(+), 5 deletions(-)
 
 diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
-index 8bc1e3a03c..9740fb3403 100644
+index 834f0b88ad..785cea46e5 100644
 --- a/lib/librte_vhost/socket.c
 +++ b/lib/librte_vhost/socket.c
 @@ -1052,9 +1052,10 @@ again:


More information about the stable mailing list