[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 01/14] qemu coroutine: support bypass mode
From: |
Ming Lei |
Subject: |
[Qemu-devel] [PATCH RFC 01/14] qemu coroutine: support bypass mode |
Date: |
Thu, 17 Jul 2014 00:31:08 +0800 |
This patch introduces several APIs for supporting bypass qemu coroutine
in case of being not necessary and for performance's sake.
Signed-off-by: Ming Lei <address@hidden>
---
include/block/coroutine.h | 7 +++++++
include/block/coroutine_int.h | 5 +++++
qemu-coroutine-lock.c | 4 ++--
qemu-coroutine.c | 33 +++++++++++++++++++++++++++++++++
4 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/include/block/coroutine.h b/include/block/coroutine.h
index b9b7f48..9bd64da 100644
--- a/include/block/coroutine.h
+++ b/include/block/coroutine.h
@@ -234,4 +234,11 @@ void coroutine_fn yield_until_fd_readable(int fd);
*/
void qemu_coroutine_adjust_pool_size(int n);
+/* qemu coroutine bypass APIs */
+void qemu_coroutine_set_bypass(bool bypass);
+bool qemu_coroutine_bypassed(Coroutine *self);
+bool qemu_coroutine_self_bypassed(void);
+void qemu_coroutine_set_var(void *var);
+void *qemu_coroutine_get_var(void);
+
#endif /* QEMU_COROUTINE_H */
diff --git a/include/block/coroutine_int.h b/include/block/coroutine_int.h
index f133d65..106d0b2 100644
--- a/include/block/coroutine_int.h
+++ b/include/block/coroutine_int.h
@@ -39,6 +39,11 @@ struct Coroutine {
Coroutine *caller;
QSLIST_ENTRY(Coroutine) pool_next;
+ bool bypass;
+
+ /* only used in bypass mode */
+ void *opaque;
+
/* Coroutines that should be woken up when we yield or terminate */
QTAILQ_HEAD(, Coroutine) co_queue_wakeup;
QTAILQ_ENTRY(Coroutine) co_queue_next;
diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c
index e4860ae..7c69ff6 100644
--- a/qemu-coroutine-lock.c
+++ b/qemu-coroutine-lock.c
@@ -82,13 +82,13 @@ static bool qemu_co_queue_do_restart(CoQueue *queue, bool
single)
bool coroutine_fn qemu_co_queue_next(CoQueue *queue)
{
- assert(qemu_in_coroutine());
+ assert(qemu_in_coroutine() || qemu_coroutine_self_bypassed());
return qemu_co_queue_do_restart(queue, true);
}
void coroutine_fn qemu_co_queue_restart_all(CoQueue *queue)
{
- assert(qemu_in_coroutine());
+ assert(qemu_in_coroutine() || qemu_coroutine_self_bypassed());
qemu_co_queue_do_restart(queue, false);
}
diff --git a/qemu-coroutine.c b/qemu-coroutine.c
index bd574aa..324f5ad 100644
--- a/qemu-coroutine.c
+++ b/qemu-coroutine.c
@@ -157,3 +157,36 @@ void qemu_coroutine_adjust_pool_size(int n)
qemu_mutex_unlock(&pool_lock);
}
+
+void qemu_coroutine_set_bypass(bool bypass)
+{
+ Coroutine *self = qemu_coroutine_self();
+
+ self->bypass = bypass;
+}
+
+bool qemu_coroutine_bypassed(Coroutine *self)
+{
+ return self->bypass;
+}
+
+bool qemu_coroutine_self_bypassed(void)
+{
+ Coroutine *self = qemu_coroutine_self();
+
+ return qemu_coroutine_bypassed(self);
+}
+
+void qemu_coroutine_set_var(void *var)
+{
+ Coroutine *self = qemu_coroutine_self();
+
+ self->opaque = var;
+}
+
+void *qemu_coroutine_get_var(void)
+{
+ Coroutine *self = qemu_coroutine_self();
+
+ return self->opaque;
+}
--
1.7.9.5
- [Qemu-devel] [PATCH RFC 00/14] dataplane: performance optimization and multi virtqueue, Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 01/14] qemu coroutine: support bypass mode,
Ming Lei <=
- [Qemu-devel] [PATCH RFC 02/14] qemu aio: prepare for supporting selective bypass coroutine, Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 03/14] block: support to bypass qemu coroutinue, Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 04/14] Revert "raw-posix: drop raw_get_aio_fd() since it is no longer used", Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 05/14] dataplane: enable selective bypassing coroutine, Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 06/14] qemu/obj_pool.h: introduce object allocation pool, Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 07/14] dataplane: use object pool to speed up allocation for virtio blk request, Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 08/14] linux-aio: fix submit aio as a batch, Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 09/14] linux-aio: increase max event to 256, Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 10/14] linux-aio: remove 'node' from 'struct qemu_laiocb', Ming Lei, 2014/07/16
- [Qemu-devel] [PATCH RFC 11/14] hw/virtio-pci: introduce num_queues property, Ming Lei, 2014/07/16