aboutsummaryrefslogtreecommitdiff
path: root/util/qemu-coroutine.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-02-13 19:12:40 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2017-02-21 11:39:40 +0000
commit480cff632221dc4d4889bf72dd0f09cd35096bc1 (patch)
tree8fd7a9adcdc981c7785d157d852cded18d4e9034 /util/qemu-coroutine.c
parentfed20a70e39bb9385020bdc4e8839d95326df8e2 (diff)
coroutine-lock: add limited spinning to CoMutex
Running a very small critical section on pthread_mutex_t and CoMutex shows that pthread_mutex_t is much faster because it doesn't actually go to sleep. What happens is that the critical section is shorter than the latency of entering the kernel and thus FUTEX_WAIT always fails. With CoMutex there is no such latency but you still want to avoid wait and wakeup. So introduce it artificially. This only works with one waiters; because CoMutex is fair, it will always have more waits and wakeups than a pthread_mutex_t. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-id: 20170213181244.16297-3-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'util/qemu-coroutine.c')
-rw-r--r--util/qemu-coroutine.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
index 415600dc30..72412e5649 100644
--- a/util/qemu-coroutine.c
+++ b/util/qemu-coroutine.c
@@ -118,7 +118,7 @@ void qemu_coroutine_enter(Coroutine *co)
co->ctx = qemu_get_current_aio_context();
/* Store co->ctx before anything that stores co. Matches
- * barrier in aio_co_wake.
+ * barrier in aio_co_wake and qemu_co_mutex_wake.
*/
smp_wmb();