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 4EEF743829 for ; Tue, 5 Mar 2024 16:35:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4ABC0415D7; Tue, 5 Mar 2024 16:35:42 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 9E141415D7 for ; Tue, 5 Mar 2024 16:35:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709652940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wHl58ORjo2fA9pgXdpAzUDVOmOZ8xZCA3DZgdKlBIDo=; b=DlWfrH7I9zWwSU+O578CZW5cHqwemo7ZMC/X02PB3TEfRxOavtD4LtC6JUgQ/u4JxY0ohw Xq0ZNw4bvFG5EecIz/J2MZ37KdFQVs/ieqxKaa8ITuIYpsEmuLLQH6x6MONIltzmE5gVtn HCTPDhTznhGqBUfM6GnQcXdEQGdHF0k= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-537-HEI0Vv3NNtCaHTs7TIK4zw-1; Tue, 05 Mar 2024 10:35:37 -0500 X-MC-Unique: HEI0Vv3NNtCaHTs7TIK4zw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 603211C0514D for ; Tue, 5 Mar 2024 15:35:37 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C980200AE7F; Tue, 5 Mar 2024 15:35:35 +0000 (UTC) From: Kevin Traynor 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 21.11.7 Date: Tue, 5 Mar 2024 15:34:03 +0000 Message-ID: <20240305153449.263666-30-ktraynor@redhat.com> In-Reply-To: <20240305153449.263666-1-ktraynor@redhat.com> References: <20240305153449.263666-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 21.11.7 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/11/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://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/b3ec4db23d97a9b4be49777fc70ea95619051a4a Thanks. Kevin --- >From b3ec4db23d97a9b4be49777fc70ea95619051a4a 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 [ 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 | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index b211799687..fa0779d03d 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -2518,5 +2518,4 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, uint16_t i; uint16_t free_entries; - uint16_t dropped = 0; static bool allocerr_warned; @@ -2558,9 +2557,6 @@ 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; @@ -2579,6 +2575,4 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, allocerr_warned = true; } - dropped += 1; - i++; break; } @@ -2593,24 +2587,19 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, 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; } -- 2.43.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 14:08:55.403464317 +0000 +++ 0030-vhost-fix-memory-leak-in-Virtio-Tx-split-path.patch 2024-03-05 14:08:54.646520755 +0000 @@ -1 +1 @@ -From 7746fba831509fdb4c528266d0b38a89566e01e5 Mon Sep 17 00:00:00 2001 +From b3ec4db23d97a9b4be49777fc70ea95619051a4a Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 7746fba831509fdb4c528266d0b38a89566e01e5 ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -20,2 +21,2 @@ - lib/vhost/virtio_net.c | 24 ++++++------------------ - 1 file changed, 6 insertions(+), 18 deletions(-) + lib/vhost/virtio_net.c | 23 ++++++----------------- + 1 file changed, 6 insertions(+), 17 deletions(-) @@ -24 +25 @@ -index c738b7edc9..9951842b9f 100644 +index b211799687..fa0779d03d 100644 @@ -27 +28 @@ -@@ -3105,5 +3105,4 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, +@@ -2518,5 +2518,4 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, @@ -29 +30 @@ - uint16_t avail_entries; + uint16_t free_entries; @@ -33 +34 @@ -@@ -3144,9 +3143,6 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, +@@ -2558,9 +2557,6 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, @@ -44 +45 @@ -@@ -3165,6 +3161,4 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, +@@ -2579,6 +2575,4 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, @@ -51 +52 @@ -@@ -3177,25 +3171,19 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, +@@ -2593,24 +2587,19 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, @@ -58 +58,0 @@ --