From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBcKO-0004lk-UR for qemu-devel@nongnu.org; Mon, 19 Aug 2013 23:10:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VBcKH-0006ld-15 for qemu-devel@nongnu.org; Mon, 19 Aug 2013 23:09:52 -0400 Received: from e28smtp05.in.ibm.com ([122.248.162.5]:35282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBcKG-0006hI-Bt for qemu-devel@nongnu.org; Mon, 19 Aug 2013 23:09:44 -0400 Received: from /spool/local by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Aug 2013 08:32:50 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id B8A1B394004E for ; Tue, 20 Aug 2013 08:39:01 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7K3AcGx33423514 for ; Tue, 20 Aug 2013 08:40:39 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7K399jp019095 for ; Tue, 20 Aug 2013 08:39:09 +0530 Message-ID: <5212DDCA.5060906@linux.vnet.ibm.com> Date: Tue, 20 Aug 2013 11:08:58 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1376598879-18976-1-git-send-email-alex@alex.org.uk> <1376598879-18976-14-git-send-email-alex@alex.org.uk> In-Reply-To: <1376598879-18976-14-git-send-email-alex@alex.org.uk> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCHv11 13/31] 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 , Jan Kiszka , qemu-devel@nongnu.org, liu ping fan , Stefan Hajnoczi , Paolo Bonzini , MORITA Kazutaka , rth@twiddle.net ÓÚ 2013-8-16 4:34, Alex Bligh дµÀ: > 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 2b9ba9b..d8656cc 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); glib will not set *timeout to a meaningful value before calling aio_ctx_prepare(), right? If so, "*timeout = 10" should be used. > } 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); > } > > static gboolean > -- Best Regards Wenchao Xia