Received: from eggs.gnu.org ([2001:4830:134:3::10]:46756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4oZQ-0005Yc-FF for qemu-devel@nongnu.org; Wed, 09 Jul 2014 05:53:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4oZH-00014X-Eb for qemu-devel@nongnu.org; Wed, 09 Jul 2014 05:53:48 -0400 Received: from mail-qc0-x231.google.com ([2607:f8b0:400d:c01::231]:43535) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4oZH-00014J-Aa for qemu-devel@nongnu.org; Wed, 09 Jul 2014 05:53:39 -0400 Received: by mail-qc0-f177.google.com with SMTP id r5so6394546qcx.36 for ; Wed, 09 Jul 2014 02:53:38 -0700 (PDT) Received: from yakj.usersys.redhat.com (net-2-35-201-190.cust.vodafonedsl.it. [2.35.201.190]) by mx.google.com with ESMTPSA id j97sm31669122qgd.37.2014.07.09.02.53.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 02:53:38 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 9 Jul 2014 11:53:07 +0200 Message-Id: <1404899590-24973-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1404899590-24973-1-git-send-email-pbonzini@redhat.com> References: <1404899590-24973-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 07/10] aio-win32: add aio_set_dispatching optimization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Paolo Bonzini --- aio-win32.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/aio-win32.c b/aio-win32.c index 1ec434a..fd52686 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -144,12 +144,25 @@ bool aio_poll(AioContext *ctx, bool blocking) { AioHandler *node; HANDLE events[MAXIMUM_WAIT_OBJECTS + 1]; - bool progress, first; + bool was_dispatching, progress, first; int count; int timeout; + was_dispatching = ctx->dispatching; progress = false; + /* aio_notify can avoid the expensive event_notifier_set if + * everything (file descriptors, bottom halves, timers) will + * be re-evaluated before the next blocking poll(). This is + * already true when aio_poll is called with blocking == false; + * if blocking == true, it is only true after poll() returns. + * + * If we're in a nested event loop, ctx->dispatching might be true. + * In that case we can restore it just before returning, but we + * have to clear it now. + */ + aio_set_dispatching(ctx, !blocking); + ctx->walking_handlers++; /* fill fd sets */ @@ -170,6 +183,7 @@ bool aio_poll(AioContext *ctx, bool blocking) timeout = blocking ? qemu_timeout_ns_to_ms(aio_compute_timeout(ctx)) : 0; ret = WaitForMultipleObjects(count, events, FALSE, timeout); + aio_set_dispatching(ctx, true); if (first && aio_bh_poll(ctx)) { progress = true; @@ -191,5 +205,6 @@ bool aio_poll(AioContext *ctx, bool blocking) progress |= timerlistgroup_run_timers(&ctx->tlg); + aio_set_dispatching(ctx, was_dispatching); return progress; } -- 1.9.3