From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH] net/virtio: fix an incorrect behavior of device stop/start Date: Thu, 19 Oct 2017 21:53:14 +0800 Message-ID: <20171019135314.GA1545@yliu-home> 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> <20170901071426.GA25578@debian-ZGViaWFuCg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jens Freimann , dev@dpdk.org, maxime.coquelin@redhat.com, stable@dpdk.org To: Tiwei Bie Return-path: Content-Disposition: inline In-Reply-To: <20170901071426.GA25578@debian-ZGViaWFuCg> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Sep 01, 2017 at 03:14:26PM +0800, Tiwei Bie wrote: > > > > 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. Otherwise? I'm assuming you fixed a real issue? If so, it'd be better if you can add a bit info about the issue. > This patch fixes this issue > > > > > by flushing the Rx queues when starting the device. > > > > > > > > > > Fixes: a85786dc816f ("virtio: fix states handling during initialization") ... > > > > > @@ -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. I agree with Jens here. We already have too many for loops in this function. Let's not add yet another one. Besides that, the VIRTQUEU_DUMP loop probably should also be removed and more it to the notify loop. --yliu