From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCVdm-0007JV-Nj for qemu-devel@nongnu.org; Tue, 07 Jul 2015 12:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCVdl-0000sa-Nw for qemu-devel@nongnu.org; Tue, 07 Jul 2015 12:22:38 -0400 References: <1435670385-625-1-git-send-email-famz@redhat.com> <1435670385-625-5-git-send-email-famz@redhat.com> <20150707150850.GG28673@stefanha-thinkpad.redhat.com> From: Paolo Bonzini Message-ID: <559BEFD4.7050103@redhat.com> Date: Tue, 7 Jul 2015 17:27:16 +0200 MIME-Version: 1.0 In-Reply-To: <20150707150850.GG28673@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 4/4] aio-posix: Use epoll in aio_poll List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , Fam Zheng Cc: Kevin Wolf , qemu-devel@nongnu.org, qemu-block@nongnu.org On 07/07/2015 17:08, Stefan Hajnoczi wrote: >> > + >> > +#define EPOLL_BATCH 128 >> > +static bool aio_poll_epoll(AioContext *ctx, bool blocking) >> > +{ >> > + AioHandler *node; >> > + bool was_dispatching; >> > + int i, ret; >> > + bool progress; >> > + int64_t timeout; >> > + struct epoll_event events[EPOLL_BATCH]; >> > + >> > + aio_context_acquire(ctx); >> > + 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++; >> > + >> > + timeout = blocking ? aio_compute_timeout(ctx) : 0; >> > + >> > + if (timeout > 0) { >> > + timeout = DIV_ROUND_UP(timeout, 1000000); >> > + } > I think you already posted the timerfd code in an earlier series. Why > degrade to millisecond precision? It needs to be fixed up anyway if the > main loop uses aio_poll() in the future. BTW, what about putting the code in a separate aio-epoll.c file? Paolo