From 3de89ce9fb5eda46f7cefd70e9090cb7cd7ec803 Mon Sep 17 00:00:00 2001 From: Yang Zhong Date: Wed, 28 Mar 2018 20:14:53 +0800 Subject: [PATCH 1/2] 9p: removing coroutines of 9p to increase the I/O performance This is a quick workaround, need to be fixed. Signed-off-by: Chao Peng --- hw/9pfs/9p.c | 12 +++++------- hw/9pfs/9p.h | 6 +++--- hw/9pfs/coth.h | 3 +++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 9e046f7acb..11c8ee08d9 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1082,10 +1082,7 @@ static void coroutine_fn pdu_complete(V9fsPDU *pdu, ssize_t len) out_notify: pdu->s->transport->push_and_notify(pdu); - /* Now wakeup anybody waiting in flush for this request */ - if (!qemu_co_queue_next(&pdu->complete)) { - pdu_free(pdu); - } + pdu_free(pdu); } static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension) @@ -3997,7 +3994,7 @@ static inline bool is_read_only_op(V9fsPDU *pdu) void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr) { - Coroutine *co; +// Coroutine *co; CoroutineEntry *handler; V9fsState *s = pdu->s; @@ -4015,8 +4012,9 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr) } qemu_co_queue_init(&pdu->complete); - co = qemu_coroutine_create(handler, pdu); - qemu_coroutine_enter(co); + handler(pdu); + //co = qemu_coroutine_create(handler, pdu); + //qemu_coroutine_enter(co); } /* Returns 0 on success, 1 on failure. */ diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index b8f72a3bd9..d16bf9d05e 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -391,21 +391,21 @@ extern int total_open_fd; static inline void v9fs_path_write_lock(V9fsState *s) { if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) { - qemu_co_rwlock_wrlock(&s->rename_lock); + // qemu_co_rwlock_wrlock(&s->rename_lock); } } static inline void v9fs_path_read_lock(V9fsState *s) { if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) { - qemu_co_rwlock_rdlock(&s->rename_lock); + // qemu_co_rwlock_rdlock(&s->rename_lock); } } static inline void v9fs_path_unlock(V9fsState *s) { if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) { - qemu_co_rwlock_unlock(&s->rename_lock); + // qemu_co_rwlock_unlock(&s->rename_lock); } } diff --git a/hw/9pfs/coth.h b/hw/9pfs/coth.h index c2cdc7a9ea..0fe971d1f5 100644 --- a/hw/9pfs/coth.h +++ b/hw/9pfs/coth.h @@ -46,6 +46,9 @@ qemu_coroutine_yield(); \ } while (0) +#undef v9fs_co_run_in_worker +#define v9fs_co_run_in_worker(code_block) do {code_block} while(0); + void co_run_in_worker_bh(void *); int coroutine_fn v9fs_co_readlink(V9fsPDU *, V9fsPath *, V9fsString *); int coroutine_fn v9fs_co_readdir(V9fsPDU *, V9fsFidState *, struct dirent **); -- 2.21.0