Skip to contentSkip to conversation

block: warn about aio=native if libaio is unavailable

PATCH Superseded Stefan Hajnoczi 6 participants 11 messages Jul 17, 2015 – Jul 23, 2015 Block layer

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover block: warn about aio=native if libaio is unavailable

v2:
* Banish CONFIG_LINUX_AIO from blockdev.c, that is raw-posix.c's business [Kevin]
* Print the warning in the same way as the aio=native,cache.direct=off deprecation warning [Kevin]

Open question: what about the Windows case? We now pass the FILE_FLAG_OVERLAPPED flag which we didn't do before for -drive aio=native.

Stefan Hajnoczi (2):
raw-posix: warn about BDRV_O_NATIVE_AIO if libaio is unavailable
blockdev: always compile in -drive aio= parsing

 block/raw-posix.c | 11 ++++++++++-
 blockdev.c        |  2 --
 2 files changed, 10 insertions(+), 3 deletions(-)
Signature · 1 line
2.4.3
#1 lore raw

PATCH v2 1/2 raw-posix: warn about BDRV_O_NATIVE_AIO if libaio is unavailable

raw-posix.c silently ignores BDRV_O_NATIVE_AIO if libaio is unavailable. It is confusing when aio=native performance is identical to aio=threads because the binary was accidentally built without libaio.

Print a deprecation warning if -drive aio=native is used with a binary that does not support libaio. There are probably users using aio=native who would be inconvenienced if QEMU suddenly refused to start their guests. In the future this will become an error.

---
 block/raw-posix.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
block/raw-posix.c +10 -1
index 855febe..e09019c 100644
@@ -519,7 +519,16 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
                      "future QEMU versions.\n",
                      bs->filename);
     }
-#endif
+#else
+    if (bdrv_flags & BDRV_O_NATIVE_AIO) {
+        error_printf("WARNING: aio=native was specified for '%s', but "
+                     "is not supported in this build. Falling back to "
+                     "aio=threads.\n"
+                     "         This will become an error condition in "
+                     "future QEMU versions.\n",
+                     bs->filename);
+    }
+#endif /* !defined(CONFIG_LINUX_AIO) */
 
     s->has_discard = true;
     s->has_write_zeroes = true;
Signature · 1 line
2.4.3
Acked-by on v2 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] raw-posix: warn about BDRV_O_NATIVE_AIO if libaio is unavailable

Am 17.07.2015 um 16:23 schrieb Stefan Hajnoczi:

Quoted 10 lines

raw-posix.c silently ignores BDRV_O_NATIVE_AIO if libaio is unavailable. It is confusing when aio=native performance is identical to aio=threads because the binary was accidentally built without libaio.

Print a deprecation warning if -drive aio=native is used with a binary that does not support libaio. There are probably users using aio=native who would be inconvenienced if QEMU suddenly refused to start their guests. In the future this will become an error.

had that myself on a freshly installed system without libaio-devel.

Another thing. Would it make sense to change the default to aio=native somewhen?

Quoted 30 lines

From what I can tell this seems to outperform aio=threads in most cases.

---
 block/raw-posix.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
block/raw-posix.c +10 -1
index 855febe..e09019c 100644
@@ -519,7 +519,16 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
                      "future QEMU versions.\n",
                      bs->filename);
     }
-#endif
+#else
+    if (bdrv_flags & BDRV_O_NATIVE_AIO) {
+        error_printf("WARNING: aio=native was specified for '%s', but "
+                     "is not supported in this build. Falling back to "
+                     "aio=threads.\n"
+                     "         This will become an error condition in "
+                     "future QEMU versions.\n",
+                     bs->filename);
+    }
+#endif /* !defined(CONFIG_LINUX_AIO) */
 
     s->has_discard = true;
     s->has_write_zeroes = true;
#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] raw-posix: warn about BDRV_O_NATIVE_AIO if libaio is unavailable

Quoted 10 lines · Christian Borntraeger

Am 17.07.2015 um 16:23 schrieb Stefan Hajnoczi:

Quoted 9 lines

raw-posix.c silently ignores BDRV_O_NATIVE_AIO if libaio is unavailable. It is confusing when aio=native performance is identical to aio=threads because the binary was accidentally built without libaio.

