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 A0932A0C45 for ; Mon, 13 Sep 2021 17:41:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 152F5410EF; Mon, 13 Sep 2021 17:41:25 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 7AA09410E5 for ; Mon, 13 Sep 2021 17:41:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631547683; 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=aiGP6dtMAWvc+IN6GYcYo6avmCe5fhINJjzZIgFMM5U=; b=T6QWqSkiV1Oi0Ptceus4ngGa0Y+Db5t5DhysmaOv+bci7Rp7NoYNqKlALus2mkz9dJBrrw fYC1VMD62j2lwDl80nQyaIyQkDAVC7fIhSI24NdhN3yEmN1XjIz5wccqN9ocNpfVJNLfQ6 iguOptxNIpy7EWbomf18+X4GXZWt6As= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-pdwt8bevNl2hWwnziedmbA-1; Mon, 13 Sep 2021 11:41:19 -0400 X-MC-Unique: pdwt8bevNl2hWwnziedmbA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB481824FAA; Mon, 13 Sep 2021 15:41:18 +0000 (UTC) Received: from [10.39.208.12] (unknown [10.39.208.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 874321972D; Mon, 13 Sep 2021 15:41:17 +0000 (UTC) To: Andrew Rybchenko , Chenbo Xia Cc: dev@dpdk.org, Ivan Ilchenko , stable@dpdk.org References: <20210818141329.2842686-1-andrew.rybchenko@oktetlabs.ru> <20210818141329.2842686-2-andrew.rybchenko@oktetlabs.ru> From: Maxime Coquelin Message-ID: <8983d9c0-0f7c-6feb-07fd-d40300e446c6@redhat.com> Date: Mon, 13 Sep 2021 17:41:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210818141329.2842686-2-andrew.rybchenko@oktetlabs.ru> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-stable] [PATCH 2/2] net/virtio: fix Tx completed mbufs leak on device stop 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 Sender: "stable" On 8/18/21 4:13 PM, Andrew Rybchenko wrote: > From: Ivan Ilchenko > > 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 > Signed-off-by: Andrew Rybchenko > --- > drivers/net/virtio/virtio_ethdev.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c > index e58085a2c9..ed3fefee7c 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -2393,6 +2393,34 @@ 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]; Maybe add a check to ensure that vq is non-NULL since it is dereferenced later without checking. > + xmit_cleanup(vq, virtqueue_nused(vq)); > + } > +} > + > /* > * Stop device: disable interrupt and mark link down > */ > @@ -2411,6 +2439,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); > >