[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 2/2] QEMUBH: make AioContext's bh re-entrant
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v3 2/2] QEMUBH: make AioContext's bh re-entrant |
Date: |
Thu, 20 Jun 2013 09:39:24 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Thu, Jun 20, 2013 at 04:59:29AM +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. The lock only
> affects the writers and bh's callback does not take this extra lock.
> Note that for the same AioContext, aio_bh_poll() can not run in
> parallel yet.
>
> Signed-off-by: Liu Ping Fan <address@hidden>
> ---
> async.c | 22 ++++++++++++++++++++++
> include/block/aio.h | 5 +++++
> 2 files changed, 27 insertions(+)
qemu_bh_cancel() and qemu_bh_delete() are not modified by this patch.
It seems that calling them from a thread is a little risky because there
is no guarantee that the BH is no longer invoked after a thread calls
these functions.
I think that's worth a comment or do you want them to take the lock so
they become safe?
The other thing I'm unclear on is the ->idle assignment followed
immediately by a ->scheduled assignment. Without memory barriers
aio_bh_poll() isn't guaranteed to get an ordered view of these updates:
it may see an idle BH as a regular scheduled BH because ->idle is still
0.
Stefan