Print a deprecation warning if -drive aio=native is used with a binary that does not support libaio. There are probably users using aio=native who would be inconvenienced if QEMU suddenly refused to start their guests. In the future this will become an error.

Quoted 8 lines
Quoted 1 line

had that myself on a freshly installed system without libaio-devel.

Another thing. Would it make sense to change the default to aio=native somewhen?
From what I can tell this seems to outperform aio=threads in most cases.

this seems a good idea to me, we are always changing from threads to native in our installations

Quoted 28 lines
Quoted 27 lines
---
  block/raw-posix.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
block/raw-posix.c +10 -1
index 855febe..e09019c 100644
@@ -519,7 +519,16 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
                       "future QEMU versions.\n",
                       bs->filename);
      }
-#endif
+#else
+    if (bdrv_flags & BDRV_O_NATIVE_AIO) {
+        error_printf("WARNING: aio=native was specified for '%s', but "
+                     "is not supported in this build. Falling back to "
+                     "aio=threads.\n"
+                     "         This will become an error condition in "
+                     "future QEMU versions.\n",
+                     bs->filename);
+    }
+#endif /* !defined(CONFIG_LINUX_AIO) */
 
      s->has_discard = true;
      s->has_write_zeroes = true;
#4 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] raw-posix: warn about BDRV_O_NATIVE_AIO if libaio is unavailable

In reply to Christian Borntraeger

Am 23.07.2015 um 12:09 hat Christian Borntraeger geschrieben:

Quoted 10 lines

Am 17.07.2015 um 16:23 schrieb Stefan Hajnoczi:

Quoted 9 lines

raw-posix.c silently ignores BDRV_O_NATIVE_AIO if libaio is unavailable. It is confusing when aio=native performance is identical to aio=threads because the binary was accidentally built without libaio.

Print a deprecation warning if -drive aio=native is used with a binary that does not support libaio. There are probably users using aio=native who would be inconvenienced if QEMU suddenly refused to start their guests. In the future this will become an error.

Quoted 8 lines
Quoted 1 line

had that myself on a freshly installed system without libaio-devel.

Another thing. Would it make sense to change the default to aio=native somewhen? From what I can tell this seems to outperform aio=threads in most cases.

aio=native requires cache.direct=on, which is not portable to all platforms that qemu supports, and also doesn't work with all filesystems on Linux (most notably tmpfs fails). Also recent benchmarks seem to suggest that currently there is no clear winner between aio=native and aio=threads, it depends too much on the host storage and the workload.

When we discussed the default cache mode a while back (with the options cache=writeback and cache=none), it was considered more important to have a default setting that works everywhere and performs good for quick ad-hoc VMs and development/debugging work than one that performs best in enterprise setups that should use a management tool anyway.

Kevin

#5 lore raw

PATCH v2 2/2 blockdev: always compile in -drive aio= parsing

In reply to Stefan Hajnoczi

CONFIG_LINUX_AIO is an implementation detail of raw-posix.c. Don't mention CONFIG_LINUX_AIO in blockdev.c. Let raw-posix.c decide what to do with BDRV_O_NATIVE_AIO if CONFIG_LINUX_AIO is not defined.

---
 blockdev.c | 2 --
 1 file changed, 2 deletions(-)
blockdev.c +0 -2
index 62a4586..37b91c8 100644
@@ -405,7 +405,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
         bdrv_flags |= BDRV_O_NO_FLUSH;
     }
 
-#ifdef CONFIG_LINUX_AIO
     if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
         if (!strcmp(buf, "native")) {
             bdrv_flags |= BDRV_O_NATIVE_AIO;
@@ -416,7 +415,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
            goto early_err;
         }
     }
