linux-aio: Convert to coroutines
RFC PATCH 1/3 qemu-img bench
In reply to Kevin WolfThis adds a qemu-img command that allows doing some simple benchmarks for the block layer without involving guest devices and a real VM.
For the start, this implements only a test of sequential reads.
--- qemu-img-cmds.hx | 6 ++ qemu-img.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-img.texi | 10 ++++ 3 files changed, 190 insertions(+)
qemu-img-cmds.hx +6 -0
@@ -9,6 +9,12 @@ STEXI @table @option ETEXI +DEF("bench", img_bench, + "bench [-c count] [-d depth] [-f fmt] [-n] [-q] [-s buffer_size] [-t cache] filename") +STEXI +@item bench [-c @var{count}] [-d @var{depth}] [-f @var{fmt}] [-n] [-q] [-s @var{buffer_size}] [-t @var{cache}] @var{filename} +ETEXI + DEF("check", img_check, "check [-q] [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] filename") STEXI
qemu-img.c +174 -0
180 lines not on this page · raw message
qemu-img.texi +10 -0
@@ -117,6 +117,16 @@ Skip the creation of the target volume Command description: @table @option +@item bench [-c @var{count}] [-d @var{depth}] [-f @var{fmt}] [-n] [-q] [-s @var{buffer_size}] [-t @var{cache}] @var{filename} + +Run a simple sequential read benchmark on the specified image. A total number +of @var{count} I/O requests is performed, each @var{buffer_size} bytes in size, +and with @var{depth} requests in parallel. + +If @code{-n} is specified, the native AIO backend is used if possible. On +Linux, this option has no effect unless @code{-t none} or @code{-t directsync} +is specified as well. + @item check [-f @var{fmt}] [--output=@var{ofmt}] [-r [leaks | all]] [-T @var{src_cache}] @var{filename} Perform a consistency check on the disk image @var{filename}. The command can
Signature · 1 line
1.8.3.1
RFC PATCH 3/3 linux-aio: Don't reenter request coroutine recursively
In reply to Kevin WolfWhen getting an error while submitting requests, we must be careful to wake up only inactive coroutines. Therefore we must special-case the currently active coroutine and communicate an error for that request using the ordinary return value of ioq_submit().
--- block/linux-aio.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
block/linux-aio.c +16 -7
@@ -177,12 +177,19 @@ static int ioq_submit(struct qemu_laio_state *s) container_of(s->io_q.iocbs[i], struct qemu_laiocb, iocb); laiocb->ret = (ret <0 ) ? ret : -EIO ; -qemu_laio_process_completion (s, laiocb); +if (laiocb->co !=qemu_coroutine_self ()) { +qemu_coroutine_enter (laiocb->co,NULL ); + }else { +/* The return value is used for the currently active coroutine. +* We're always in ioq_enqueue() here, ioq_submit() never runs from +* a request's coroutine.*/ + ret = laiocb->ret; + } }return ret; } -static void ioq_enqueue (struct qemu_laio_state *s,struct iocb *iocb) +static int ioq_enqueue (struct qemu_laio_state *s,struct iocb *iocb) {unsigned int idx = s->io_q.idx;
@@ -191,7 +198,9 @@ static void ioq_enqueue(struct qemu_laio_state *s, struct iocb *iocb)/* submit immediately if queue is full */ if (idx == s->io_q.size) { -ioq_submit (s); +return ioq_submit (s); + }else { +return 0 ; } }
@@ -253,11 +262,11 @@ int laio_submit_co(BlockDriverState *bs, void *aio_ctx, int fd,if (!s->io_q.plugged) { ret =io_submit (s->ctx,1 , &iocbs); -if (ret <0 ) { -return ret; - } }else { -ioq_enqueue (s, iocbs); + ret =ioq_enqueue (s, iocbs); + } +if (ret <0 ) { +return ret; }qemu_coroutine_yield ();
Signature · 1 line
1.8.3.1
cover linux-aio: Convert to coroutines
This is my current branch for converting the linux-aio interface to coroutines. I started this as a performance optimisation, but I think it also makes it much easier to avoid the recursive coroutine reentrace that Ming Lei has sent a relatively complex callback-based patch for. See patch 3 for a quick attempt on fixing the same problem in a coroutine-based linux-aio implementation.
Not ready to be merged mainly because of incomplete testing and benchmarking.
Kevin Wolf (3):
qemu-img bench
raw-posix: Convert Linux AIO submission to coroutines
linux-aio: Don't reenter request coroutine recursively
block/linux-aio.c | 89 +++++++++++----------------- block/raw-aio.h | 5 +- block/raw-posix.c | 62 +++++++++---------- qemu-img-cmds.hx | 6 ++ qemu-img.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-img.texi | 10 ++++ 6 files changed, 256 insertions(+), 90 deletions(-)
Signature · 1 line
1.8.3.1
RFC PATCH 2/3 raw-posix: Convert Linux AIO submission to coroutines
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
As a side effect, the codepath taken by aio=threads is changed to use paio_submit_co(). This doesn't change the performance at this point.
Results of qemu-img bench -t none -c 10000000 [-n] /dev/loop0:
| aio=native | aio=threads
| before | with patch | before | with patch
------+----------+------------+----------+------------
run 1 | 29.921s | 26.932s | 35.286s | 35.447s
run 2 | 29.793s | 26.252s | 35.276s | 35.111s
run 3 | 30.186s | 27.114s | 35.042s | 34.921s
run 4 | 30.425s | 26.600s | 35.169s | 34.968s
run 5 | 30.041s | 26.263s | 35.224s | 35.000sTODO: Do some more serious benchmarking in VMs with less variance. Results of a quick fio run are vaguely positive.
--- block/linux-aio.c | 70 +++++++++++++++++-------------------------------------- block/raw-aio.h | 5 ++-- block/raw-posix.c | 62 ++++++++++++++++++++++-------------------------- 3 files changed, 52 insertions(+), 85 deletions(-)
block/linux-aio.c +22 -48
@@ -12,6 +12,7 @@#include "qemu/queue.h" #include "block/raw-aio.h" #include "qemu/event_notifier.h" +#include "block/coroutine.h" #include <libaio.h>
@@ -28,7 +29,7 @@#define MAX_QUEUED_IO 128struct qemu_laiocb { -BlockAIOCB common; +Coroutine *co;struct qemu_laio_state *ctx;struct iocb iocb;ssize_t ret;
@@ -86,9 +87,9 @@ static void qemu_laio_process_completion(struct qemu_laio_state *s, } } } - laiocb->common.cb (laiocb->common.opaque, ret); -qemu_aio_unref (laiocb); + laiocb->ret = ret; +qemu_coroutine_enter (laiocb->co,NULL ); }/* The completion BH fetches completed I/O requests and invokes their
@@ -146,30 +147,6 @@ static void qemu_laio_completion_cb(EventNotifier *e) } } -static void laio_cancel (BlockAIOCB *blockacb) -{ -struct qemu_laiocb *laiocb = (struct qemu_laiocb *)blockacb; -struct io_event event; -int ret; - -if (laiocb->ret != -EINPROGRESS ) { -return ; - } - ret =io_cancel (laiocb->ctx->ctx, &laiocb->iocb, &event); - laiocb->ret = -ECANCELED ; -if (ret !=0 ) { -/* iocb is not cancelled, cb will be called by the event loop later */ -return ; - } - - laiocb->common.cb (laiocb->common.opaque, laiocb->ret); -} - -static const AIOCBInfo laio_aiocb_info = { - .aiocb_size =sizeof (struct qemu_laiocb ), - .cancel_async = laio_cancel, -}; -static void ioq_init (LaioQueue *io_q) { io_q->size =MAX_QUEUED_IO ;
@@ -243,23 +220,21 @@ int laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug)return ret; } -BlockAIOCB *laio_submit (BlockDriverState *bs,void *aio_ctx,int fd, -int64_t sector_num,QEMUIOVector *qiov,int nb_sectors, -BlockCompletionFunc *cb,void *opaque,int type) +int laio_submit_co (BlockDriverState *bs,void *aio_ctx,int fd, +int64_t sector_num,QEMUIOVector *qiov,int nb_sectors,int type) {struct qemu_laio_state *s = aio_ctx; -struct qemu_laiocb *laiocb; -struct iocb *iocbs;off_t offset = sector_num *512 ; - laiocb =qemu_aio_get (&laio_aiocb_info, bs, cb, opaque); - laiocb->nbytes = nb_sectors *512 ; - laiocb->ctx = s; - laiocb->ret = -EINPROGRESS ; - laiocb->is_read = (type ==QEMU_AIO_READ ); - laiocb->qiov = qiov; - - iocbs = &laiocb->iocb; +struct qemu_laiocb laiocb = { + .co =qemu_coroutine_self (), + .nbytes = nb_sectors *512 , + .ctx = s, + .is_read = (type ==QEMU_AIO_READ ), + .qiov = qiov, + }; +struct iocb *iocbs = &laiocb.iocb; +int ret;switch (type) {case QEMU_AIO_WRITE :
@@ -272,22 +247,21 @@ BlockAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,default :fprintf (stderr,"%s: invalid AIO request type 0x%x.\n" , __func__, type); - goto out_free_aiocb; +return -EIO ; } -io_set_eventfd (&laiocb->iocb,event_notifier_get_fd (&s->e)); +io_set_eventfd (&laiocb.iocb,event_notifier_get_fd (&s->e));if (!s->io_q.plugged) { -if (io_submit (s->ctx,1 , &iocbs) <0 ) { - goto out_free_aiocb; + ret =io_submit (s->ctx,1 , &iocbs); +if (ret <0 ) { +return ret; } }else {ioq_enqueue (s, iocbs); } -return &laiocb->common; -out_free_aiocb: -qemu_aio_unref (laiocb); -return NULL ; +qemu_coroutine_yield (); +return laiocb.ret; }void laio_detach_aio_context (void *s_,AioContext *old_context)
block/raw-aio.h +2 -3
@@ -35,9 +35,8 @@#ifdef CONFIG_LINUX_AIO void *laio_init (void );void laio_cleanup (void *s); -BlockAIOCB *laio_submit (BlockDriverState *bs,void *aio_ctx,int fd, -int64_t sector_num,QEMUIOVector *qiov,int nb_sectors, -BlockCompletionFunc *cb,void *opaque,int type); +int laio_submit_co (BlockDriverState *bs,void *aio_ctx,int fd, +int64_t sector_num,QEMUIOVector *qiov,int nb_sectors,int type);void laio_detach_aio_context (void *s,AioContext *old_context);void laio_attach_aio_context (void *s,AioContext *new_context);void laio_io_plug (BlockDriverState *bs,void *aio_ctx);
block/raw-posix.c +28 -34
118 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
Quoted 18 lines · Kevin Wolf
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
As a side effect, the codepath taken by aio=threads is changed to use
paio_submit_co(). This doesn't change the performance at this point.Results of qemu-img bench -t none -c 10000000 [-n]
/dev/loop0:| aio=native | aio=threads | before | with patch | before | with patch ------+----------+------------+----------+------------ run 1 | 29.921s | 26.932s | 35.286s | 35.447s run 2 | 29.793s | 26.252s | 35.276s | 35.111s run 3 | 30.186s | 27.114s | 35.042s | 34.921s run 4 | 30.425s | 26.600s | 35.169s | 34.968s run 5 | 30.041s | 26.263s | 35.224s | 35.000s
Quoted 2 lines
TODO: Do some more serious benchmarking in VMs with less variance. Results of a quick fio run are vaguely positive.
I still see the main-loop spun warnings with this patches applied to master. It wasn't there with the original patch from August.
~/git/qemu$ ./qemu-img bench -t none -c 10000000 -n /dev/ram1 Sending 10000000 requests, 4096 bytes each, 64 in parallel
main-loop: WARNING: I/O thread spun for 1000 iterations Run completed in 31.947 seconds.
Peter
Quoted 283 lines
Signed-off-by Kevin Wolf <[email protected]>--- block/linux-aio.c | 70 +++++++++++++++++-------------------------------------- block/raw-aio.h | 5 ++-- block/raw-posix.c | 62 ++++++++++++++++++++++-------------------------- 3 files changed, 52 insertions(+), 85 deletions(-)block/linux-aio.c +22
-48@@ -12,6 +12,7 @@#include "qemu/queue.h" #include "block/raw-aio.h" #include "qemu/event_notifier.h" +#include "block/coroutine.h" #include <libaio.h> @@ -28,7 +29,7 @@#define MAX_QUEUED_IO 128struct qemu_laiocb { -BlockAIOCB common; +Coroutine *co;struct qemu_laio_state *ctx;struct iocb iocb;ssize_t ret;@@ -86,9 +87,9 @@ static void qemu_laio_process_completion(struct qemu_laio_state *s, } } } - laiocb->common.cb (laiocb->common.opaque, ret); -qemu_aio_unref (laiocb); + laiocb->ret = ret; +qemu_coroutine_enter (laiocb->co,NULL ); }/* The completion BH fetches completed I/O requests and invokes their @@ -146,30 +147,6 @@ static void qemu_laio_completion_cb(EventNotifier *e) } } -static void laio_cancel (BlockAIOCB *blockacb) -{ -struct qemu_laiocb *laiocb = (struct qemu_laiocb *)blockacb; -struct io_event event; -int ret; - -if (laiocb->ret != -EINPROGRESS ) { -return ; - } - ret =io_cancel (laiocb->ctx->ctx, &laiocb->iocb, &event); - laiocb->ret = -ECANCELED ; -if (ret !=0 ) { -/* iocb is not cancelled, cb will be called by the event loop later */ -return ; - } - - laiocb->common.cb (laiocb->common.opaque, laiocb->ret); -} - -static const AIOCBInfo laio_aiocb_info = { - .aiocb_size =sizeof (struct qemu_laiocb ), - .cancel_async = laio_cancel, -}; -static void ioq_init (LaioQueue *io_q) { io_q->size =MAX_QUEUED_IO ;@@ -243,23 +220,21 @@ int laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug)return ret; } -BlockAIOCB *laio_submit (BlockDriverState *bs,void *aio_ctx,int fd, -int64_t sector_num,QEMUIOVector *qiov,int nb_sectors, -BlockCompletionFunc *cb,void *opaque,int type) +int laio_submit_co (BlockDriverState *bs,void *aio_ctx,int fd, +int64_t sector_num,QEMUIOVector *qiov,int nb_sectors,int type) {struct qemu_laio_state *s = aio_ctx; -struct qemu_laiocb *laiocb; -struct iocb *iocbs;off_t offset = sector_num *512 ; - laiocb =qemu_aio_get (&laio_aiocb_info, bs, cb, opaque); - laiocb->nbytes = nb_sectors *512 ; - laiocb->ctx = s; - laiocb->ret = -EINPROGRESS ; - laiocb->is_read = (type ==QEMU_AIO_READ ); - laiocb->qiov = qiov; - - iocbs = &laiocb->iocb; +struct qemu_laiocb laiocb = { + .co =qemu_coroutine_self (), + .nbytes = nb_sectors *512 , + .ctx = s, + .is_read = (type ==QEMU_AIO_READ ), + .qiov = qiov, + }; +struct iocb *iocbs = &laiocb.iocb; +int ret;switch (type) {case QEMU_AIO_WRITE :@@ -272,22 +247,21 @@ BlockAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,default :fprintf (stderr,"%s: invalid AIO request type 0x%x.\n" , __func__, type); - goto out_free_aiocb; +return -EIO ; } -io_set_eventfd (&laiocb->iocb,event_notifier_get_fd (&s->e)); +io_set_eventfd (&laiocb.iocb,event_notifier_get_fd (&s->e));if (!s->io_q.plugged) { -if (io_submit (s->ctx,1 , &iocbs) <0 ) { - goto out_free_aiocb; + ret =io_submit (s->ctx,1 , &iocbs); +if (ret <0 ) { +return ret; } }else {ioq_enqueue (s, iocbs); } -return &laiocb->common; -out_free_aiocb: -qemu_aio_unref (laiocb); -return NULL ; +qemu_coroutine_yield (); +return laiocb.ret; }void laio_detach_aio_context (void *s_,AioContext *old_context)block/raw-aio.h +2
-3@@ -35,9 +35,8 @@#ifdef CONFIG_LINUX_AIO void *laio_init (void );void laio_cleanup (void *s); -BlockAIOCB *laio_submit (BlockDriverState *bs,void *aio_ctx,int fd, -int64_t sector_num,QEMUIOVector *qiov,int nb_sectors, -BlockCompletionFunc *cb,void *opaque,int type); +int laio_submit_co (BlockDriverState *bs,void *aio_ctx,int fd, +int64_t sector_num,QEMUIOVector *qiov,int nb_sectors,int type);void laio_detach_aio_context (void *s,AioContext *old_context);void laio_attach_aio_context (void *s,AioContext *new_context);void laio_io_plug (BlockDriverState *bs,void *aio_ctx);block/raw-posix.c +28
-34@@ -1075,14 +1075,13 @@ static BlockAIOCB *paio_submit(BlockDriverState *bs, int fd,return thread_pool_submit_aio (pool, aio_worker, acb, cb, opaque); } -static BlockAIOCB *raw_aio_submit (BlockDriverState *bs, -int64_t sector_num,QEMUIOVector *qiov,int nb_sectors, -BlockCompletionFunc *cb,void *opaque,int type) +static int coroutine_fn raw_co_rw(BlockDriverState *bs, int64_t sector_num, +int nb_sectors,QEMUIOVector *qiov,int type) {BDRVRawState *s = bs->opaque;if (fd_open (bs) <0 ) -return NULL ; +return -EIO ;/* * Check if the underlying device requires requests to be aligned, @@ -1095,14 +1094,25 @@ static BlockAIOCB *raw_aio_submit(BlockDriverState *bs, type |=QEMU_AIO_MISALIGNED ; #ifdef CONFIG_LINUX_AIO }else if (s->use_aio) { -return laio_submit (bs, s->aio_ctx, s->fd, sector_num, qiov, - nb_sectors, cb, opaque, type); +return laio_submit_co (bs, s->aio_ctx, s->fd, sector_num, qiov, + nb_sectors, type);#endif } } -return paio_submit (bs, s->fd, sector_num, qiov, nb_sectors, - cb, opaque, type); +return paio_submit_co (bs, s->fd, sector_num, qiov, nb_sectors, type); +} + +static int coroutine_fn raw_co_readv(BlockDriverState *bs, int64_t sector_num, +int nb_sectors,QEMUIOVector *qiov) +{ +return raw_co_rw (bs, sector_num, nb_sectors, qiov,QEMU_AIO_READ ); +} + +static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num, +int nb_sectors,QEMUIOVector *qiov) +{ +return raw_co_rw (bs, sector_num, nb_sectors, qiov,QEMU_AIO_WRITE ); }static void raw_aio_plug (BlockDriverState *bs)@@ -1135,22 +1145,6 @@ static void raw_aio_flush_io_queue(BlockDriverState *bs)#endif } -static BlockAIOCB *raw_aio_readv (BlockDriverState *bs, -int64_t sector_num,QEMUIOVector *qiov,int nb_sectors, -BlockCompletionFunc *cb,void *opaque) -{ -return raw_aio_submit (bs, sector_num, qiov, nb_sectors, - cb, opaque,QEMU_AIO_READ ); -} - -static BlockAIOCB *raw_aio_writev (BlockDriverState *bs, -int64_t sector_num,QEMUIOVector *qiov,int nb_sectors, -BlockCompletionFunc *cb,void *opaque) -{ -return raw_aio_submit (bs, sector_num, qiov, nb_sectors, - cb, opaque,QEMU_AIO_WRITE ); -} -static BlockAIOCB *raw_aio_flush (BlockDriverState *bs,BlockCompletionFunc *cb,void *opaque) {@@ -1701,8 +1695,8 @@ static BlockDriver bdrv_file = { .bdrv_co_get_block_status = raw_co_get_block_status, .bdrv_co_write_zeroes = raw_co_write_zeroes, - .bdrv_aio_readv = raw_aio_readv, - .bdrv_aio_writev = raw_aio_writev, + .bdrv_co_readv = raw_co_readv, + .bdrv_co_writev = raw_co_writev, .bdrv_aio_flush = raw_aio_flush, .bdrv_aio_discard = raw_aio_discard, .bdrv_refresh_limits = raw_refresh_limits,@@ -2103,8 +2097,8 @@ static BlockDriver bdrv_host_device = { .create_opts = &raw_create_opts, .bdrv_co_write_zeroes = hdev_co_write_zeroes, - .bdrv_aio_readv = raw_aio_readv, - .bdrv_aio_writev = raw_aio_writev, + .bdrv_co_readv = raw_co_readv, + .bdrv_co_writev = raw_co_writev, .bdrv_aio_flush = raw_aio_flush, .bdrv_aio_discard = hdev_aio_discard, .bdrv_refresh_limits = raw_refresh_limits,@@ -2252,8 +2246,8 @@ static BlockDriver bdrv_host_floppy = { .bdrv_create = hdev_create, .create_opts = &raw_create_opts, - .bdrv_aio_readv = raw_aio_readv, - .bdrv_aio_writev = raw_aio_writev, + .bdrv_co_readv = raw_co_readv, + .bdrv_co_writev = raw_co_writev, .bdrv_aio_flush = raw_aio_flush, .bdrv_refresh_limits = raw_refresh_limits, .bdrv_io_plug = raw_aio_plug,@@ -2383,8 +2377,8 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_create = hdev_create, .create_opts = &raw_create_opts, - .bdrv_aio_readv = raw_aio_readv, - .bdrv_aio_writev = raw_aio_writev, + .bdrv_co_readv = raw_co_readv, + .bdrv_co_writev = raw_co_writev, .bdrv_aio_flush = raw_aio_flush, .bdrv_refresh_limits = raw_refresh_limits, .bdrv_io_plug = raw_aio_plug,@@ -2520,8 +2514,8 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_create = hdev_create, .create_opts = &raw_create_opts, - .bdrv_aio_readv = raw_aio_readv, - .bdrv_aio_writev = raw_aio_writev, + .bdrv_co_readv = raw_co_readv, + .bdrv_co_writev = raw_co_writev, .bdrv_aio_flush = raw_aio_flush, .bdrv_refresh_limits = raw_refresh_limits, .bdrv_io_plug = raw_aio_plug,
Signature · 16 lines
Mit freundlichen Grüßen Peter Lieven ........................................................... KAMP Netzwerkdienste GmbH Vestische Str. 89-91 | 46117 Oberhausen Tel: +49 (0) 208.89 402-50 | Fax: +49 (0) 208.89 402-40 [email protected] | http://www.kamp.de Geschäftsführer: Heiner Lante | Michael Lante Amtsgericht Duisburg | HRB Nr. 12154 USt-Id-Nr.: DE 120607556 ...........................................................
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
In reply to Kevin WolfHi Kevin,
Quoted 3 lines · Kevin Wolf
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
I am not sure it is good way for linux aio optimization:
- for raw image with some constraint, coroutine can be avoided since io_submit() won't sleep most of times
- handling one time coroutine takes much time than handling malloc, memset and free on small buffer, following the test data:
-- 241ns per coroutine
-- 61ns per (malloc, memset, free for 128bytes)
I still think we should figure out a fast path to avoid cocourinte for linux-aio with raw image, otherwise it can't scale well for high IOPS device.
Also we can use simple buf pool to avoid the dynamic allocation easily, can't we?
Quoted 15 lines
As a side effect, the codepath taken by aio=threads is changed to use
paio_submit_co(). This doesn't change the performance at this point.Results of qemu-img bench -t none -c 10000000 [-n]
/dev/loop0:| aio=native | aio=threads | before | with patch | before | with patch ------+----------+------------+----------+------------ run 1 | 29.921s | 26.932s | 35.286s | 35.447s run 2 | 29.793s | 26.252s | 35.276s | 35.111s run 3 | 30.186s | 27.114s | 35.042s | 34.921s run 4 | 30.425s | 26.600s | 35.169s | 34.968s run 5 | 30.041s | 26.263s | 35.224s | 35.000s
Quoted 2 lines
TODO: Do some more serious benchmarking in VMs with less variance. Results of a quick fio run are vaguely positive.
I will do the test with Paolo's fast path approach under VM I/O situation.
Thanks,
Ming Lei
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
Quoted 9 lines · Ming Lei
Hi Kevin,
Quoted 3 lines · Kevin Wolf
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
I am not sure it is good way for linux aio optimization:
Quoted 7 lines
- for raw image with some constraint, coroutine can be avoided since
io_submit()won't sleep most of times- handling one time coroutine takes much time than handling malloc, memset and free on small buffer, following the test data:
-- 241ns per coroutine
What do you mean by "coroutine" here? Create + destroy? Yield?
Quoted 8 lines
-- 61ns per (malloc, memset, free for 128bytes)
I still think we should figure out a fast path to avoid cocourinte for linux-aio with raw image, otherwise it can't scale well for high IOPS device.
Also we can use simple buf pool to avoid the dynamic allocation easily, can't we?
[...]
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
Quoted 14 lines · Markus Armbruster
Quoted 12 lines · Ming Lei
Hi Kevin,
Quoted 3 lines · Kevin Wolf
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
I am not sure it is good way for linux aio optimization:
- for raw image with some constraint, coroutine can be avoided since
io_submit()won't sleep most of times
Quoted 6 lines
Quoted 4 lines
- handling one time coroutine takes much time than handling malloc, memset and free on small buffer, following the test data:
-- 241ns per coroutine
What do you mean by "coroutine" here? Create + destroy? Yield?
Please see perf_cost() in tests/test-coroutine.c
Thanks,
Ming Lei
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
Quoted 15 lines · Ming Lei
Quoted 14 lines · Markus Armbruster
Quoted 12 lines · Ming Lei
Hi Kevin,
Quoted 3 lines · Kevin Wolf
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
I am not sure it is good way for linux aio optimization:
- for raw image with some constraint, coroutine can be avoided since
io_submit()won't sleep most of times
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
- handling one time coroutine takes much time than handling malloc, memset and free on small buffer, following the test data:
-- 241ns per coroutine
What do you mean by "coroutine" here? Create + destroy? Yield?
Please see
perf_cost()intests/test-coroutine.c
static __attribute__((noinline)) void perf_cost_func(void *opaque)
{
qemu_coroutine_yield();
}
static void perf_cost(void)
{
const unsigned long maxcycles = 40000000;
unsigned long i = 0;
double duration;
unsigned long ops;
Coroutine *co;
g_test_timer_start();
while (i++ < maxcycles) {
co = qemu_coroutine_create(perf_cost_func);
qemu_coroutine_enter(co, &i);
qemu_coroutine_enter(co, NULL);
}
duration = g_test_timer_elapsed();
ops = (long)(maxcycles / (duration * 1000));
g_test_message("Run operation %lu iterations %f s, %luK operations/s, "
"%luns per coroutine",
maxcycles,
duration, ops,
(unsigned long)(1000000000 * duration) / maxcycles);
}This tests create, enter, yield, reenter, terminate, destroy. The cost of create + destroy may well dominate.
If we create and destroy coroutines for each AIO request, we're doing it wrong. I doubt Kevin's doing it *that* wrong ;)
Anyway, let's benchmark the real code instead of putting undue trust in tests/test-coroutine.c micro-benchmarks.
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
Quoted 57 lines · Markus Armbruster
Quoted 16 lines · Ming Lei
Quoted 15 lines · Markus Armbruster
Quoted 13 lines · Ming Lei
Hi Kevin,
Quoted 4 lines · Kevin Wolf
This improves the performance of requests because an ACB doesn't need to
be allocated on the heap any more. It also makes the code nicer and smaller.I am not sure it is good way for linux aio optimization:
- for raw image with some constraint, coroutine can be avoided since
io_submit()won't sleep most of timesQuoted 8 lines
Quoted 6 lines
Quoted 4 lines
- handling one time coroutine takes much time than handling malloc, memset and free on small buffer, following the test data:
-- 241ns per coroutine
What do you mean by "coroutine" here? Create + destroy? Yield?
Please see
perf_cost()intests/test-coroutine.cstatic __attribute__((noinline)) void perf_cost_func(void *opaque) { qemu_coroutine_yield(); } static void perf_cost(void) { const unsigned long maxcycles = 40000000; unsigned long i = 0; double duration; unsigned long ops; Coroutine *co; g_test_timer_start(); while (i++ < maxcycles) { co = qemu_coroutine_create(perf_cost_func); qemu_coroutine_enter(co, &i); qemu_coroutine_enter(co, NULL); } duration = g_test_timer_elapsed(); ops = (long)(maxcycles / (duration * 1000)); g_test_message("Run operation %lu iterations %f s, %luK operations/s, " "%luns per coroutine", maxcycles, duration, ops, (unsigned long)(1000000000 * duration) / maxcycles); }
Quoted 2 lines
This tests create, enter, yield, reenter, terminate, destroy. The cost of create + destroy may well dominate.
Actually there shouldn't have been much cost from create and destroy attributed to coroutine pool.
Quoted 6 lines
If we create and destroy coroutines for each AIO request, we're doing it wrong. I doubt Kevin's doing it *that* wrong ;)
Anyway, let's benchmark the real code instead of putting undue trust in
tests/test-coroutine.cmicro-benchmarks.
I don't think there isn't trust from the micro-benchmark.
That is the direct cost from coroutine, and the cost won't be avoided at all, not mention cost from switching stack.
If you google some test data posted by me previously, that would show bypassing coroutine can increase throughput with ~50% for raw image in case of linux aio, that is the real test case, not micro-benchmark.
Thanks,
Ming Lei
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
In reply to Ming LeiQuoted 15 lines · Ming Lei
Hi Kevin,
Quoted 3 lines · Kevin Wolf
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
I am not sure it is good way for linux aio optimization:
- for raw image with some constraint, coroutine can be avoided since
io_submit()won't sleep most of times- handling one time coroutine takes much time than handling malloc, memset and free on small buffer, following the test data:
Quoted 6 lines
-- 241ns per coroutine
-- 61ns per (malloc, memset, free for 128bytes)I still think we should figure out a fast path to avoid cocourinte for linux-aio with raw image, otherwise it can't scale well for high IOPS device.
sigsetjmp/siglongjmp are just ~60 instructions, it cannot account for 180ns (600 clock cycles). The cost of creating and destroying the coroutine must come from somewhere else.
Let's just try something else. Let's remove the pool mutex, as suggested by Peter but in a way that works even with non-ioeventfd backends.
I still believe we will end with some kind of coroutine bypass scheme (even coroutines _do_ allocate an AIOCB, so calling bdrv_aio_readv directly can help), but hey it cannot hurt to optimize hot code.
The patch below has a single pool where coroutines are placed on destruction, and a per-thread allocation pool. Whenever the destruction pool is big enough, the next thread that runs out of coroutines will steal from it instead of making a new coroutine. If this works, it would be beautiful in two ways:
1) the allocation does not have to do any atomic operation in the fast path, it's entirely using thread-local storage. Once every POOL_BATCH_SIZE allocations it will do a single atomic_xchg. Release does an atomic_cmpxchg loop, that hopefully doesn't cause any starvation, and an atomic_inc.
2) in theory this should be completely adaptive. The number of coroutines around should be a little more than POOL_BATCH_SIZE * number of allocating threads; so this also removes qemu_coroutine_adjust_pool_size. (The previous pool size was POOL_BATCH_SIZE * number of block backends, so it was a bit more generous).
The patch below is very raw, and untested beyond tests/test-coroutine. There may be some premature optimization (not using GPrivate, even though I need it to run the per-thread destructor) but it was easy enough. Ming, Kevin, can you benchmark it?
Related to this, we can see if __thread beats GPrivate in coroutine-ucontext.c. Every clock cycle counts (600 clock cycles are a 2% improvement at 3 GHz and 100 kiops) so we can see what we get.
Paolo
include/qemu/queue.h +11 -0
@@ -191,6 +191,17 @@ struct { \ #define QSLIST_INSERT_HEAD(head, elm, field) do { \ (elm)->field.sle_next = (head)->slh_first; \ (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_INSERT_HEAD_ATOMIC(head, elm, field) do { \ + do { \ + (elm)->field.sle_next = (head)->slh_first; \ + } while (atomic_cmpxchg(&(head)->slh_first, (elm)->field.sle_next, \ + (elm)) != (elm)->field.sle_next); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_MOVE_ATOMIC(dest, src) do { \ + (dest)->slh_first = atomic_xchg(&(src)->slh_first, NULL); \ } while (/*CONSTCOND*/0)#define QSLIST_REMOVE_HEAD (head, field) do { \
qemu-coroutine.c +32 -41
123 lines not on this page · raw message
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
In reply to Ming LeiAm 28.11.2014 um 03:59 hat Ming Lei geschrieben:
Quoted 9 lines
Hi Kevin,
Quoted 3 lines · Kevin Wolf
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
I am not sure it is good way for linux aio optimization:
Quoted 8 lines
- for raw image with some constraint, coroutine can be avoided since
io_submit()won't sleep most of times- handling one time coroutine takes much time than handling malloc, memset and free on small buffer, following the test data:
-- 241ns per coroutine
-- 61ns per (malloc, memset, free for 128bytes)
Please finally stop making comparisons between completely unrelated things and trying to make a case against coroutines out of it. It simply doesn't make any sense.
The truth is that in the 'qemu-img bench' case as well as in the highest performing VM setup for Peter and me, the practically existing coroutine based git branches perform better then the practically existing bypass branches. If you think that theoretically the bypass branches must be better, show us the patches and benchmarks.
If you can't, let's merge the coroutine improvements (which improve more than just the case of raw images using no block layer features, including cases that benefit the average user) and be done.
Quoted 6 lines
I still think we should figure out a fast path to avoid cocourinte for linux-aio with raw image, otherwise it can't scale well for high IOPS device.
Also we can use simple buf pool to avoid the dynamic allocation easily, can't we?
Yes, the change to g_slice_alloc() was a bad move performance-wise.
Quoted 14 lines
Quoted 14 lines
As a side effect, the codepath taken by aio=threads is changed to use
paio_submit_co(). This doesn't change the performance at this point.Results of qemu-img bench -t none -c 10000000 [-n]
/dev/loop0:| aio=native | aio=threads | before | with patch | before | with patch ------+----------+------------+----------+------------ run 1 | 29.921s | 26.932s | 35.286s | 35.447s run 2 | 29.793s | 26.252s | 35.276s | 35.111s run 3 | 30.186s | 27.114s | 35.042s | 34.921s run 4 | 30.425s | 26.600s | 35.169s | 34.968s run 5 | 30.041s | 26.263s | 35.224s | 35.000s
Quoted 5 lines
Quoted 2 lines
TODO: Do some more serious benchmarking in VMs with less variance. Results of a quick fio run are vaguely positive.
I will do the test with Paolo's fast path approach under VM I/O situation.
Currently, the best thing to compare it against is probably Peter's git branch at https://github.com/plieven/qemu.git perf_master2. This patch is only a first step in a whole series of possible optimisations.
Kevin
Re: [Qemu-devel] [RFC PATCH 1/3] qemu-img bench
In reply to Kevin Wolfqemu-img.c out: · line 3162
Quoted 3 lines · Kevin Wolf
qemu-img.c +3
-0+while (data.n >0 ) { +main_loop_wait (false); + }
Why is this false (non-blocking)? This is why you get the main loop spun warning message.
Using true (blocking) seems like the right thing. data.n changes as part of the callback, which is invoked from the main loop. There is no need to be non-blocking.
Stefan
Re: [Qemu-devel] [RFC PATCH 1/3] qemu-img bench
Am 28.11.2014 um 12:49 hat Stefan Hajnoczi geschrieben:
Quoted 11 lines · Kevin Wolf
qemu-img.c out: · line 3162
Quoted 3 lines
qemu-img.c +3
-0+while (data.n >0 ) { +main_loop_wait (false); + }Why is this false (non-blocking)? This is why you get the main loop spun warning message.
Using true (blocking) seems like the right thing. data.n changes as part of the callback, which is invoked from the main loop. There is no need to be non-blocking.
I think the parameter has exactly the opposite meaning as what you describe:
int main_loop_wait(int nonblocking)
If it were true, you would get timeout = 0. qemu-io and qemu-nbd also pass false here.
Kevin
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
In reply to Peter LievenAm 27.11.2014 um 10:50 hat Peter Lieven geschrieben:
Quoted 22 lines · Kevin Wolf
Quoted 18 lines
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
As a side effect, the codepath taken by aio=threads is changed to use
paio_submit_co(). This doesn't change the performance at this point.Results of qemu-img bench -t none -c 10000000 [-n]
/dev/loop0:| aio=native | aio=threads | before | with patch | before | with patch ------+----------+------------+----------+------------ run 1 | 29.921s | 26.932s | 35.286s | 35.447s run 2 | 29.793s | 26.252s | 35.276s | 35.111s run 3 | 30.186s | 27.114s | 35.042s | 34.921s run 4 | 30.425s | 26.600s | 35.169s | 34.968s run 5 | 30.041s | 26.263s | 35.224s | 35.000sQuoted 2 lines
TODO: Do some more serious benchmarking in VMs with less variance. Results of a quick fio run are vaguely positive.
Quoted 7 lines
I still see the main-loop spun warnings with this patches applied to master. It wasn't there with the original patch from August.
~/git/qemu$ ./qemu-img bench -t none -c 10000000 -n
/dev/ram1Sending 10000000 requests, 4096 bytes each, 64 in parallel
main-loop: WARNING: I/O thread spun for 1000 iterations Run completed in 31.947 seconds.
Yes, I still need to bisect that. The 'qemu-img bench' numbers above are actually also from August, we have regressed meanwhile by about a second, and I also haven't found the reason for that yet.
Kevin
Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines
Am 28.11.2014 um 13:57 hat Kevin Wolf geschrieben:
Quoted 26 lines
Am 27.11.2014 um 10:50 hat Peter Lieven geschrieben:
Quoted 25 lines · Kevin Wolf
Quoted 18 lines
This improves the performance of requests because an ACB doesn't need to be allocated on the heap any more. It also makes the code nicer and smaller.
As a side effect, the codepath taken by aio=threads is changed to use
paio_submit_co(). This doesn't change the performance at this point.Results of qemu-img bench -t none -c 10000000 [-n]
/dev/loop0:| aio=native | aio=threads | before | with patch | before | with patch ------+----------+------------+----------+------------ run 1 | 29.921s | 26.932s | 35.286s | 35.447s run 2 | 29.793s | 26.252s | 35.276s | 35.111s run 3 | 30.186s | 27.114s | 35.042s | 34.921s run 4 | 30.425s | 26.600s | 35.169s | 34.968s run 5 | 30.041s | 26.263s | 35.224s | 35.000sQuoted 2 lines
TODO: Do some more serious benchmarking in VMs with less variance. Results of a quick fio run are vaguely positive.
I still see the main-loop spun warnings with this patches applied to master. It wasn't there with the original patch from August.
Quoted 8 lines
Quoted 4 lines
~/git/qemu$ ./qemu-img bench -t none -c 10000000 -n
/dev/ram1Sending 10000000 requests, 4096 bytes each, 64 in parallel
main-loop: WARNING: I/O thread spun for 1000 iterations Run completed in 31.947 seconds.Yes, I still need to bisect that. The 'qemu-img bench' numbers above are actually also from August, we have regressed meanwhile by about a second, and I also haven't found the reason for that yet.
Did the first part of this now. The commit that introduced the "spun" message is 2cdff7f6 ('linux-aio: avoid deadlock in nested aio_poll() calls').
The following patch doesn't make it go away completely, but I only see it sometime during like every other run now, instead of immediately after starting qemu-img bench. It's probably a (very) minor performance optimisation, too.
Kevin
block/linux-aio.c +3 -1
@@ -136,6 +136,8 @@ static void qemu_laio_completion_bh(void *opaque)qemu_laio_process_completion (s, laiocb); } + +qemu_bh_cancel (s->completion_bh); }static void qemu_laio_completion_cb (EventNotifier *e)
@@ -143,7 +145,7 @@ static void qemu_laio_completion_cb(EventNotifier *e) struct qemu_laio_state *s = container_of(e, struct qemu_laio_state, e);if (event_notifier_test_and_clear (&s->e)) { -qemu_bh_schedule (s->completion_bh); +qemu_laio_completion_bh (s); } }
Re: [Qemu-devel] [RFC PATCH 1/3] qemu-img bench
In reply to Kevin WolfQuoted 13 lines · Kevin Wolf
Am 28.11.2014 um 12:49 hat Stefan Hajnoczi geschrieben:
Quoted 11 lines · Kevin Wolf
qemu-img.c out: · line 3162
Quoted 3 lines
qemu-img.c +3
-0+while (data.n >0 ) { +main_loop_wait (false); + }Why is this false (non-blocking)? This is why you get the main loop spun warning message.
Using true (blocking) seems like the right thing. data.n changes as part of the callback, which is invoked from the main loop. There is no need to be non-blocking.
Quoted 7 lines
I think the parameter has exactly the opposite meaning as what you describe:
int
main_loop_wait(int nonblocking)If it were true, you would get timeout = 0. qemu-io and qemu-nbd also pass false here.
Oops, you are right! Sorry, I was confused.
Stefan
Re: [Qemu-devel] [RFC PATCH 3/3] linux-aio: Don't reenter request coroutine recursively
In reply to Kevin WolfAm 26.11.2014 um 15:46 hat Kevin Wolf geschrieben:
Quoted 9 lines
When getting an error while submitting requests, we must be careful to wake up only inactive coroutines. Therefore we must special-case the currently active coroutine and communicate an error for that request using the ordinary return value of
ioq_submit().Signed-off-by Kevin Wolf <[email protected]>--- block/linux-aio.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
Ming, did you have a look at this patch specifically? Does it fix the issue that you tried to address with a much more complex callback-based patch?
I'd like to go forward with this as both Peter and I have measured considerable performance improvements with our optimisation proposals, and this series is an important part of it.
Kevin
Quoted 56 lines
block/linux-aio.c +16
-7@@ -177,12 +177,19 @@ static int ioq_submit(struct qemu_laio_state *s) container_of(s->io_q.iocbs[i], struct qemu_laiocb, iocb); laiocb->ret = (ret <0 ) ? ret : -EIO ; -qemu_laio_process_completion (s, laiocb); +if (laiocb->co !=qemu_coroutine_self ()) { +qemu_coroutine_enter (laiocb->co,NULL ); + }else { +/* The return value is used for the currently active coroutine. +* We're always in ioq_enqueue() here, ioq_submit() never runs from +* a request's coroutine.*/ + ret = laiocb->ret; + } }return ret; } -static void ioq_enqueue (struct qemu_laio_state *s,struct iocb *iocb) +static int ioq_enqueue (struct qemu_laio_state *s,struct iocb *iocb) {unsigned int idx = s->io_q.idx;@@ -191,7 +198,9 @@ static void ioq_enqueue(struct qemu_laio_state *s, struct iocb *iocb)/* submit immediately if queue is full */ if (idx == s->io_q.size) { -ioq_submit (s); +return ioq_submit (s); + }else { +return 0 ; } }@@ -253,11 +262,11 @@ int laio_submit_co(BlockDriverState *bs, void *aio_ctx, int fd,if (!s->io_q.plugged) { ret =io_submit (s->ctx,1 , &iocbs); -if (ret <0 ) { -return ret; - } }else { -ioq_enqueue (s, iocbs); + ret =ioq_enqueue (s, iocbs); + } +if (ret <0 ) { +return ret; }qemu_coroutine_yield ();Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [RFC PATCH 3/3] linux-aio: Don't reenter request coroutine recursively
Quoted 6 lines · Kevin Wolf
Am 26.11.2014 um 15:46 hat Kevin Wolf geschrieben:
Quoted 5 lines
When getting an error while submitting requests, we must be careful to wake up only inactive coroutines. Therefore we must special-case the currently active coroutine and communicate an error for that request using the ordinary return value of
ioq_submit().
Quoted 8 lines
Quoted 4 lines
Signed-off-by Kevin Wolf <[email protected]>--- block/linux-aio.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)Ming, did you have a look at this patch specifically? Does it fix the issue that you tried to address with a much more complex callback-based patch?
I think your patch can't fix my issue.
As I explained, we have to handle -EAGAIN and partial submission, which can be triggered quite easily in case of multi-queue, and other case like NVME.
Thanks,
Quoted 65 lines
I'd like to go forward with this as both Peter and I have measured considerable performance improvements with our optimisation proposals, and this series is an important part of it.
Kevin
Quoted 56 lines
block/linux-aio.c +16
-8@@ -177,12 +177,19 @@ static int ioq_submit(struct qemu_laio_state *s) container_of(s->io_q.iocbs[i], struct qemu_laiocb, iocb); laiocb->ret = (ret <0 ) ? ret : -EIO ; -qemu_laio_process_completion (s, laiocb); +if (laiocb->co !=qemu_coroutine_self ()) { +qemu_coroutine_enter (laiocb->co,NULL ); + }else { +/* The return value is used for the currently active coroutine. +* We're always in ioq_enqueue() here, ioq_submit() never runs from +* a request's coroutine.*/ + ret = laiocb->ret; + } }return ret; } -static void ioq_enqueue (struct qemu_laio_state *s,struct iocb *iocb) +static int ioq_enqueue (struct qemu_laio_state *s,struct iocb *iocb) {unsigned int idx = s->io_q.idx;@@ -191,7 +198,9 @@ static void ioq_enqueue(struct qemu_laio_state *s, struct iocb *iocb)/* submit immediately if queue is full */ if (idx == s->io_q.size) { -ioq_submit (s); +return ioq_submit (s); + }else { +return 0 ; } }@@ -253,11 +262,11 @@ int laio_submit_co(BlockDriverState *bs, void *aio_ctx, int fd,if (!s->io_q.plugged) { ret =io_submit (s->ctx,1 , &iocbs); -if (ret <0 ) { -return ret; - } }else { -ioq_enqueue (s, iocbs); + ret =ioq_enqueue (s, iocbs); + } +if (ret <0 ) { +return ret; }qemu_coroutine_yield (); --1.8.3.1
Re: [Qemu-devel] [RFC PATCH 3/3] linux-aio: Don't reenter request coroutine recursively
Am 04.12.2014 um 16:22 hat Ming Lei geschrieben:
Quoted 16 lines · Kevin Wolf
Quoted 6 lines
Am 26.11.2014 um 15:46 hat Kevin Wolf geschrieben:
Quoted 5 lines
When getting an error while submitting requests, we must be careful to wake up only inactive coroutines. Therefore we must special-case the currently active coroutine and communicate an error for that request using the ordinary return value of
ioq_submit().Quoted 8 lines
Quoted 4 lines
Signed-off-by Kevin Wolf <[email protected]>--- block/linux-aio.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)Ming, did you have a look at this patch specifically? Does it fix the issue that you tried to address with a much more complex callback-based patch?
Quoted 5 lines
I think your patch can't fix my issue.
As I explained, we have to handle
-EAGAINand partial submission, which can be triggered quite easily in case of multi-queue, and other case like NVME.
Yes, this is an alternative only to the first patch of your series. If we go that route, your second patch would still be needed as well, of course. It should be relatively obvious how to change it to apply on top of this one.
Kevin
Re: [Qemu-devel] [RFC PATCH 3/3] linux-aio: Don't reenter request coroutine recursively
Quoted 17 lines · Kevin Wolf
Am 04.12.2014 um 16:22 hat Ming Lei geschrieben:
Quoted 16 lines · Kevin Wolf
Quoted 14 lines
Am 26.11.2014 um 15:46 hat Kevin Wolf geschrieben:
Quoted 9 lines
When getting an error while submitting requests, we must be careful to wake up only inactive coroutines. Therefore we must special-case the currently active coroutine and communicate an error for that request using the ordinary return value of
ioq_submit().Signed-off-by Kevin Wolf <[email protected]>--- block/linux-aio.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)Ming, did you have a look at this patch specifically? Does it fix the issue that you tried to address with a much more complex callback-based patch?
Quoted 7 lines
Quoted 5 lines
I think your patch can't fix my issue.
As I explained, we have to handle
-EAGAINand partial submission, which can be triggered quite easily in case of multi-queue, and other case like NVME.Yes, this is an alternative only to the first patch of your series. If
No, most of my first patch is for handling -EAGAIN and partial submission, so both my two patches are needed for the issue.
Quoted 6 lines
we go that route, your second patch would still be needed as well, of course. It should be relatively obvious how to change it to apply on top of this one.
Kevin