[dpdk-stable] patch 'vhost: fix deadlock in driver unregister' has been queued to LTS release 18.11.1

Kevin Traynor ktraynor at redhat.com
Thu Mar 21 13:29:01 CET 2019


Hi,

FYI, your patch has been queued to LTS release 18.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 03/22/19. 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.

Kevin Traynor

---
>From 1068627314e508eb2e1576e3bb0ecc1d4d85d496 Mon Sep 17 00:00:00 2001
From: Wenjie Sun <findtheonlyway at gmail.com>
Date: Mon, 28 Jan 2019 14:55:49 +0800
Subject: [PATCH] vhost: fix deadlock in driver unregister

[ upstream commit 054617fd82b6d99595520e75fdab6706f39d5643 ]

In rte_vhost_driver_unregister(), the connection fd is
removed from the fdset using fdset_try_del(). Call to
this function may fail if the corresponding fd is in
busy state, indicating that event dispatcher is
executing the read or write callback on this fd.
When it happens, rte_vhost_driver_unregister() keeps
trying to remove the fd from the set until it is no
more busy.

This situation is causing a deadlock, because
rte_vhost_driver_unregister() keeps trying to remove
the fd from the set with vhost_user.mutex held, while
the callback executed by the dispatcher,
vhost_user_read_cb(), also takes this mutex at
numerous places.

The fix consists in releasing vhost_user.mutex between
each retry in vhost_driver_unregister().

Fixes: 8b4b949144b8 ("vhost: fix dead lock on closing in server mode")

Signed-off-by: Wenjie Sun <findtheonlyway at gmail.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/librte_vhost/socket.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 9cf34ad17..9883b0491 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -962,11 +962,11 @@ rte_vhost_driver_unregister(const char *path)
 	struct vhost_user_connection *conn, *next;
 
-	pthread_mutex_lock(&vhost_user.mutex);
-
-	for (i = 0; i < vhost_user.vsocket_cnt; i++) {
-		struct vhost_user_socket *vsocket = vhost_user.vsockets[i];
-
-		if (!strcmp(vsocket->path, path)) {
 again:
+	pthread_mutex_lock(&vhost_user.mutex);
+
+	for (i = 0; i < vhost_user.vsocket_cnt; i++) {
+		struct vhost_user_socket *vsocket = vhost_user.vsockets[i];
+
+		if (!strcmp(vsocket->path, path)) {
 			pthread_mutex_lock(&vsocket->conn_mutex);
 			for (conn = TAILQ_FIRST(&vsocket->conn_list);
@@ -984,4 +984,5 @@ again:
 					pthread_mutex_unlock(
 							&vsocket->conn_mutex);
+					pthread_mutex_unlock(&vhost_user.mutex);
 					goto again;
 				}
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-03-21 11:21:26.441844591 +0000
+++ 0003-vhost-fix-deadlock-in-driver-unregister.patch	2019-03-21 11:21:26.290140974 +0000
@@ -1,8 +1,10 @@
-From 054617fd82b6d99595520e75fdab6706f39d5643 Mon Sep 17 00:00:00 2001
+From 1068627314e508eb2e1576e3bb0ecc1d4d85d496 Mon Sep 17 00:00:00 2001
 From: Wenjie Sun <findtheonlyway at gmail.com>
 Date: Mon, 28 Jan 2019 14:55:49 +0800
 Subject: [PATCH] vhost: fix deadlock in driver unregister
 
+[ upstream commit 054617fd82b6d99595520e75fdab6706f39d5643 ]
+
 In rte_vhost_driver_unregister(), the connection fd is
 removed from the fdset using fdset_try_del(). Call to
 this function may fail if the corresponding fd is in
@@ -23,7 +25,6 @@
 each retry in vhost_driver_unregister().
 
 Fixes: 8b4b949144b8 ("vhost: fix dead lock on closing in server mode")
-Cc: stable at dpdk.org
 
 Signed-off-by: Wenjie Sun <findtheonlyway at gmail.com>
 Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>


More information about the stable mailing list