From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7jZj-0006ub-03 for qemu-devel@nongnu.org; Fri, 09 Aug 2013 06:05:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V7jZd-0000UU-1E for qemu-devel@nongnu.org; Fri, 09 Aug 2013 06:05:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7jZc-0000UK-Or for qemu-devel@nongnu.org; Fri, 09 Aug 2013 06:05:32 -0400 Message-ID: <5204BEC6.4090303@redhat.com> Date: Fri, 09 Aug 2013 12:04:54 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1375998147-24292-1-git-send-email-alex@alex.org.uk> <1375998147-24292-13-git-send-email-alex@alex.org.uk> In-Reply-To: <1375998147-24292-13-git-send-email-alex@alex.org.uk> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC] [PATCHv8 12/30] aio / timers: aio_ctx_prepare sets timeout from AioContext timers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: Kevin Wolf , Anthony Liguori , liu ping fan , qemu-devel@nongnu.org, Stefan Hajnoczi , MORITA Kazutaka , rth@twiddle.net Il 08/08/2013 23:42, Alex Bligh ha scritto: > Calculate the timeout in aio_ctx_prepare taking into account > the timers attached to the AioContext. > > Alter aio_ctx_check similarly. > > Signed-off-by: Alex Bligh > --- > async.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/async.c b/async.c > index 2051921..dd27459 100644 > --- a/async.c > +++ b/async.c > @@ -150,13 +150,14 @@ aio_ctx_prepare(GSource *source, gint *timeout) > { > AioContext *ctx = (AioContext *) source; > QEMUBH *bh; > + int deadline; > > for (bh = ctx->first_bh; bh; bh = bh->next) { > if (!bh->deleted && bh->scheduled) { > if (bh->idle) { > /* idle bottom halves will be polled at least > * every 10ms */ > - *timeout = 10; > + *timeout = qemu_soonest_timeout(*timeout, 10); > } else { > /* non-idle bottom halves will be executed > * immediately */ > @@ -166,6 +167,14 @@ aio_ctx_prepare(GSource *source, gint *timeout) > } > } > > + deadline = qemu_timeout_ns_to_ms(timerlistgroup_deadline_ns(ctx->tlg)); > + if (deadline == 0) { > + *timeout = 0; > + return true; > + } else { > + *timeout = qemu_soonest_timeout(*timeout, deadline); > + } > + > return false; > } > > @@ -180,7 +189,7 @@ aio_ctx_check(GSource *source) > return true; > } > } > - return aio_pending(ctx); > + return aio_pending(ctx) || (timerlistgroup_deadline_ns(ctx->tlg) == 0); Again, if we do the "two AioContext" tricks, the timerlistgroup_deadline_ns function would be internal to AioContext. Paolo > } > > static gboolean >