Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-09-12 Thread Stefan Hajnoczi
On Tue, Sep 10, 2013 at 02:42:10PM -0500, Michael Roth wrote: Quoting Stefan Hajnoczi (2013-08-29 02:43:02) On Thu, Aug 29, 2013 at 09:09:45AM +0800, Wenchao Xia wrote: 于 2013-8-28 16:49, Stefan Hajnoczi 写道: On Wed, Aug 28, 2013 at 11:25:33AM +0800, Wenchao Xia wrote: +void

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-09-10 Thread Michael Roth
Quoting Stefan Hajnoczi (2013-08-29 02:43:02) On Thu, Aug 29, 2013 at 09:09:45AM +0800, Wenchao Xia wrote: 于 2013-8-28 16:49, Stefan Hajnoczi 写道: On Wed, Aug 28, 2013 at 11:25:33AM +0800, Wenchao Xia wrote: +void aio_context_release(AioContext *ctx) +{ +

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-30 Thread Stefan Hajnoczi
On Thu, Aug 29, 2013 at 10:26:31AM +0200, Paolo Bonzini wrote: Il 27/08/2013 16:39, Stefan Hajnoczi ha scritto: +void aio_context_acquire(AioContext *ctx) +{ +qemu_mutex_lock(ctx-acquire_lock); +while (ctx-owner) { +assert(!qemu_thread_is_self(ctx-owner)); +

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-30 Thread Paolo Bonzini
Il 30/08/2013 11:22, Stefan Hajnoczi ha scritto: On Thu, Aug 29, 2013 at 10:26:31AM +0200, Paolo Bonzini wrote: Il 27/08/2013 16:39, Stefan Hajnoczi ha scritto: +void aio_context_acquire(AioContext *ctx) +{ +qemu_mutex_lock(ctx-acquire_lock); +while (ctx-owner) { +

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-30 Thread Stefan Hajnoczi
On Fri, Aug 30, 2013 at 3:24 PM, Paolo Bonzini pbonz...@redhat.com wrote: Il 30/08/2013 11:22, Stefan Hajnoczi ha scritto: On Thu, Aug 29, 2013 at 10:26:31AM +0200, Paolo Bonzini wrote: Il 27/08/2013 16:39, Stefan Hajnoczi ha scritto: +void aio_context_acquire(AioContext *ctx) +{ +

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-29 Thread Stefan Hajnoczi
On Thu, Aug 29, 2013 at 09:09:45AM +0800, Wenchao Xia wrote: 于 2013-8-28 16:49, Stefan Hajnoczi 写道: On Wed, Aug 28, 2013 at 11:25:33AM +0800, Wenchao Xia wrote: +void aio_context_release(AioContext *ctx) +{ +qemu_mutex_lock(ctx-acquire_lock); +assert(ctx-owner

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-29 Thread Paolo Bonzini
Il 27/08/2013 16:39, Stefan Hajnoczi ha scritto: +void aio_context_acquire(AioContext *ctx) +{ +qemu_mutex_lock(ctx-acquire_lock); +while (ctx-owner) { +assert(!qemu_thread_is_self(ctx-owner)); +aio_notify(ctx); /* kick current owner */ +

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-29 Thread Wenchao Xia
于 2013-8-27 22:39, Stefan Hajnoczi 写道: It can be useful to run an AioContext from a thread which normally does not own the AioContext. For example, request draining can be implemented by acquiring the AioContext and looping aio_poll() until all requests have been completed. The following

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-28 Thread Stefan Hajnoczi
On Wed, Aug 28, 2013 at 11:25:33AM +0800, Wenchao Xia wrote: +void aio_context_release(AioContext *ctx) +{ +qemu_mutex_lock(ctx-acquire_lock); +assert(ctx-owner qemu_thread_is_self(ctx-owner)); +ctx-owner = NULL; +qemu_cond_signal(ctx-acquire_cond); +

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-28 Thread Wenchao Xia
于 2013-8-28 16:49, Stefan Hajnoczi 写道: On Wed, Aug 28, 2013 at 11:25:33AM +0800, Wenchao Xia wrote: +void aio_context_release(AioContext *ctx) +{ +qemu_mutex_lock(ctx-acquire_lock); +assert(ctx-owner qemu_thread_is_self(ctx-owner)); +ctx-owner = NULL; +

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-27 Thread Paolo Bonzini
Il 27/08/2013 16:39, Stefan Hajnoczi ha scritto: It can be useful to run an AioContext from a thread which normally does not own the AioContext. For example, request draining can be implemented by acquiring the AioContext and looping aio_poll() until all requests have been completed. The

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-27 Thread Alex Bligh
--On 27 August 2013 16:39:45 +0200 Stefan Hajnoczi stefa...@redhat.com wrote: This patch implements aio_context_acquire() and aio_context_release(). Note that existing aio_poll() callers do not need to worry about acquiring and releasing - it is only needed when multiple threads will call

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-27 Thread Wenchao Xia
于 2013-8-27 23:12, Paolo Bonzini 写道: Il 27/08/2013 16:39, Stefan Hajnoczi ha scritto: It can be useful to run an AioContext from a thread which normally does not own the AioContext. For example, request draining can be implemented by acquiring the AioContext and looping aio_poll() until all

Re: [Qemu-devel] [RFC] aio: add aio_context_acquire() and aio_context_release()

2013-08-27 Thread Wenchao Xia
The APIs look nice to me, have some minor comments. It can be useful to run an AioContext from a thread which normally does not own the AioContext. For example, request draining can be implemented by acquiring the AioContext and looping aio_poll() until all requests have been completed.