]> Git Repo - qemu.git/commitdiff
aio-posix: disable fdmon-io_uring when GSource is used
authorStefan Hajnoczi <[email protected]>
Mon, 11 May 2020 18:36:30 +0000 (19:36 +0100)
committerStefan Hajnoczi <[email protected]>
Mon, 18 May 2020 17:16:00 +0000 (18:16 +0100)
The glib event loop does not call fdmon_io_uring_wait() so fd handlers
waiting to be submitted build up in the list. There is no benefit is
using io_uring when the glib GSource is being used, so disable it
instead of implementing a more complex fix.

This fixes a memory leak where AioHandlers would build up and increasing
amounts of CPU time were spent iterating them in aio_pending(). The
symptom is that guests become slow when QEMU is built with io_uring
support.

Buglink: https://bugs.launchpad.net/qemu/+bug/1877716
Fixes: 73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf ("aio-posix: add io_uring fd monitoring implementation")
Signed-off-by: Stefan Hajnoczi <[email protected]>
Tested-by: Oleksandr Natalenko <[email protected]>
Message-id: 20200511183630[email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
include/block/aio.h
util/aio-posix.c
util/aio-win32.c
util/async.c

index 62ed954344ff58a946cb94828933278b300b0ffe..b2f703fa3fcfea983e2eaa838adea4c0e32456ab 100644 (file)
@@ -701,6 +701,9 @@ void aio_context_setup(AioContext *ctx);
  */
 void aio_context_destroy(AioContext *ctx);
 
+/* Used internally, do not call outside AioContext code */
+void aio_context_use_g_source(AioContext *ctx);
+
 /**
  * aio_context_set_poll_params:
  * @ctx: the aio context
index 8af334ab1958492dcb1d23b481ca406830db9036..1b2a3af65b79d4f2f6804961407a7a44ebdd91bb 100644 (file)
@@ -682,6 +682,18 @@ void aio_context_destroy(AioContext *ctx)
     aio_free_deleted_handlers(ctx);
 }
 
+void aio_context_use_g_source(AioContext *ctx)
+{
+    /*
+     * Disable io_uring when the glib main loop is used because it doesn't
+     * support mixed glib/aio_poll() usage. It relies on aio_poll() being
+     * called regularly so that changes to the monitored file descriptors are
+     * submitted, otherwise a list of pending fd handlers builds up.
+     */
+    fdmon_io_uring_destroy(ctx);
+    aio_free_deleted_handlers(ctx);
+}
+
 void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,
                                  int64_t grow, int64_t shrink, Error **errp)
 {
index 729d533faf4d807e0a5388edd2afa4f9b1cf2959..953c56ab48a2f4bcf2ece21dd070ef0bc44f1265 100644 (file)
@@ -414,6 +414,10 @@ void aio_context_destroy(AioContext *ctx)
 {
 }
 
+void aio_context_use_g_source(AioContext *ctx)
+{
+}
+
 void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,
                                  int64_t grow, int64_t shrink, Error **errp)
 {
index 3165a28f2f77df330f2b42db98c2845d449d2260..1319eee3bc20661c34a3a4eb0c2b21c47b66ba5e 100644 (file)
@@ -362,6 +362,7 @@ static GSourceFuncs aio_source_funcs = {
 
 GSource *aio_get_g_source(AioContext *ctx)
 {
+    aio_context_use_g_source(ctx);
     g_source_ref(&ctx->source);
     return &ctx->source;
 }
This page took 0.02918 seconds and 4 git commands to generate.