patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Wenjie Sun <findtheonlyway@gmail.com>
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>,
	dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'vhost: fix deadlock in driver unregister' has been queued to LTS release 18.11.1
Date: Thu, 21 Mar 2019 12:29:01 +0000	[thread overview]
Message-ID: <20190321122903.668-3-ktraynor@redhat.com> (raw)
In-Reply-To: <20190321122903.668-1-ktraynor@redhat.com>

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@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@gmail.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@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@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@dpdk.org
 
 Signed-off-by: Wenjie Sun <findtheonlyway@gmail.com>
 Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

  parent reply	other threads:[~2019-03-21 12:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 12:28 [dpdk-stable] patch 'net/mlx5: fix instruction hotspot on replenishing Rx buffer' " Kevin Traynor
2019-03-21 12:29 ` [dpdk-stable] patch 'net/bonding: fix reset active slave' " Kevin Traynor
2019-03-21 12:29 ` Kevin Traynor [this message]
2019-03-21 12:29 ` [dpdk-stable] patch 'net/bnx2x: fix segfaults due to stale interrupt status' " Kevin Traynor
2019-03-21 12:29 ` [dpdk-stable] patch 'net/ixgbe: fix crash on remove' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190321122903.668-3-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=findtheonlyway@gmail.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).