From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9U6i-0003TT-3l for qemu-devel@nongnu.org; Wed, 23 Nov 2016 04:44:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9U6f-0008AJ-1W for qemu-devel@nongnu.org; Wed, 23 Nov 2016 04:44:48 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34474) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c9U6e-00088x-PR for qemu-devel@nongnu.org; Wed, 23 Nov 2016 04:44:44 -0500 Received: by mail-wm0-x242.google.com with SMTP id g23so1342678wme.1 for ; Wed, 23 Nov 2016 01:44:44 -0800 (PST) Date: Wed, 23 Nov 2016 09:44:41 +0000 From: Stefan Hajnoczi Message-ID: <20161123094441.GD20034@stefanha-x1.localdomain> References: <1479832306-26440-1-git-send-email-stefanha@redhat.com> <1479832306-26440-10-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bajzpZikUji1w+G9" Content-Disposition: inline In-Reply-To: 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: Paolo Bonzini Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, borntraeger@de.ibm.com, Fam Zheng , Karl Rister --bajzpZikUji1w+G9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 22, 2016 at 06:21:24PM +0100, Paolo Bonzini wrote: >=20 >=20 > 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); >=20 > 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). >=20 > 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: >=20 > return run_poll_handlers(ctx, 0); >=20 > or just an instance of the loop, without qemu_clock_get_ns and the > tracepoints: >=20 > return run_poll_handlers_once(ctx); >=20 > and removing from patch 10 the >=20 > /* Handle any buffers that snuck in after we finished polling */ > virtio_queue_host_notifier_aio_poll(n); >=20 > ? I thought about the final poll but decided it was nicer for virtio.c to do it internally. Not all .io_poll_end() implementations may require an additional poll so it seemed more optimal to leave it up to each callback. If you prefer the run_poll_handlers_once(ctx) approach I'll switch to that. Stefan --bajzpZikUji1w+G9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJYNWUJAAoJEJykq7OBq3PIWAgH/RemRHN3UgO49LDXfDKCu4n0 d6SVxwCcAtSjqYA3LmU3uOaaYRajIdfrAtbo6aPnXyFWpBcTwG1TfdVIFni7vTZG BSuwP1BJ65D+0l7hEDFlJwOZySjeLvGDTyMBzrFaM/qyuK5XnWHQp3g0CYcN1yS0 5J5SV9bYlt8C1QJD2vFQbAKVOoOX1PGJzgovB/s/XjpbyJCktLi+x50tTfZaj+Cb zBMPus7j619+PVhHsHWIMQfPYhC87tgK1OWPBvPn4lLIuembX1JPCgRICipbpIUL 9hbG9uNmMTPsq2AREFNp/Lm7uXeuavpAH4ToblGrWYWxTCFqE6llGMAgyIeN1YM= =vEOs -----END PGP SIGNATURE----- --bajzpZikUji1w+G9--