-#endif
 
     if ((buf = qemu_opt_get(opts, "format")) != NULL) {
         if (is_help_option(buf)) {
Signature · 1 line
2.4.3
#6 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] blockdev: always compile in -drive aio= parsing

Quoted 2 lines · Stefan Hajnoczi

CONFIG_LINUX_AIO is an implementation detail of raw-posix.c. Don't mention CONFIG_LINUX_AIO in blockdev.c. Let raw-posix.c decide what to

To be precise: "raw-posix.c or raw-win32.c", or maybe "the block driver".

Quoted 27 lines

do with BDRV_O_NATIVE_AIO if CONFIG_LINUX_AIO is not defined.

---
 blockdev.c | 2 --
 1 file changed, 2 deletions(-)
blockdev.c +0 -2
index 62a4586..37b91c8 100644
@@ -405,7 +405,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
         bdrv_flags |= BDRV_O_NO_FLUSH;
     }
 
-#ifdef CONFIG_LINUX_AIO
     if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
         if (!strcmp(buf, "native")) {
             bdrv_flags |= BDRV_O_NATIVE_AIO;
@@ -416,7 +415,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
            goto early_err;
         }
     }
-#endif
 
     if ((buf = qemu_opt_get(opts, "format")) != NULL) {
         if (is_help_option(buf)) {
#7 lore raw
In reply to Stefan Hajnoczi
Quoted 8 lines · Stefan Hajnoczi

v2:
* Banish CONFIG_LINUX_AIO from blockdev.c, that is raw-posix.c's business [Kevin]
* Print the warning in the same way as the aio=native,cache.direct=off deprecation warning [Kevin]

Open question: what about the Windows case? We now pass the FILE_FLAG_OVERLAPPED flag which we didn't do before for -drive aio=native.

Odd. Commit a273652 takes the trouble to implement native asynchronous I/O there, but unless CONFIG_LINUX_AIO somehow gets defined, it's unreachable, isn't it? Paolo?

I think PATCH 2's commit message needs to be updated to discuss the impact.

#8 lore raw
Quoted 7 lines · Markus Armbruster
Quoted 7 lines
Quoted 7 lines

v2:
* Banish CONFIG_LINUX_AIO from blockdev.c, that is raw-posix.c's business [Kevin]
* Print the warning in the same way as the aio=native,cache.direct=off deprecation warning [Kevin]

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Open question: what about the Windows case? We now pass the FILE_FLAG_OVERLAPPED flag which we didn't do before for -drive aio=native.

Odd. Commit a273652 takes the trouble to implement native asynchronous I/O there, but unless CONFIG_LINUX_AIO somehow gets defined, it's unreachable, isn't it? Paolo?

I don't remember how I tested that code, but it's probably been dead code since it was committed. If it's bitrot and thus these patches break it, I will fix it.

Paolo

Quoted 2 lines

I think PATCH 2's commit message needs to be updated to discuss the impact.

#9 lore raw

Am 23.07.2015 um 10:08 hat Paolo Bonzini geschrieben:

Quoted 12 lines · Markus Armbruster
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

v2:
* Banish CONFIG_LINUX_AIO from blockdev.c, that is raw-posix.c's business [Kevin]
* Print the warning in the same way as the aio=native,cache.direct=off deprecation warning [Kevin]

Open question: what about the Windows case? We now pass the FILE_FLAG_OVERLAPPED flag which we didn't do before for -drive aio=native.

Quoted 7 lines
Quoted 3 lines

Odd. Commit a273652 takes the trouble to implement native asynchronous I/O there, but unless CONFIG_LINUX_AIO somehow gets defined, it's unreachable, isn't it? Paolo?

I don't remember how I tested that code, but it's probably been dead code since it was committed. If it's bitrot and thus these patches break it, I will fix it.

The tools use a different path, so qemu-img/io would have correctly used AIO on Windows.

Kevin

#10 lore raw
In reply to Markus Armbruster
Quoted 11 lines · Markus Armbruster
Quoted 8 lines · Stefan Hajnoczi

v2:
* Banish CONFIG_LINUX_AIO from blockdev.c, that is raw-posix.c's business [Kevin]
* Print the warning in the same way as the aio=native,cache.direct=off deprecation warning [Kevin]

Open question: what about the Windows case? We now pass the FILE_FLAG_OVERLAPPED flag which we didn't do before for -drive aio=native.

Quoted 6 lines

Odd. Commit a273652 takes the trouble to implement native asynchronous I/O there, but unless CONFIG_LINUX_AIO somehow gets defined, it's unreachable, isn't it? Paolo?

I think PATCH 2's commit message needs to be updated to discuss the impact.

Nice find!

I'll send a v2.