[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC 4/4] aio-posix: Use epoll in aio_poll
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH RFC 4/4] aio-posix: Use epoll in aio_poll |
Date: |
Tue, 7 Jul 2015 17:27:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 |
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