Re: [Qemu-devel] [PATCH v2 3/3] AioContext: fix broken ctx->dispatching optimization

2015-07-17 Thread Stefan Hajnoczi
On Fri, Jul 17, 2015 at 06:17:47AM +0200, Paolo Bonzini wrote: > > > On 16/07/2015 11:56, Paolo Bonzini wrote: > > @@ -286,13 +283,15 @@ bool aio_poll(AioContext *ctx, bool blocking) > > npfd = 0; > > ctx->walking_handlers--; > > > > +if (blocking) { > > +atomic_sub(&ctx->

Re: [Qemu-devel] [PATCH v2 3/3] AioContext: fix broken ctx->dispatching optimization

2015-07-16 Thread Paolo Bonzini
On 16/07/2015 11:56, Paolo Bonzini wrote: > @@ -286,13 +283,15 @@ bool aio_poll(AioContext *ctx, bool blocking) > npfd = 0; > ctx->walking_handlers--; > > +if (blocking) { > +atomic_sub(&ctx->notify_me, 2); > +} > + I kept this place for subtracting notify_me because

Re: [Qemu-devel] [PATCH v2 3/3] AioContext: fix broken ctx->dispatching optimization

2015-07-16 Thread Paolo Bonzini
On 17/07/2015 04:25, Fam Zheng wrote: > What if aio_notify happens after the previous aio_dispatch() but before the > next necessary atomic_add? The aio_notify would still skip the > event_notifier_set(), and the next ppoll() will not return. For example: > > Thread A

Re: [Qemu-devel] [PATCH v2 3/3] AioContext: fix broken ctx->dispatching optimization

2015-07-16 Thread Fam Zheng
On Thu, 07/16 11:56, Paolo Bonzini wrote: > diff --git a/aio-posix.c b/aio-posix.c > index 4abec38..268d14d 100644 > --- a/aio-posix.c > +++ b/aio-posix.c > @@ -233,26 +233,23 @@ static void add_pollfd(AioHandler *node) > bool aio_poll(AioContext *ctx, bool blocking) > { > AioHandler *node;

[Qemu-devel] [PATCH v2 3/3] AioContext: fix broken ctx->dispatching optimization

2015-07-16 Thread Paolo Bonzini
This patch rewrites the ctx->dispatching optimization, which was the cause of some mysterious hangs that could be reproduced on aarch64 KVM only. The hangs were indirectly caused by aio_poll() and in particular by flash memory updates's call to blk_write(), which invokes aio_poll(). Fun stuff: they