Received: from eggs.gnu.org ([2001:4830:134:3::10]:53298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw2v3-0005YX-MJ for qemu-devel@nongnu.org; Mon, 17 Oct 2016 04:05:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bw2uy-00050f-Kk for qemu-devel@nongnu.org; Mon, 17 Oct 2016 04:05:13 -0400 Sender: Paolo Bonzini References: <1476380062-18001-1-git-send-email-pbonzini@redhat.com> <1476380062-18001-16-git-send-email-pbonzini@redhat.com> <20161016164010.GF2128@stefanha-x1.localdomain> From: Paolo Bonzini Message-ID: <23793765-8363-005e-c752-7534ce174a04@redhat.com> Date: Mon, 17 Oct 2016 10:04:59 +0200 MIME-Version: 1.0 In-Reply-To: <20161016164010.GF2128@stefanha-x1.localdomain> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 15/18] block: only call aio_poll on the current thread's AioContext List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, qemu-block@nongnu.org, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On 16/10/2016 18:40, Stefan Hajnoczi wrote: > > void bdrv_wakeup(BlockDriverState *bs) > > { > > + if (bs->wakeup) { > > + aio_bh_schedule_oneshot(qemu_get_aio_context(), dummy_bh_cb, NULL); > > + } > > } > > Why use a dummy BH instead of aio_notify()? Originally I used aio_bh_schedule_oneshot() because aio_notify() is not enough for aio_poll() to return true. It's also true that I am not using anymore the result of aio_poll, though. Since this is not a fast path and it's not very much stressed by qemu-iotests, I think it's better if we can move towards making aio_notify() more or less an internal detail. If you prefer aio_notify(), however, I can look into that as well. Thanks, Paolo >> > void bdrv_dec_in_flight(BlockDriverState *bs) >> > diff --git a/include/block/block.h b/include/block/block.h >> > index ba4318b..72d5d8e 100644 >> > --- a/include/block/block.h >> > +++ b/include/block/block.h >> > @@ -343,9 +343,27 @@ void bdrv_drain_all(void); >> > #define bdrv_poll_while(bs, cond) ({ \ >> > bool waited_ = false; \ >> > BlockDriverState *bs_ = (bs); \ >> > - while ((cond)) { \ >> > - aio_poll(bdrv_get_aio_context(bs_), true); \ >> > - waited_ = true; \ >> > + AioContext *ctx_ = bdrv_get_aio_context(bs_); \ >> > + if (aio_context_in_iothread(ctx_)) { \ >> > + while ((cond)) { \ >> > + aio_poll(ctx_, true); \ >> > + waited_ = true; \ >> > + } \ >> > + } else { \ >> > + assert(qemu_get_current_aio_context() == \ >> > + qemu_get_aio_context()); \ > The assumption is that IOThread #1 will never call bdrv_poll_while() on > IOThread #2's AioContext. I believe that is true today. Is this what > you had in mind? > > Please add a comment since it's not completely obvious from the assert > expression. >