From patchwork Mon Jan 28 06:55:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5a2Z5paH5p2w?= X-Patchwork-Id: 50062 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5B4C25B3; Mon, 28 Jan 2019 07:56:01 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id DD6C920BD; Mon, 28 Jan 2019 07:56:00 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id y1so7330607plp.9; Sun, 27 Jan 2019 22:56:00 -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:mime-version :content-transfer-encoding; bh=FxPsiBxvWmbGkBNNsSodHFdxnuGyXJT50sm4E0g8T0w=; b=nNahWc/R1hhkqG0LWWrA4XNNzVVEeviUHgVn88Mnkiq7pXp8Yx+nGjzLD46XcQx0YU G8cVhzFgTpgMbxTvfp3NWMbUBGfEKghHiGP1uVnQYNQhVlVlkSRGqOCvy4KWAM93Furm Qs6Sji9xYSa2zLPxq4WBx85pMFBz4dQLQfwyN6B1GFO0eJTg33tAF+hlZsD7gEm7Fb/3 Fl+iAokpf54tDeUyFVNpD1n9Z/9hP4kECn5Re9YxZZPX6DPvG1I1U1EUe95w+7fxpUh/ wh9XdTk/8VJw//bBQkoGY8BjIieukWWkmSNHZqQbedHB8kn6odXH8Xr9B+68/XLrG3ty xVow== 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:mime-version :content-transfer-encoding; bh=FxPsiBxvWmbGkBNNsSodHFdxnuGyXJT50sm4E0g8T0w=; b=dHFBt4yYuU6CYcMwv4/UWtLc+xuzb4ByTZIulMhBMWbyzwJVsFQ1fwcHpoGQJcUHOB b2ZSByvcCjfHqAodcQ75As2o4eYnUX8fvIbHXpwpFK/ay+74xsYD4Mi9L85Ribj6RAUW MRnwU8vGzBnLdwC6igfTgNcQrjHawyqgwDYagDMvIGB7V1WhD//Tnx9bDLxkBHK0jhmF gWnEZ958uVxSgdM9An3zodJ8zFQnxPbEsn7lCwdKpiXAc3gzUjZ6Wzt45KUgjHVHSmxf BQsHibVKmL0npklUlzY6TvXjHTZGN8D1MYnQlatZmXtLyEOvIMNaJlYtzUqnLuAaY8Ib nxmg== X-Gm-Message-State: AJcUukdYFSqMzqXPlrBKfugEwbjhQcwxdg0pL94RAwopnVInlsC3zWLk zBpG+QJocB+v7pSXK78rn+M0tPwp X-Google-Smtp-Source: ALg8bN4qvlYvwtbk11cYB+95qezbgQ759/qUS2TSwiIlgMNLarR4EXGtbEh4vq6R2NYY8p3QJvuB5A== X-Received: by 2002:a17:902:7e44:: with SMTP id a4mr20718909pln.338.1548658559282; Sun, 27 Jan 2019 22:55:59 -0800 (PST) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id q199sm58661810pfc.97.2019.01.27.22.55.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 27 Jan 2019 22:55:58 -0800 (PST) From: sunwenjie To: dev@dpdk.org Cc: sunwenjie , stable@dpdk.org Date: Mon, 28 Jan 2019 14:55:49 +0800 Message-Id: <20190128065549.98266-1-findtheonlyway@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] vhost: fix deadlock when vhost unregister X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When rte_vhost_driver_unregister delete the connection fd, fdset_try_del will always try and donot release the vhostuser.mutex if the fd is busy, but the fdset_event_dispatch will set the fd to busy and call vhost_user_msg_handler to get vhostuser.mutex, which will cause deadlock. Unlock the vhost_user.mutexif fdset_try_del fail and relock it when retry. Fixes: 8b4b949144b8 ("vhost: fix dead lock on closing in server mode") Cc: stable@dpdk.org Signed-off-by: sunwenjie Signed-off-by: Surname Lastname Reviewed-by: Maxime Coquelin Signed-off-by: Wenjie Sun --- lib/librte_vhost/socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 @@ -961,13 +961,13 @@ rte_vhost_driver_unregister(const char *path) int count; struct vhost_user_connection *conn, *next; +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)) { -again: pthread_mutex_lock(&vsocket->conn_mutex); for (conn = TAILQ_FIRST(&vsocket->conn_list); conn != NULL; @@ -983,6 +983,7 @@ rte_vhost_driver_unregister(const char *path) conn->connfd) == -1) { pthread_mutex_unlock( &vsocket->conn_mutex); + pthread_mutex_unlock(&vhost_user.mutex); goto again; }