kvm tools: Increase AIO_MAX to 256
PATCH 1/2 kvm tools: Increase AIO_MAX to 256
The queue size for virtio_blk is 256 and AIO_MAX is 32, we might be short of available aio events if guest issues > 32 requests simultaneously. Following error is observed when guest running stressed I/O workload.
Info: disk_image__read error: total=-11
To fix this, let's increase the aio events limit.
--- tools/kvm/disk/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/kvm/disk/core.c +1 -1
@@ -6,7 +6,7 @@#include <sys/eventfd.h> #include <sys/poll.h> -#define AIO_MAX 32 +#define AIO_MAX 256int debug_iodelay;
Signature · 1 line
1.7.10.2
PATCH 2/2 kvm tools: Restart io_submit if it returns EAGAIN
Keep trying if io_submit returns EAGAIN. No need to fail the request.
--- tools/kvm/util/read-write.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
tools/kvm/util/read-write.c +13 -3
@@ -322,23 +322,33 @@ int aio_pwritev(io_context_t ctx, struct iocb *iocb, int fd, const struct iovec off_t offset, int ev, void *param) { struct iocb *ios[1] = { iocb }; +int ret;io_prep_pwritev (iocb, fd, iov, iovcnt, offset);io_set_eventfd (iocb, ev); iocb->data = param; -return io_submit (ctx,1 , ios); +restart: + ret =io_submit (ctx,1 , ios); +if (ret == -EAGAIN ) + goto restart; +return ret; }int aio_preadv (io_context_t ctx,struct iocb *iocb,int fd,const struct iovec *iov,int iovcnt,off_t offset,int ev,void *param) {struct iocb *ios[1 ] = { iocb }; +int ret;io_prep_preadv (iocb, fd, iov, iovcnt, offset);io_set_eventfd (iocb, ev); iocb->data = param; -return io_submit (ctx,1 , ios); +restart: + ret =io_submit (ctx,1 , ios); +if (ret == -EAGAIN ) + goto restart; +return ret; } -#endif +#endif
Signature · 1 line
1.7.10.2
Quoted 19 lines · Asias He
The queue size for
virtio_blkis 256 andAIO_MAXis 32, we might be short of available aio events if guest issues > 32 requests simultaneously. Following error is observed when guest running stressed I/O workload.Info:
disk_image__readerror: total=-11To fix this, let's increase the aio events limit.
Signed-off-by Asias He <[email protected]>--- tools/kvm/disk/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/kvm/disk/core.c +0
-0
tools/kvm/disk/core.c line 11
Quoted 7 lines
tools/kvm/disk/core.c +1
-1@@ -6,7 +6,7 @@#include <sys/eventfd.h> #include <sys/poll.h> -#define AIO_MAX 32 +#define AIO_MAX 256int debug_iodelay;
Is there any downside to bumping up the limit? Ingo?
Pekka Enberg
AppliedRe: [PATCH 2/2] kvm tools: Restart io_submit if it returns EAGAIN
In reply to Asias HeQuoted 3 lines · Asias He
Keep trying if
io_submitreturns EAGAIN. No need to fail the request.Signed-off-by Asias He <[email protected]>
Applied, thanks!
Quoted 24 lines · Pekka Enberg
Quoted 22 lines · Asias He
The queue size for
virtio_blkis 256 andAIO_MAXis 32, we might be short of available aio events if guest issues > 32 requests simultaneously. Following error is observed when guest running stressed I/O workload.Info:
disk_image__readerror: total=-11To fix this, let's increase the aio events limit.
Signed-off-by Asias He <[email protected]>---
tools/kvm/disk/core.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/kvm/disk/core.c +0
-0@@ -6,7 +6,7 @@ #include <sys/eventfd.h> #include <sys/poll.h>
Quoted 6 lines
tools/kvm/disk/core.c line 11
Quoted 4 lines
tools/kvm/disk/core.c +1
-1-#define AIO_MAX 32 +#define AIO_MAX 256 int debug_iodelay;Is there any downside to bumping up the limit? Ingo?
We can have 0x10000 aio requests by default which is way much larger than 256. And we can also increase this limit through /proc/sys/fs/aio-max-nr.
------>fs/aio.c
unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
<------
Signature · 1 line
Asias He