提交 a9d92355 编写于 作者: P Paolo Bonzini 提交者: Stefan Hajnoczi

coroutine-lock: reschedule coroutine on the AioContext it was running on

As a small step towards the introduction of multiqueue, we want
coroutines to remain on the same AioContext that started them,
unless they are moved explicitly with e.g. aio_co_schedule.  This patch
avoids that coroutines switch AioContext when they use a CoMutex.
For now it does not make much of a difference, because the CoMutex
is not thread-safe and the AioContext itself is used to protect the
CoMutex from concurrent access.  However, this is going to change.
Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NFam Zheng <famz@redhat.com>
Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
Message-id: 20170213135235.12274-9-pbonzini@redhat.com
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 ff82911c
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "qemu/coroutine.h" #include "qemu/coroutine.h"
#include "qemu/coroutine_int.h" #include "qemu/coroutine_int.h"
#include "qemu/queue.h" #include "qemu/queue.h"
#include "block/aio.h"
#include "trace.h" #include "trace.h"
void qemu_co_queue_init(CoQueue *queue) void qemu_co_queue_init(CoQueue *queue)
...@@ -63,7 +64,6 @@ void qemu_co_queue_run_restart(Coroutine *co) ...@@ -63,7 +64,6 @@ void qemu_co_queue_run_restart(Coroutine *co)
static bool qemu_co_queue_do_restart(CoQueue *queue, bool single) static bool qemu_co_queue_do_restart(CoQueue *queue, bool single)
{ {
Coroutine *self = qemu_coroutine_self();
Coroutine *next; Coroutine *next;
if (QSIMPLEQ_EMPTY(&queue->entries)) { if (QSIMPLEQ_EMPTY(&queue->entries)) {
...@@ -72,8 +72,7 @@ static bool qemu_co_queue_do_restart(CoQueue *queue, bool single) ...@@ -72,8 +72,7 @@ static bool qemu_co_queue_do_restart(CoQueue *queue, bool single)
while ((next = QSIMPLEQ_FIRST(&queue->entries)) != NULL) { while ((next = QSIMPLEQ_FIRST(&queue->entries)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&queue->entries, co_queue_next); QSIMPLEQ_REMOVE_HEAD(&queue->entries, co_queue_next);
QSIMPLEQ_INSERT_TAIL(&self->co_queue_wakeup, next, co_queue_next); aio_co_wake(next);
trace_qemu_co_queue_next(next);
if (single) { if (single) {
break; break;
} }
......
...@@ -28,7 +28,6 @@ qemu_coroutine_terminate(void *co) "self %p" ...@@ -28,7 +28,6 @@ qemu_coroutine_terminate(void *co) "self %p"
# util/qemu-coroutine-lock.c # util/qemu-coroutine-lock.c
qemu_co_queue_run_restart(void *co) "co %p" qemu_co_queue_run_restart(void *co) "co %p"
qemu_co_queue_next(void *nxt) "next %p"
qemu_co_mutex_lock_entry(void *mutex, void *self) "mutex %p self %p" qemu_co_mutex_lock_entry(void *mutex, void *self) "mutex %p self %p"
qemu_co_mutex_lock_return(void *mutex, void *self) "mutex %p self %p" qemu_co_mutex_lock_return(void *mutex, void *self) "mutex %p self %p"
qemu_co_mutex_unlock_entry(void *mutex, void *self) "mutex %p self %p" qemu_co_mutex_unlock_entry(void *mutex, void *self) "mutex %p self %p"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册