From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 48916A00E6 for ; Thu, 21 Mar 2019 13:29:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 408874CA9; Thu, 21 Mar 2019 13:29:25 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 487EC1B47C for ; Thu, 21 Mar 2019 13:29:24 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE73581E1A; Thu, 21 Mar 2019 12:29:23 +0000 (UTC) Received: from rh.redhat.com (ovpn-116-76.ams2.redhat.com [10.36.116.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id C876B60BE5; Thu, 21 Mar 2019 12:29:20 +0000 (UTC) From: Kevin Traynor To: Wenjie Sun Cc: Maxime Coquelin , dpdk stable Date: Thu, 21 Mar 2019 12:29:01 +0000 Message-Id: <20190321122903.668-3-ktraynor@redhat.com> In-Reply-To: <20190321122903.668-1-ktraynor@redhat.com> References: <20190321122903.668-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 21 Mar 2019 12:29:23 +0000 (UTC) Subject: [dpdk-stable] patch 'vhost: fix deadlock in driver unregister' has been queued to LTS release 18.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 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 Reviewed-by: Maxime Coquelin --- 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 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 Reviewed-by: Maxime Coquelin