Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-20 Thread Stefan Hajnoczi
On Wed, Jun 19, 2013 at 11:27:25AM +0200, Paolo Bonzini wrote: > Il 19/06/2013 00:26, mdroth ha scritto: > > On Tue, Jun 18, 2013 at 09:20:26PM +0200, Paolo Bonzini wrote: > >> Il 18/06/2013 17:14, mdroth ha scritto: > >>> Could we possibly simplify this by introducing a recursive mutex that we > >

Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-19 Thread Paolo Bonzini
Il 19/06/2013 00:26, mdroth ha scritto: > On Tue, Jun 18, 2013 at 09:20:26PM +0200, Paolo Bonzini wrote: >> Il 18/06/2013 17:14, mdroth ha scritto: >>> Could we possibly simplify this by introducing a recursive mutex that we >>> could use to protect the whole list loop and hold even during the cb?

Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-18 Thread mdroth
On Tue, Jun 18, 2013 at 09:20:26PM +0200, Paolo Bonzini wrote: > Il 18/06/2013 17:14, mdroth ha scritto: > > Could we possibly simplify this by introducing a recursive mutex that we > > could use to protect the whole list loop and hold even during the cb? > > If it is possible, we should avoid rec

Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-18 Thread Paolo Bonzini
Il 18/06/2013 17:14, mdroth ha scritto: > Could we possibly simplify this by introducing a recursive mutex that we > could use to protect the whole list loop and hold even during the cb? If it is possible, we should avoid recursive locks. It makes impossible to establish a lock hierarchy. For ex

Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-18 Thread mdroth
On Tue, Jun 18, 2013 at 10:14:38AM -0500, mdroth wrote: > On Sun, Jun 16, 2013 at 07:21:21PM +0800, Liu Ping Fan wrote: > > BH will be used outside big lock, so introduce lock to protect > > between the writers, ie, bh's adders and deleter. > > Note that the lock only affects the writers and bh's c

Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-18 Thread mdroth
On Sun, Jun 16, 2013 at 07:21:21PM +0800, Liu Ping Fan wrote: > BH will be used outside big lock, so introduce lock to protect > between the writers, ie, bh's adders and deleter. > Note that the lock only affects the writers and bh's callback does > not take this extra lock. > > Signed-off-by: Liu

Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-18 Thread Stefan Hajnoczi
On Tue, Jun 18, 2013 at 10:19:40AM +0800, liu ping fan wrote: > On Mon, Jun 17, 2013 at 11:28 PM, Stefan Hajnoczi wrote: > > On Sun, Jun 16, 2013 at 07:21:21PM +0800, Liu Ping Fan wrote: > > Why lock bh_lock before assigning bh->next? Could you lock the mutex > > here and then drop the smp_wmb()

Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-17 Thread liu ping fan
On Mon, Jun 17, 2013 at 11:28 PM, Stefan Hajnoczi wrote: > On Sun, Jun 16, 2013 at 07:21:21PM +0800, Liu Ping Fan wrote: >> @@ -47,8 +47,12 @@ QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void >> *opaque) >> bh->ctx = ctx; >> bh->cb = cb; >> bh->opaque = opaque; >> +qemu

Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-17 Thread Paolo Bonzini
Il 17/06/2013 17:28, Stefan Hajnoczi ha scritto: >> > +qemu_mutex_lock(&ctx->bh_lock); >> > bh->next = ctx->first_bh; >> > +/* Make sure the memebers ready before putting bh into list */ > s/memebers/members/ > >> > +smp_wmb(); > Why lock bh_lock before assigning bh->next? Could

Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-17 Thread Stefan Hajnoczi
On Sun, Jun 16, 2013 at 07:21:21PM +0800, Liu Ping Fan wrote: > @@ -47,8 +47,12 @@ QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void > *opaque) > bh->ctx = ctx; > bh->cb = cb; > bh->opaque = opaque; > +qemu_mutex_lock(&ctx->bh_lock); > bh->next = ctx->first_bh; > +

[Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant

2013-06-16 Thread Liu Ping Fan
BH will be used outside big lock, so introduce lock to protect between the writers, ie, bh's adders and deleter. Note that the lock only affects the writers and bh's callback does not take this extra lock. Signed-off-by: Liu Ping Fan --- async.c | 21 + include/bl