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 1C92943B86 for ; Tue, 5 Mar 2024 10:53:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1691F42E15; Tue, 5 Mar 2024 10:53:54 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062.outbound.protection.outlook.com [40.107.223.62]) by mails.dpdk.org (Postfix) with ESMTP id 792C44014F for ; Tue, 5 Mar 2024 10:53:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lwy77mQqJq0TZAtdxOjdfa87XjdQBQZqOUB9zbAOOXf5P9KDxrdU7bch0d7vr+Y+KgVDR8B9lzlbQVwxP0cXdEh3F9mv0LybXbC2XcYX7IhgWnJxyyNaXKNQXmDVN2f4t5l4LrkbehC82+uq62YuwCmnbx9cdMaBdKXb1mflpHj6pl0n8++pAcBd4VtjjbXrE7fBIe4OYdSjmTdUFbmr8ujvnTEmhEtplONC91VbCxvcM0/0bn4oMI7UHTLjp8OLk5EiJUsucz+PY3NBF3pAD4TDuQs7P5fgdZh5UqnllSXOKfXV+nMDd4qROUkPUSXh2ocLlgH1Az2dmmvyye1tpQ== 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=f/lChv82dhn1RBmnQZNcQC8wbNPFH7rQg8dOg9x2AS4=; b=InDbKpDuyhPoLz+TLm98Mc5LcSrEYXHuIazOyYe+filUpathbcZCa3jSlBhWvY1hoHL+EtzpNSCvUdIK+k8feptM3+SeSAkb7yhpMx/a+TBmtJ468HO0EW0BmV6HpSZ6wUh0jZaRcb15e6C622j7cnNeZAHI4MkTcvwRjdY+Qy3hsoMvlQTWhsZTINHNI6BKQSqywp9xokdL4axkkFSKA7+lTcfHfHVdFQClOFPP63EvSUdEkUioWf99Q03nK7umzJf9FOxfBt3FNY99YTq4Q1EXqTEBYFjz5mu/d/erlal6Q3vdVt9WZbY5R7uV7yGxtoQ5bWEDoXRLTwPlpIgnFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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 (0) 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=f/lChv82dhn1RBmnQZNcQC8wbNPFH7rQg8dOg9x2AS4=; b=fM+EMk9E1XtWn+fdkWrs3LDMglSA1f2i1XuKJyi8NiMcqKuVIs8sm+IT7qse6tvAAyjHrGlTNIlMgPjmqXEqKB44RVBzrWh4AIztd3BhwaaECHQwJpEFOWc/ExvaSvZM/FnGAS/uYyIy6F3va15Af4NND059T84O0QFnojPxfPVuwfFh75/kHfu/GPGNyqpWB2HnDOYU/GTY2nq04LvIJUbjssr41oyMGHSL2Mv3z2rmtbwFaddXCmhKfep7IhVCKJ7c5P3dgjqNJYtDW3orVCnsSVAaVclCHXaJHGMU+WY/UOQVktmYE5Y8YLira2c2IqIirVXPCIlG0eaBhcpeeA== Received: from CY5PR22CA0009.namprd22.prod.outlook.com (2603:10b6:930:16::20) by SN7PR12MB7107.namprd12.prod.outlook.com (2603:10b6:806:2a2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Tue, 5 Mar 2024 09:53:49 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:930:16:cafe::a1) by CY5PR22CA0009.outlook.office365.com (2603:10b6:930:16::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.39 via Frontend Transport; Tue, 5 Mar 2024 09:53:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Tue, 5 Mar 2024 09:53:49 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 5 Mar 2024 01:53:35 -0800 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.1258.12; Tue, 5 Mar 2024 01:53:34 -0800 From: Xueming Li To: Maxime Coquelin CC: David Marchand , dpdk stable Subject: patch 'vhost: fix memory leak in Virtio Tx split path' has been queued to stable release 23.11.1 Date: Tue, 5 Mar 2024 17:46:42 +0800 Message-ID: <20240305094757.439387-62-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305094757.439387-1-xuemingl@nvidia.com> References: <20240305094757.439387-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-TrafficTypeDiagnostic: CY4PEPF0000FCC4:EE_|SN7PR12MB7107:EE_ X-MS-Office365-Filtering-Correlation-Id: 6751f27d-6118-4c33-5b83-08dc3cfa2839 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pwciwft/fh5tBQG2AIDnF+G5pEsCAm984f0EoGQat6+j+5N8TH9/4XlQaTKJYH3tAY0YL9LIQPRpJ8gj3ZV8foqnLKV3ZvXt36v3YUVK5i4U3A5EekmNQmG1eVFaUkBLiUy1PQ8d0bRoRpqgTc5SPhzOB6ug1GC/7DY1+eJBxr9CbApFj+bSD/tFZftpFtjNESApzA3ph5YvGJJS3te0DrtR8DNPjYNOXQzisdafOAY5Ac6mKhM9A3TCxYAXkrCk3RGaacJUb0rKW6wrY2jOgJ+dM9WcMUshBtA5pgV105rQiwp7cJPd9aTEtqX3uWmyYPEUKcZPd726/4ysHsRFGfK2RFXICOAxqMp3CNoco9KivI4Iw0UF587StQ7Fn2TswTk/2lHtHTHHb/cimL2/XaFdu4a1yYCVFOXPcUHQz6Y2WPKq4JODmHAFH/7E+XDowyzN+HV22Uaeh0o53iSJzofcyqVTN3gQhTy0t1fPe6PQaW3tW6K34HZ/PpTv78f7HTLz8OLvY8X37+nnCk7ubgdoaEvHD0rPiL1DSLCP/7ge13KhC4RDHxWGnuvTIdLaAplCP5QyqBDIXIo7RoIy9R5IbXTLm220K5hwskCXcgbhYC3G1YoYaSHw0TvgujtP6x5DU39dLMh1FEFEMoTI5gylwfKSycLt7SBBVKVLUD5OPQC+ePPTrSAt5k5EH1w24L5LjeBRsWnUS2ha8dQ0KOdz6Kz+AiabhwPSN47b4BzepiBA9BCTb+zA0NaZ6aWW X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(82310400014)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 09:53:49.2699 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6751f27d-6118-4c33-5b83-08dc3cfa2839 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7107 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 23.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/31/24. 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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=e951bbbd186c29ef86a3016ff30bc33b9dac35fa Thanks. Xueming Li --- >From e951bbbd186c29ef86a3016ff30bc33b9dac35fa Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Wed, 31 Jan 2024 20:53:08 +0100 Subject: [PATCH] vhost: fix memory leak in Virtio Tx split path Cc: Xueming Li [ upstream commit 7746fba831509fdb4c528266d0b38a89566e01e5 ] When vIOMMU is enabled, rte_vhost_dequeue_burst() can return early because of IOTLB misses. Such IOTLB misses are especially frequent when a Virtio device is bound to a kernel driver in guest. This patch fixes a mbuf leak occurring in this case. Fixes: 242695f6122a ("vhost: allocate and free packets in bulk in Tx split") Signed-off-by: Maxime Coquelin Signed-off-by: David Marchand Reviewed-by: David Marchand --- lib/vhost/virtio_net.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index d00f4b03aa..895a79cf51 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -3104,7 +3104,6 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, { uint16_t i; uint16_t avail_entries; - uint16_t dropped = 0; static bool allocerr_warned; /* @@ -3143,11 +3142,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, update_shadow_used_ring_split(vq, head_idx, 0); - if (unlikely(buf_len <= dev->vhost_hlen)) { - dropped += 1; - i++; + if (unlikely(buf_len <= dev->vhost_hlen)) break; - } buf_len -= dev->vhost_hlen; @@ -3164,8 +3160,6 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, buf_len, mbuf_pool->name); allocerr_warned = true; } - dropped += 1; - i++; break; } @@ -3176,27 +3170,21 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, VHOST_LOG_DATA(dev->ifname, ERR, "failed to copy desc to mbuf.\n"); allocerr_warned = true; } - dropped += 1; - i++; break; } - } - if (dropped) - rte_pktmbuf_free_bulk(&pkts[i - 1], count - i + 1); + if (unlikely(count != i)) + rte_pktmbuf_free_bulk(&pkts[i], count - i); - vq->last_avail_idx += i; - - do_data_copy_dequeue(vq); - if (unlikely(i < count)) - vq->shadow_used_idx = i; if (likely(vq->shadow_used_idx)) { + vq->last_avail_idx += vq->shadow_used_idx; + do_data_copy_dequeue(vq); flush_shadow_used_ring_split(dev, vq); vhost_vring_call_split(dev, vq); } - return (i - dropped); + return i; } __rte_noinline -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 17:39:32.803090760 +0800 +++ 0061-vhost-fix-memory-leak-in-Virtio-Tx-split-path.patch 2024-03-05 17:39:30.783566493 +0800 @@ -1 +1 @@ -From 7746fba831509fdb4c528266d0b38a89566e01e5 Mon Sep 17 00:00:00 2001 +From e951bbbd186c29ef86a3016ff30bc33b9dac35fa Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 7746fba831509fdb4c528266d0b38a89566e01e5 ] @@ -14 +16,0 @@ -Cc: stable@dpdk.org @@ -24 +26 @@ -index c738b7edc9..9951842b9f 100644 +index d00f4b03aa..895a79cf51 100644 @@ -58 +60 @@ - VHOST_DATA_LOG(dev->ifname, ERR, "failed to copy desc to mbuf."); + VHOST_LOG_DATA(dev->ifname, ERR, "failed to copy desc to mbuf.\n");