patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
	Chenbo Xia <chenbo.xia@intel.com>
Cc: dev@dpdk.org, Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>,
	stable@dpdk.org
Subject: [dpdk-stable] [PATCH v2 2/2] net/virtio: fix Tx completed mbufs leak on device stop
Date: Wed, 15 Sep 2021 12:19:42 +0300	[thread overview]
Message-ID: <20210915091942.3604998-2-andrew.rybchenko@oktetlabs.ru> (raw)
In-Reply-To: <20210915091942.3604998-1-andrew.rybchenko@oktetlabs.ru>

From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>

Free Tx completed mbufs on device stop. Not completed Tx mbufs cannot be
freed since they are still in use.

Fixes: c1f86306a02 ("virtio: add new driver")
Cc: stable@dpdk.org

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
v2:
    - check vq pointer vs NULL before calling cleanup function

 drivers/net/virtio/virtio_ethdev.c | 31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index da1633d77e..3e3b42eaf6 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -2401,6 +2401,35 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
 	PMD_INIT_LOG(DEBUG, "%d mbufs freed", mbuf_num);
 }
 
+static void
+virtio_tx_completed_cleanup(struct rte_eth_dev *dev)
+{
+	struct virtio_hw *hw = dev->data->dev_private;
+	struct virtqueue *vq;
+	int qidx;
+	void (*xmit_cleanup)(struct virtqueue *vq, uint16_t nb_used);
+
+	if (virtio_with_packed_queue(hw)) {
+		if (hw->use_vec_tx)
+			xmit_cleanup = &virtio_xmit_cleanup_inorder_packed;
+		else if (virtio_with_feature(hw, VIRTIO_F_IN_ORDER))
+			xmit_cleanup = &virtio_xmit_cleanup_inorder_packed;
+		else
+			xmit_cleanup = &virtio_xmit_cleanup_normal_packed;
+	} else {
+		if (hw->use_inorder_tx)
+			xmit_cleanup = &virtio_xmit_cleanup_inorder;
+		else
+			xmit_cleanup = &virtio_xmit_cleanup;
+	}
+
+	for (qidx = 0; qidx < hw->max_queue_pairs; qidx++) {
+		vq = hw->vqs[2 * qidx + VTNET_SQ_TQ_QUEUE_IDX];
+		if (vq != NULL)
+			xmit_cleanup(vq, virtqueue_nused(vq));
+	}
+}
+
 /*
  * Stop device: disable interrupt and mark link down
  */
@@ -2419,6 +2448,8 @@ virtio_dev_stop(struct rte_eth_dev *dev)
 		goto out_unlock;
 	hw->started = 0;
 
+	virtio_tx_completed_cleanup(dev);
+
 	if (intr_conf->lsc || intr_conf->rxq) {
 		virtio_intr_disable(dev);
 
-- 
2.30.2


  reply	other threads:[~2021-09-15  9:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18 14:13 [dpdk-stable] [PATCH 1/2] net/virtio: fix Tx cleanup functions to have same signature Andrew Rybchenko
2021-08-18 14:13 ` [dpdk-stable] [PATCH 2/2] net/virtio: fix Tx completed mbufs leak on device stop Andrew Rybchenko
2021-09-13 15:41   ` Maxime Coquelin
2021-09-15  9:16     ` Andrew Rybchenko
2021-09-13 15:38 ` [dpdk-stable] [PATCH 1/2] net/virtio: fix Tx cleanup functions to have same signature Maxime Coquelin
2021-09-15  9:19 ` [dpdk-stable] [PATCH v2 " Andrew Rybchenko
2021-09-15  9:19   ` Andrew Rybchenko [this message]
2021-09-23 11:20     ` [dpdk-stable] [PATCH v2 2/2] net/virtio: fix Tx completed mbufs leak on device stop Maxime Coquelin
2021-09-28 15:30     ` Maxime Coquelin
2021-09-23 11:19   ` [dpdk-stable] [PATCH v2 1/2] net/virtio: fix Tx cleanup functions to have same signature Maxime Coquelin
2021-09-28 15:30   ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210915091942.3604998-2-andrew.rybchenko@oktetlabs.ru \
    --to=andrew.rybchenko@oktetlabs.ru \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=ivan.ilchenko@oktetlabs.ru \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).