On Thu, Jul 3, 2014 at 6:59 PM, Paolo Bonzini <pbonz...@redhat.com> wrote:
Looks like a very interesting optimization for the block layer. If we can get some performance results - especially how it improves the virtio-blk dataplane regression - maybe we should merge it for 2.1. > @@ -247,9 +248,22 @@ ThreadPool *aio_get_thread_pool(AioContext *ctx) > return ctx->thread_pool; > } > > +void aio_set_dispatching(AioContext *ctx, bool dispatching) > +{ > + ctx->dispatching = dispatching; > + /* Write ctx->dispatching before reading e.g. bh->scheduled. */ > + if (!dispatching) { > + smp_mb(); > + } Is the if statement necessary? It seems like an optimization to avoid the memory barrier in 50% of the calls. But by avoiding the barrier it could cause other threads to "miss" the dispatching period on machines with weak memory models. I guess that's fine since we're not trying to optimize other threads but more focussing on callers from the event loop's own thread. Anyway, the if statement makes this function trickier than it has to be IMO. Want to drop it?