From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFHgO-00050O-FI for qemu-devel@nongnu.org; Wed, 15 Jul 2015 04:04:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFHgH-0007ja-7A for qemu-devel@nongnu.org; Wed, 15 Jul 2015 04:04:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFHgH-0007iD-0y for qemu-devel@nongnu.org; Wed, 15 Jul 2015 04:04:41 -0400 Date: Wed, 15 Jul 2015 16:04:36 +0800 From: Fam Zheng Message-ID: <20150715080436.GD2412@ad.nay.redhat.com> References: <1436860421-4604-1-git-send-email-famz@redhat.com> <1436860421-4604-7-git-send-email-famz@redhat.com> <55A4D775.40006@redhat.com> <20150714094840.GD27873@ad.nay.redhat.com> <55A5EB61.2040108@redhat.com> <20150715060108.GC2412@ad.nay.redhat.com> <55A60DDE.3070804@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55A60DDE.3070804@redhat.com> Subject: Re: [Qemu-devel] [PATCH for-2.4 06/12] etsec: Flush queue when rx buffer is consumed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: Peter Maydell , Peter Crosthwaite , Rob Herring , qemu-devel@nongnu.org, Michael Walle , Gerd Hoffmann , stefanha@redhat.com, "Edgar E. Iglesias" On Wed, 07/15 15:38, Jason Wang wrote: > > > On 07/15/2015 02:01 PM, Fam Zheng wrote: > > On Wed, 07/15 13:10, Jason Wang wrote: > >>>> And can we do this without a bh? Otherwise, we may need to stop and > >>>> restart the bh during vm stop and start? > >>> A bh doesn't hurt when vm stop and restart (we get superfluous flush), > >> The problem is qemu_flush_queued_packets() does not check runstate. So > >> it may call .receive() which may modify guest state (DMA or registers). > > You're right, .can_receive will be called incorrectly if the following sequence > > of events is processed by main loop right after we schedule it: > > > > 1) QMP 'stop' command: > > Runstate is changed to STOP. > > > > 2) tap read: > > A new packet is read in, but since qemu_can_send_packet is false, it will > > be queued. > > > > 3) aio_dispatch: > > This BH is called too late here, and the queue is flushed, which calls > > .receive(). > > > > An ideal fix would be stopping tap with a vmstate handler, but for this patch, > > does the following work? > > Looks good for me. How about axienet then since in your series it also > uses a bh? Good point, the same applies, I'll fix that too. Fam