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 E04BBA0543 for ; Tue, 21 Jun 2022 10:13:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 485CD42802; Tue, 21 Jun 2022 10:13:02 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061.outbound.protection.outlook.com [40.107.92.61]) by mails.dpdk.org (Postfix) with ESMTP id 27E0842802 for ; Tue, 21 Jun 2022 10:13:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NKE0vflfcR6xubtM4ic/2SQBYzKzxwCcMK2/+nfr0rDVgujzN2UQbMhCEzxqH46V7KJgsyCNQe9JKi4ctqlCsW7f6nPNIQkDkHG9xlHwmT6T7+UDXC1LNYy4bhnb9Qo2pjgg+anz9I98APKd43vSfn2wNX+JyDZ6HK+ZuL7NaVN/sBZj8mbXQ41xnyK2nIwrKWzT5JxkQlcWIR9rXAIXHsQRVBzSua1gW3hQfMiXs8xP9Qr9IeVbaEQng0pTpj1ru6EPsjpXWPmV0yKTRWqr2R6/RZrb65gV94JAsF1sWXIMBCx8fbODJVcI4XF8sRjD3YvJePSyzzXqgg/lF50Ztw== 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=B0ByfzcXo5DJriWsAQTFuih+Eq7A4Z1CpBfhJQiqZK4=; b=feV6W262PwpG7ILuV60PFrD5XNWsqz+Ek42PZ/K7eIE3WeiPHmidRsgaMMPQM7cdvwnASjXvdIPIREdan5aJ4hc1gkBihhNpFvn7f6URlN0fxZW4dxQmj8WmrIqNLXp0+LR6mcGOD4W4Czgi5czBdPSmg9pmPF2re9vyh6N8nhB3TH+V7cBb6hWAPQ2o/M8swpF5yKiBeez8Zt8UnngxtcQF2k8QQfcyXwBHB0xay1nNZJYGIS5jcHORdlHrWoucVT9KgpLUJHylb69pxFlgYk3X2R67kH7Own5CliuXByvHDJh8k7dBnjkfg2dVAgJieNDSuEJlzlxGAN8ZB+3cFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=redhat.com 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=B0ByfzcXo5DJriWsAQTFuih+Eq7A4Z1CpBfhJQiqZK4=; b=BHXdo6HAe/HX6a5j95JB3JJdrv4wppfRG3mLGB/89Z9Wc4hvdNW3UM82OmFEvp1kVrsAKTINPYSMTc28+44LbHl2UP8vgBrjHD1VHvNoMPT2Bbc4sBVmZNNxJO0YzCVjrrMVjC2pZz0KHoKfacibDxH5Y9R+bWQzNK2oQfPSNrQpZYZ+XUx/VLj8PCaKGAtMAnC3pFu+5ocWUeHiwOIcYa2kveTlFth/mwMQGB+cDl4ZiyJBRgXsKDxvjRWktGm0OttJoNHIoXeUqFrEAZ+DUBqA+VajHUOmyeJXcNSoC1ZYl0ojhMWzg5HFlEk2mHykGXFPv/0bzl6lDXh+TetZhA== Received: from MW4PR03CA0319.namprd03.prod.outlook.com (2603:10b6:303:dd::24) by DS7PR12MB5887.namprd12.prod.outlook.com (2603:10b6:8:7a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.22; Tue, 21 Jun 2022 08:12:59 +0000 Received: from CO1NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::f3) by MW4PR03CA0319.outlook.office365.com (2603:10b6:303:dd::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.16 via Frontend Transport; Tue, 21 Jun 2022 08:12:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT003.mail.protection.outlook.com (10.13.175.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5353.14 via Frontend Transport; Tue, 21 Jun 2022 08:12:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Tue, 21 Jun 2022 08:12:58 +0000 Received: from nvidia.com (10.126.230.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.22; Tue, 21 Jun 2022 01:12:56 -0700 From: Xueming Li To: David Marchand CC: Sunil Pai G , Maxime Coquelin , dpdk stable Subject: patch 'vhost: fix async access' has been queued to stable release 20.11.6 Date: Tue, 21 Jun 2022 11:02:59 +0300 Message-ID: <20220621080301.2315720-114-xuemingl@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220621080301.2315720-1-xuemingl@nvidia.com> References: <20220621080301.2315720-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.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: a72788c6-9b63-46f8-c6f8-08da535ddac0 X-MS-TrafficTypeDiagnostic: DS7PR12MB5887:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NnLHmyQdb+Ued/mAc5vdwkUXunMmjMUuJfQClhd2v8SveQGkqPYZYt6iMJBM2GZJwyo2j5ArZkGxebM3xuwHkE/BTR5HtwVMMU6o5yyZBAveNBtOYsY5N9Hzng9BB/26PeBC3ATV/iLsfnvs3Rqfm5V7O9jFDfyM6Nf5K/JDg/olqL/dgEMQjKK6j+piI3CBjCjPRLp1jieBZgdNckP+GLBKEEEA9u/SMxZQ7d3EfH6psC5pKsCnDBQ0rV1ALoPpsFFjHHua7+d6Pzc10Ue6YwksU7YLWNuUYrz7XOh6LT8+nmFPOz94XGLAum+QrbwdUv1yZd5QL1Z3K+v8sUwLTW2D8SXvrg80VMNvzV+yXsuKkwkx3iuAasufAl9MJ4NqXf/VTVZpaxThykwWABGNc+tMaTFkQsk7yZsHTLNSu3XvXdKWkZW/2Q6iyZirAfrV5okeD5v+lAUM58zYAmxtW+F7ONUH8QnoSVlCGkgQY9NQRpmHqyWISdQHMOTY9VX51JeJIZ0Vg0Ohr5oNVrRiK5cMbnIFtQzC6pUaaa6jKtmpyLkIjifcFqCvvHftRfkBWY8CXuo8EqBBzhTAEcg4iADEXPkYh2EDJywiccb1FQrCSXEGDtkGB8f1SvMgHeb5RDNaZ96vK7CEqGNw+5+sEaRksfkg9Mmh3lSEjqnrywslNLLgXzRhl17oPRBTtb8/t6M4zwfIq9apwIICDP8hf3mIL9q0nzrpJP1TQlH/BL35LApq5/n0wkjlEnjNhqtmCOaqbtz4vDEHKshmXk0Tg5+re+7K4pPRXJjjRi3Fdg33i+y5isGcjphCMnQAdRA06CedvjXlDAeA0NpJ8dFcCWTRxun1inLuD2an1Dgm0Y0= X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(396003)(346002)(376002)(39860400002)(136003)(46966006)(36840700001)(40470700004)(16526019)(186003)(336012)(356005)(1076003)(47076005)(426003)(7696005)(53546011)(82740400003)(2616005)(41300700001)(26005)(6286002)(36860700001)(86362001)(54906003)(83380400001)(6916009)(70586007)(8676002)(4326008)(70206006)(2906002)(8936002)(5660300002)(82310400005)(40480700001)(55016003)(478600001)(36756003)(40460700003)(966005)(316002)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 08:12:59.2539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a72788c6-9b63-46f8-c6f8-08da535ddac0 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.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5887 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 06/23/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/ee29f5fa6b16c19ab2d8cb1fdeffabe0b95f0aa2 Thanks. Xueming Li --- >From ee29f5fa6b16c19ab2d8cb1fdeffabe0b95f0aa2 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Fri, 17 Jun 2022 07:52:27 +0200 Subject: [PATCH] vhost: fix async access Cc: Xueming Li [ upstream commit 2d47fd3dfb596d266b89d82c2c4b2351c3d6fe20 ] vq->async accesses must be protected with vq->access_lock. Fixes: eb666d24085f ("vhost: fix async unregister deadlock") Fixes: 0c0935c5f794 ("vhost: allow to check in-flight packets for async vhost") Signed-off-by: David Marchand Acked-by: Sunil Pai G Reviewed-by: Maxime Coquelin --- lib/librte_vhost/vhost.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index e76929d81b..93f0aa240b 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -1697,31 +1697,26 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id) if (vq == NULL) return ret; - ret = 0; - - if (!vq->async_registered) - return ret; - if (!rte_spinlock_trylock(&vq->access_lock)) { VHOST_LOG_CONFIG(ERR, "Failed to unregister async channel. " "virt queue busy.\n"); - return -1; + return ret; } - if (vq->async_pkts_inflight_n) { + if (!vq->async_registered) { + ret = 0; + } else if (vq->async_pkts_inflight_n) { VHOST_LOG_CONFIG(ERR, "Failed to unregister async channel. " "async inflight packets must be completed before unregistration.\n"); - ret = -1; - goto out; - } - - vhost_free_async_mem(vq); + } else { + ret = 0; + vhost_free_async_mem(vq); - vq->async_ops.transfer_data = NULL; - vq->async_ops.check_completed_copies = NULL; - vq->async_registered = false; + vq->async_ops.transfer_data = NULL; + vq->async_ops.check_completed_copies = NULL; + vq->async_registered = false; + } -out: rte_spinlock_unlock(&vq->access_lock); return ret; -- 2.35.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-06-21 15:37:54.254313139 +0800 +++ 0113-vhost-fix-async-access.patch 2022-06-21 15:37:49.237785294 +0800 @@ -1 +1 @@ -From 2d47fd3dfb596d266b89d82c2c4b2351c3d6fe20 Mon Sep 17 00:00:00 2001 +From ee29f5fa6b16c19ab2d8cb1fdeffabe0b95f0aa2 Mon Sep 17 00:00:00 2001 @@ -3 +3 @@ -Date: Mon, 11 Apr 2022 13:00:08 +0200 +Date: Fri, 17 Jun 2022 07:52:27 +0200 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 2d47fd3dfb596d266b89d82c2c4b2351c3d6fe20 ] @@ -10 +12,0 @@ -Cc: stable@dpdk.org @@ -16,2 +18,2 @@ - lib/vhost/vhost.c | 25 ++++++++++--------------- - 1 file changed, 10 insertions(+), 15 deletions(-) + lib/librte_vhost/vhost.c | 27 +++++++++++---------------- + 1 file changed, 11 insertions(+), 16 deletions(-) @@ -19,5 +21,5 @@ -diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c -index df0bb9d043..14863144f3 100644 ---- a/lib/vhost/vhost.c -+++ b/lib/vhost/vhost.c -@@ -1753,27 +1753,23 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id) +diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c +index e76929d81b..93f0aa240b 100644 +--- a/lib/librte_vhost/vhost.c ++++ b/lib/librte_vhost/vhost.c +@@ -1697,31 +1697,26 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id) @@ -29 +31 @@ -- if (!vq->async) +- if (!vq->async_registered) @@ -33,2 +35,2 @@ - VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel, virtqueue busy.\n", - dev->ifname); + VHOST_LOG_CONFIG(ERR, "Failed to unregister async channel. " + "virt queue busy.\n"); @@ -39,2 +41,2 @@ -- if (vq->async->pkts_inflight_n) { -+ if (!vq->async) { +- if (vq->async_pkts_inflight_n) { ++ if (!vq->async_registered) { @@ -42,4 +44,3 @@ -+ } else if (vq->async->pkts_inflight_n) { - VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel.\n", dev->ifname); - VHOST_LOG_CONFIG(ERR, "(%s) inflight packets must be completed before unregistration.\n", - dev->ifname); ++ } else if (vq->async_pkts_inflight_n) { + VHOST_LOG_CONFIG(ERR, "Failed to unregister async channel. " + "async inflight packets must be completed before unregistration.\n"); @@ -47,0 +49,3 @@ +- } +- +- vhost_free_async_mem(vq); @@ -49 +52,0 @@ -+ vhost_free_async_mem(vq); @@ -51,10 +54 @@ - } - -- vhost_free_async_mem(vq); --out: - rte_spinlock_unlock(&vq->access_lock); - - return ret; -@@ -1891,9 +1887,6 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id) - if (vq == NULL) - return ret; ++ vhost_free_async_mem(vq); @@ -62,9 +56,7 @@ -- if (!vq->async) -- return ret; -- - if (!rte_spinlock_trylock(&vq->access_lock)) { - VHOST_LOG_CONFIG(DEBUG, - "(%s) failed to check in-flight packets. virtqueue busy.\n", -@@ -1901,7 +1894,9 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id) - return ret; - } +- vq->async_ops.transfer_data = NULL; +- vq->async_ops.check_completed_copies = NULL; +- vq->async_registered = false; ++ vq->async_ops.transfer_data = NULL; ++ vq->async_ops.check_completed_copies = NULL; ++ vq->async_registered = false; ++ } @@ -72,4 +64 @@ -- ret = vq->async->pkts_inflight_n; -+ if (vq->async) -+ ret = vq->async->pkts_inflight_n; -+ +-out: