From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9ElC-0002xs-AW for qemu-devel@nongnu.org; Tue, 22 Nov 2016 12:21:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9El9-0007Pr-3V for qemu-devel@nongnu.org; Tue, 22 Nov 2016 12:21:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47448) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9El8-0007PW-So for qemu-devel@nongnu.org; Tue, 22 Nov 2016 12:21:31 -0500 References: <1479832306-26440-1-git-send-email-stefanha@redhat.com> <1479832306-26440-10-git-send-email-stefanha@redhat.com> From: Paolo Bonzini Message-ID: Date: Tue, 22 Nov 2016 18:21:24 +0100 MIME-Version: 1.0 In-Reply-To: <1479832306-26440-10-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 09/10] aio: add .io_poll_begin/end() callbacks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: borntraeger@de.ibm.com, Karl Rister , Fam Zheng On 22/11/2016 17:31, Stefan Hajnoczi wrote: > +static bool try_poll_mode(AioContext *ctx, bool enable) > +{ > + if (enable && aio_poll_max_ns && ctx->poll_disable_cnt =3D=3D 0) { > + /* See qemu_soonest_timeout() uint64_t hack */ > + int64_t max_ns =3D MIN((uint64_t)aio_compute_timeout(ctx), > + (uint64_t)aio_poll_max_ns); > + > + if (max_ns) { > + poll_set_started(ctx, true); > + > + if (run_poll_handlers(ctx, max_ns)) { > + return true; > + } > + } > + } > + > + poll_set_started(ctx, false); You could do a single iteration even if enable =3D=3D false (which I'd rename to blocking, BTW, because poll_start can be false on exit even if enable =3D=3D true). In fact, since (like virtio_queue_host_notifier_aio_poll_end) all .io_poll_end() callbacks are going to poll once more, what about adding here: return run_poll_handlers(ctx, 0); or just an instance of the loop, without qemu_clock_get_ns and the tracepoints: return run_poll_handlers_once(ctx); and removing from patch 10 the /* Handle any buffers that snuck in after we finished polling */ virtio_queue_host_notifier_aio_poll(n); ? Thanks, Paolo