[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/10] coroutines: Use one global bottom half for Co
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 08/10] coroutines: Use one global bottom half for CoQueue |
Date: |
Tue, 26 Jul 2011 13:49:06 +0200 |
Now that AsyncContexts don't exist any more, we can use one global bottom half
for restarting coroutines instead of allocating a new one every time (before
removing AsyncContexts, the problem with having a global BH was that it had to
belong to a single AsyncContexts and wouldn't be executed in a different one -
which leads to deadlocks)
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-coroutine-lock.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c
index abaa1f7..a80f437 100644
--- a/qemu-coroutine-lock.c
+++ b/qemu-coroutine-lock.c
@@ -30,14 +30,10 @@
static QTAILQ_HEAD(, Coroutine) unlock_bh_queue =
QTAILQ_HEAD_INITIALIZER(unlock_bh_queue);
-
-struct unlock_bh {
- QEMUBH *bh;
-};
+static QEMUBH* unlock_bh;
static void qemu_co_queue_next_bh(void *opaque)
{
- struct unlock_bh *unlock_bh = opaque;
Coroutine *next;
trace_qemu_co_queue_next_bh();
@@ -45,14 +41,15 @@ static void qemu_co_queue_next_bh(void *opaque)
QTAILQ_REMOVE(&unlock_bh_queue, next, co_queue_next);
qemu_coroutine_enter(next, NULL);
}
-
- qemu_bh_delete(unlock_bh->bh);
- qemu_free(unlock_bh);
}
void qemu_co_queue_init(CoQueue *queue)
{
QTAILQ_INIT(&queue->entries);
+
+ if (!unlock_bh) {
+ unlock_bh = qemu_bh_new(qemu_co_queue_next_bh, NULL);
+ }
}
void coroutine_fn qemu_co_queue_wait(CoQueue *queue)
@@ -65,7 +62,6 @@ void coroutine_fn qemu_co_queue_wait(CoQueue *queue)
bool qemu_co_queue_next(CoQueue *queue)
{
- struct unlock_bh *unlock_bh;
Coroutine *next;
next = QTAILQ_FIRST(&queue->entries);
@@ -73,10 +69,7 @@ bool qemu_co_queue_next(CoQueue *queue)
QTAILQ_REMOVE(&queue->entries, next, co_queue_next);
QTAILQ_INSERT_TAIL(&unlock_bh_queue, next, co_queue_next);
trace_qemu_co_queue_next(next);
-
- unlock_bh = qemu_malloc(sizeof(*unlock_bh));
- unlock_bh->bh = qemu_bh_new(qemu_co_queue_next_bh, unlock_bh);
- qemu_bh_schedule(unlock_bh->bh);
+ qemu_bh_schedule(unlock_bh);
}
return (next != NULL);
--
1.7.6
- [Qemu-devel] [PATCH 00/10] block: Coroutine support, Kevin Wolf, 2011/07/26
- [Qemu-devel] [PATCH 01/10] block: Add bdrv_co_readv/writev, Kevin Wolf, 2011/07/26
- [Qemu-devel] [PATCH 02/10] block: Emulate AIO functions with bdrv_co_readv/writev, Kevin Wolf, 2011/07/26
- [Qemu-devel] [PATCH 04/10] coroutines: Locks, Kevin Wolf, 2011/07/26
- [Qemu-devel] [PATCH 03/10] block: Add bdrv_co_readv/writev emulation, Kevin Wolf, 2011/07/26
- [Qemu-devel] [PATCH 05/10] qcow2: Use coroutines, Kevin Wolf, 2011/07/26
- [Qemu-devel] [PATCH 08/10] coroutines: Use one global bottom half for CoQueue,
Kevin Wolf <=
- [Qemu-devel] [PATCH 06/10] qcow: Use coroutines, Kevin Wolf, 2011/07/26
- [Qemu-devel] [PATCH 07/10] async: Remove AsyncContext, Kevin Wolf, 2011/07/26
- [Qemu-devel] [PATCH 10/10] block: Use bdrv_co_* instead of synchronous versions in coroutines, Kevin Wolf, 2011/07/26
- [Qemu-devel] [PATCH 09/10] posix-aio-compat: Allow read after EOF, Kevin Wolf, 2011/07/26