From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1A01FA00C5 for ; Wed, 20 Jul 2022 10:26:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11E6741614; Wed, 20 Jul 2022 10:26:57 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 3526A40A7A for ; Wed, 20 Jul 2022 10:26:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jwdMlBhumJYpiP8pqbNKGVVJVXyMbrrLdkzbm7MQ3Szcdjtjfw/4NdRf9zmExhqd2dI5BXiW9XKvRfzx0vvWEzLxe9mOejHuXCdHrSSpkn7xZKbES0qC71A5Bl+eXKS7WlMHA3SAaP6RRuZ7sugOhVT9Ztt51zpzTJ5DVArm7NIQzCvNqnzwauoWn5paxMCvUkSxascezEjIU/PuVR/D9/XFUkleHyavdj+LgTNcggzrJ9cyZtprjuckcdamIv52pg24F3Yj+o9JjGZ4THRQDBTpuwjoV5KAHbrIWmkqVYpKVVaZRpSpaMhtiB+gT5dMkJSia6/QphHQutGdC0aY+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Zu8HQPUHCy4oc5BSi9DjZ6fH//UeB+GJFMyDEfDIEOE=; b=mqH6b1WoftCbpOIRku1bfCqpYw7WdtfCzxXcFOPjutAJPUVoQmonwIQ1A8+F0y0aLOZE0PT2ma4fgUeufOeDdnBqzJDyMq9fPzMmj8fg86tRg6i4HhV6Hi4Z2Q7Kuyd4/0FraHaAvipoo3ZHGhACeQTJYaGzepvwkEnTsIx8jFxN1a586jHZ4lGzmwoG18AIm+lMq3CcLvkSOOWk7KLcieEBogG/ZILP/WXA+eTcGGq9ePkwpI9mwJuOPK8UUiZ0ENWWRfMY47TrO9Q7RxjcwBL4GAhSp3/y/Vsq0yRSFkS676hFcCiM56C5aZ+jV56JhjlSoUKxNW79tp3UKXkrQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zu8HQPUHCy4oc5BSi9DjZ6fH//UeB+GJFMyDEfDIEOE=; b=E9i3K1wVYENTwkl/gSXcrX1zuw5PqlIjbWXAbO7H5v95tm2xTegWfasmHLgkl5Lz9kfxhC3qeVXBYgFh+dDPby9fJrqH/DIe5SBeCwi4GnhH/Om6CTz0EtSX9Fl43NZiKNxz8ooLAhniTfAqg767D6Lnb4kwdGZo2VMH5pcFFOhojk1uWSYJN1TE32ZC9AmEtKV1NrxGAmr6ft5mAbOxNoOt7wDyDWB8eYkAYVK1Gz+ID+9EqYSYvuIV9+iHcoEu1RSLfM8Y7X46CA3/N5k2DydLZHi7OURpyXkmjXIAv7lrmaNfJCIGQ9djJef1MSt0JBa0lndpFmZGqDzzzbJodQ== Received: from MW4PR03CA0061.namprd03.prod.outlook.com (2603:10b6:303:b6::6) by MN2PR12MB4336.namprd12.prod.outlook.com (2603:10b6:208:1df::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.12; Wed, 20 Jul 2022 08:26:53 +0000 Received: from CO1NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::d7) by MW4PR03CA0061.outlook.office365.com (2603:10b6:303:b6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.17 via Frontend Transport; Wed, 20 Jul 2022 08:26:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by CO1NAM11FT038.mail.protection.outlook.com (10.13.174.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5458.17 via Frontend Transport; Wed, 20 Jul 2022 08:26:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 20 Jul 2022 08:26:51 +0000 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 20 Jul 2022 01:26:50 -0700 From: Xueming Li To: Yuan Wang CC: , Chenbo Xia , dpdk stable Subject: patch 'net/vhost: fix deadlock on vring state change' has been queued to stable release 20.11.6 Date: Wed, 20 Jul 2022 11:21:27 +0300 Message-ID: <20220720082132.3954126-58-xuemingl@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220720082132.3954126-1-xuemingl@nvidia.com> References: <20220621080301.2315720-1-xuemingl@nvidia.com> <20220720082132.3954126-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dbb0db44-5d89-44b1-8d89-08da6a2999af X-MS-TrafficTypeDiagnostic: MN2PR12MB4336:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IwaRc5AgQGXBltHOEruynhqenNGHgVii4hZ5pZRkn9tFsCnt1UxkL7ztfJbI?= =?us-ascii?Q?G3hLAWRAP+qpQy7hNaJVOrbf0CIf9srU/IDsIZU8lSKR59OPuennuJnEflJ1?= =?us-ascii?Q?70MvdHoGjY03kYfNM5U7zQzMqa56id7NuCbk/a8UgHQ39B64jvG3a3YLrvu5?= =?us-ascii?Q?e8Z8qhaIvk252XLSKH7HTzWvf/96K8rASWbJXrWGZYviD0GEB4j51CFhynC4?= =?us-ascii?Q?BPjkDUekOEf6RNriNealm0TpPcwC1FLFFVu7OH/VDVMxlyfFrEOveHc20rk9?= =?us-ascii?Q?OfYp299DU6xrl8A509vwJIAoAs4RZxVfKJFMVfApZmLRH4e8dz3UtvnGIXqz?= =?us-ascii?Q?d66ndSHin/dj+bmuEFFdPIqlOD4z/6Zl1Q7biYrnq41jRuVVKx7vhmNDC5pK?= =?us-ascii?Q?YWvDXxDPkrrXl/PvCq8vAsi82p3ZaChSW5jVy3ytCDbiphrEI50c8pN37rx+?= =?us-ascii?Q?rG1EoIJe4et5DH5gmI8r//M+pnLGBlgAwwP1kMYGjtCgdgVcHm7x3FwWzROG?= =?us-ascii?Q?ci4+pxT3ziu34/hiSIU8VRLtbqyGxoNMZ3XQiV7WEvPStmYQFm1cXsJgu4Gb?= =?us-ascii?Q?xAGdPScfgT4KiVMKoTJUFk8D/lGdNFvR5BuDBN2d+0CLCGiwDF5PresU/DH+?= =?us-ascii?Q?qK6rxs9kkkENmdxjgfHq8Rn6fhv8sIeMiDaxzyZSKCk7SvjYETcuQPg5Dm56?= =?us-ascii?Q?e+5wV0nXm1W9KzfFg1LpjLiy9hYqj7zihMfoxBakE83Xo7o/dokGBmysXq6N?= =?us-ascii?Q?PPckJLU74xee5Zsjhdrw/J4yEDK66PW0uZ8mHWpPGSb0CkBzsMk+AJSmjPVO?= =?us-ascii?Q?dWqOBA+vPoqKonAHhZUR+k+vLV3OlMiuKU7QeJ0uh6OBAWi9NgkgkVBIRDrO?= =?us-ascii?Q?6IvpKkvM6hWXXOFvun8bLJ98HHu9GgU/BRNPTZ9haDtL2RdP6asHnO3pnxZn?= =?us-ascii?Q?q4CHud6RM4p/Jzc6dMKcMw=3D=3D?= X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(40470700004)(36840700001)(46966006)(478600001)(8936002)(70206006)(4326008)(8676002)(40480700001)(966005)(36860700001)(316002)(54906003)(2616005)(6916009)(16526019)(70586007)(36756003)(86362001)(2906002)(55016003)(47076005)(82740400003)(7696005)(40460700003)(6666004)(5660300002)(26005)(41300700001)(1076003)(53546011)(356005)(336012)(426003)(83380400001)(81166007)(186003)(6286002)(82310400005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 08:26:53.0031 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dbb0db44-5d89-44b1-8d89-08da6a2999af X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4336 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 Hi, FYI, your patch has been queued to stable release 20.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/22/22. 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. Queued patches are on a temporary branch at: https://github.com/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/fc9be6c79aebaa183e80f7faf2c7ff45114edcf8 Thanks. Xueming Li --- >From fc9be6c79aebaa183e80f7faf2c7ff45114edcf8 Mon Sep 17 00:00:00 2001 From: Yuan Wang Date: Mon, 27 Jun 2022 13:51:25 +0800 Subject: [PATCH] net/vhost: fix deadlock on vring state change Cc: Xueming Li [ upstream commit 193edd75a94fe8d0d633d1702109779fd7b7d6a0 ] If vring state changes after pmd starts working, the locked vring notifies pmd, thus calling update_queuing_status(), the latter will wait for pmd to finish accessing vring, while pmd is also waiting for vring to be unlocked, thus causing deadlock. Actually, update_queuing_status() only needs to wait while destroy/stopping the device, but not in other cases. This patch adds a flag for whether or not to wait to fix this issue. Fixes: 1ce3c7fe149f ("net/vhost: emulate device start/stop behavior") Signed-off-by: Yuan Wang Reviewed-by: Chenbo Xia --- drivers/net/vhost/rte_eth_vhost.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 2df516ec21..c994f2429b 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -715,7 +715,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) } static void -update_queuing_status(struct rte_eth_dev *dev) +update_queuing_status(struct rte_eth_dev *dev, bool wait_queuing) { struct pmd_internal *internal = dev->data->dev_private; struct vhost_queue *vq; @@ -741,7 +741,7 @@ update_queuing_status(struct rte_eth_dev *dev) rte_atomic32_set(&vq->allow_queuing, 1); else rte_atomic32_set(&vq->allow_queuing, 0); - while (rte_atomic32_read(&vq->while_queuing)) + while (wait_queuing && rte_atomic32_read(&vq->while_queuing)) rte_pause(); } @@ -753,7 +753,7 @@ update_queuing_status(struct rte_eth_dev *dev) rte_atomic32_set(&vq->allow_queuing, 1); else rte_atomic32_set(&vq->allow_queuing, 0); - while (rte_atomic32_read(&vq->while_queuing)) + while (wait_queuing && rte_atomic32_read(&vq->while_queuing)) rte_pause(); } } @@ -835,7 +835,7 @@ new_device(int vid) eth_dev->data->dev_link.link_status = ETH_LINK_UP; rte_atomic32_set(&internal->dev_attached, 1); - update_queuing_status(eth_dev); + update_queuing_status(eth_dev, false); VHOST_LOG(INFO, "Vhost device %d created\n", vid); @@ -865,7 +865,7 @@ destroy_device(int vid) internal = eth_dev->data->dev_private; rte_atomic32_set(&internal->dev_attached, 0); - update_queuing_status(eth_dev); + update_queuing_status(eth_dev, true); eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; @@ -972,7 +972,7 @@ vring_state_changed(int vid, uint16_t vring, int enable) state->max_vring = RTE_MAX(vring, state->max_vring); rte_spinlock_unlock(&state->lock); - update_queuing_status(eth_dev); + update_queuing_status(eth_dev, false); VHOST_LOG(INFO, "vring%u is %s\n", vring, enable ? "enabled" : "disabled"); @@ -1159,7 +1159,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev) } rte_atomic32_set(&internal->started, 1); - update_queuing_status(eth_dev); + update_queuing_status(eth_dev, false); return 0; } @@ -1171,7 +1171,7 @@ eth_dev_stop(struct rte_eth_dev *dev) dev->data->dev_started = 0; rte_atomic32_set(&internal->started, 0); - update_queuing_status(dev); + update_queuing_status(dev, true); return 0; } -- 2.35.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-07-20 15:01:01.470868002 +0800 +++ 0058-net-vhost-fix-deadlock-on-vring-state-change.patch 2022-07-20 15:00:58.804333679 +0800 @@ -1 +1 @@ -From 193edd75a94fe8d0d633d1702109779fd7b7d6a0 Mon Sep 17 00:00:00 2001 +From fc9be6c79aebaa183e80f7faf2c7ff45114edcf8 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 193edd75a94fe8d0d633d1702109779fd7b7d6a0 ] @@ -17 +19,0 @@ -Cc: stable@dpdk.org @@ -26 +28 @@ -index d75d256040..7e512d94bf 100644 +index 2df516ec21..c994f2429b 100644 @@ -29 +31 @@ -@@ -741,7 +741,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) +@@ -715,7 +715,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) @@ -38 +40 @@ -@@ -767,7 +767,7 @@ update_queuing_status(struct rte_eth_dev *dev) +@@ -741,7 +741,7 @@ update_queuing_status(struct rte_eth_dev *dev) @@ -47 +49 @@ -@@ -779,7 +779,7 @@ update_queuing_status(struct rte_eth_dev *dev) +@@ -753,7 +753,7 @@ update_queuing_status(struct rte_eth_dev *dev) @@ -56,2 +58,2 @@ -@@ -868,7 +868,7 @@ new_device(int vid) - vhost_dev_csum_configure(eth_dev); +@@ -835,7 +835,7 @@ new_device(int vid) + eth_dev->data->dev_link.link_status = ETH_LINK_UP; @@ -65 +67 @@ -@@ -898,7 +898,7 @@ destroy_device(int vid) +@@ -865,7 +865,7 @@ destroy_device(int vid) @@ -72 +74 @@ - eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN; + eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; @@ -74 +76 @@ -@@ -1008,7 +1008,7 @@ vring_state_changed(int vid, uint16_t vring, int enable) +@@ -972,7 +972,7 @@ vring_state_changed(int vid, uint16_t vring, int enable) @@ -83 +85 @@ -@@ -1197,7 +1197,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev) +@@ -1159,7 +1159,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev) @@ -92 +94 @@ -@@ -1209,7 +1209,7 @@ eth_dev_stop(struct rte_eth_dev *dev) +@@ -1171,7 +1171,7 @@ eth_dev_stop(struct rte_eth_dev *dev)