Skip to contentSkip to conversation

kvm tools: Increase AIO_MAX to 256

PATCH Applied Asias He 2 participants 5 messages Jun 4, 2012 – Jun 5, 2012 KVM

lore
Share & tools
lore

Asias He

author
#0 lore raw

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
index ed338e7..d1d2d59 100644
@@ -6,7 +6,7 @@
 #include <sys/eventfd.h>
 #include <sys/poll.h>
 
-#define AIO_MAX 32
+#define AIO_MAX 256
 
 int debug_iodelay;
 
Signature · 1 line
1.7.10.2
author
#1 lore raw

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
index 55473ba..44709df 100644
@@ -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
\ No newline at end of file
+#endif
Signature · 1 line
1.7.10.2
Applied
#2 lore raw

Re: [PATCH 2/2] kvm tools: Restart io_submit if it returns EAGAIN

Quoted 3 lines · Asias He

Keep trying if io_submit returns EAGAIN. No need to fail the request.

Applied, thanks!

#3 lore raw
In reply to Asias He
Quoted 19 lines · Asias He

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 +0 -0
index ed338e7..d1d2d59 100644

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 256
 
 int debug_iodelay;

Is there any downside to bumping up the limit? Ingo?

author
#4 lore raw
Quoted 24 lines · Pekka Enberg
Quoted 22 lines · Asias He

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 +0 -0
index ed338e7..d1d2d59 100644
@@ -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