From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 651C7A051C for ; Tue, 11 Feb 2020 12:29:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 582ADA3; Tue, 11 Feb 2020 12:29:16 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 32995A3 for ; Tue, 11 Feb 2020 12:29:15 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id z3so11913287wru.3 for ; Tue, 11 Feb 2020 03:29:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+da/0euk16oByjVTznVGasZmtiB///sjTeByCWFW6pc=; b=G17v2zdfcq5wAlPdN4S9Ndxzrru3Tuufk9xmw3sSem64OB+IUKVlz7Tq0wIPltkwYS KR5NB95Drur2Rq9WEVvc42xXJ3whqI1+nwV00UMm/ZNwo4dYhLkgiZBxWZ+KntHr1o3d h6zl20M4GcMR5E6o4oX0I+2Q6NK3WhnGl4eXjsRkMCzPevLJK0yA/FBc5nu0iIsIz4U4 WOH31FNLSlHcjuDGRDAnIMCNS2WKL11lVMbbKVUqiO8eSgOVQ4lhz5PM5lhPvdmH1jnU 8DtYXP+TYMnfUNHWXlv72Bh9/SD3qJ04DUvkLJUiEMvSqypoiJN6KKX+EWS+Ie9OO3IV /LvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+da/0euk16oByjVTznVGasZmtiB///sjTeByCWFW6pc=; b=rGr+P1zjgLgbXRSmXcVFLTD0a7U4lEIQ7pCNasUvOwAngwHZ3mjHCkweJ9YvlXfTkb JqFuba1a3EowyoTlqDqwu0CRAnkPvKModHv3l1axDUw9mJmwmpGDfqWOx16vuHKzsThL ehZDSZdSERIUYvJiSCRvMHxB7Kj7aAomDzcnWvY3hvgNlfk37AvwVFC/Tu6SF73VAXf6 rCqjYSPUaABaWLZuTqW8Nd55kFYfeNcvBeUj00Bey5Yem0Ttoo+7mnGQizsU954QMnM/ G++zjfJVk/WNA66zYW9i/BCqWVLAUkUbU5r4eIVqjHrYK/QIb6gNEbQ+31AXjTD9HcAY 7v8g== X-Gm-Message-State: APjAAAWxQJSbAZ7hkb3QT2ien/QSBQQqXGIGCPGvkCqjP7EJOEepVRIG uR8Nwcq67GClQTMUGZ/UUEoNbKPFWKw= X-Google-Smtp-Source: APXvYqzzg9HjWRIinKjJbp8aDfKPJINMiGQILXGY0j+YSFuXgMyYdD/GcHHhKPB/vwhGKPvAKcCj4A== X-Received: by 2002:a5d:4052:: with SMTP id w18mr7987127wrp.112.1581420554887; Tue, 11 Feb 2020 03:29:14 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id c13sm5119616wrx.9.2020.02.11.03.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 03:29:14 -0800 (PST) From: luca.boccassi@gmail.com To: Maxime Coquelin Cc: Tiwei Bie , Eelco Chaudron , dpdk stable Date: Tue, 11 Feb 2020 11:20:39 +0000 Message-Id: <20200211112216.3929-93-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200211112216.3929-1-luca.boccassi@gmail.com> References: <20200211112216.3929-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'vhost: fix deadlock on port deletion' has been queued to stable release 19.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 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 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 Reviewed-by: Tiwei Bie Acked-by: Eelco Chaudron --- 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 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@dpdk.org Signed-off-by: Maxime Coquelin Reviewed-by: Tiwei Bie @@ -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: