From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 1D98C5689; Fri, 1 Sep 2017 09:14:10 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 01 Sep 2017 00:14:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,457,1498546800"; d="scan'208";a="1190481158" Received: from debian-zgviawfucg.sh.intel.com (HELO debian-ZGViaWFuCg) ([10.67.104.160]) by fmsmga001.fm.intel.com with ESMTP; 01 Sep 2017 00:13:59 -0700 Date: Fri, 1 Sep 2017 15:14:26 +0800 From: Tiwei Bie To: Jens Freimann Cc: dev@dpdk.org, yliu@fridaylinux.org, maxime.coquelin@redhat.com, stable@dpdk.org Message-ID: <20170901071426.GA25578@debian-ZGViaWFuCg> References: <20170829082601.30349-1-tiwei.bie@intel.com> <20170830091306.a5whdd7xrgb4jbtn@dhcp-192-218.str.redhat.com> <20170830102423.GA15019@debian-ZGViaWFuCg> <20170901062646.iek4azi6nez7vyrr@dhcp-192-218.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170901062646.iek4azi6nez7vyrr@dhcp-192-218.str.redhat.com> User-Agent: Mutt/1.7.2 (2016-11-26) Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] net/virtio: fix an incorrect behavior of device stop/start X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Sep 2017 07:14:11 -0000 On Fri, Sep 01, 2017 at 08:26:46AM +0200, Jens Freimann wrote: > On Wed, Aug 30, 2017 at 06:24:24PM +0800, Tiwei Bie wrote: > > Hi Jens, > > > > On Wed, Aug 30, 2017 at 11:13:06AM +0200, Jens Freimann wrote: > > > Hi Tiwei, > > > > > > On Tue, Aug 29, 2017 at 04:26:01PM +0800, Tiwei Bie wrote: > > > > After starting a device, the driver shouldn't deliver the > > > > packets that already existed in the device before it is > > > > started to the applications. This patch fixes this issue > > > > by flushing the Rx queues when starting the device. > > > > > > > > Fixes: a85786dc816f ("virtio: fix states handling during initialization") > > > > Cc: stable@dpdk.org > > > > > > > > Signed-off-by: Tiwei Bie > > > > --- > > > > drivers/net/virtio/virtio_ethdev.c | 6 ++++++ > > > > drivers/net/virtio/virtio_rxtx.c | 2 +- > > > > drivers/net/virtio/virtqueue.c | 25 +++++++++++++++++++++++++ > > > > drivers/net/virtio/virtqueue.h | 5 +++++ > > > > 4 files changed, 37 insertions(+), 1 deletion(-) > > > > > > why don't we flush Tx queues as well? > > > > > > > The elements in the used ring of Tx queues won't be delivered > > to the applications. They don't contain any (packet) data, and > > will just be recycled during Tx. So there is no need to flush > > the Tx queues. > > ok, but it would hurt either because it's not performance relevant and > we could be sure to always start with an empty queue. It can be done > in a different patch though I guess. > Yeah, I think it's not relevant to this (bug) fix. I prefer to keep this fix (which is supposed to be backported to the stable branch) small. And it's more like some refinements which won't introduce any functional change, and can be done in a different patch if someone wants it. > > > > > > > > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c > > > > index e320811..6d60bc1 100644 > > > > --- a/drivers/net/virtio/virtio_ethdev.c > > > > +++ b/drivers/net/virtio/virtio_ethdev.c > > > > @@ -1737,6 +1737,12 @@ virtio_dev_start(struct rte_eth_dev *dev) > > > > } > > > > } > > > > > > > > + /* Flush the packets in Rx queues. */ > > > > + for (i = 0; i < dev->data->nb_rx_queues; i++) { > > > > + rxvq = dev->data->rx_queues[i]; > > > > + virtqueue_flush(rxvq->vq); > > > > + } > > > > + > > > > > > A little bit further down is a for loop going over rx queues calling > > > notify. Could we flush directly before the notify and save the > > > additional loop? > > > > > > > I saw there is also another `for' loop to dump the Rx queues. > > And I think it makes the code more readable to flush the Rx > > queues in a separate `for' loop too. Besides, this function > > isn't performance critical. So I didn't combine them into one > > `for' loop. > > To me code is better readable when it is concise, so I'd still vote for > combining the loops if its logically equivalent. > > On the other hand I think this should be fixed soon, so > > Reviewed-by: Jens Freimann > Thank you! :-) It's not a big deal. I'd like to leave it up to the maintainers. They can make the decision when applying the patch. Best regards, Tiwei Bie