26ba25
From bd738e0bbc2fec04c928959e8e7e99af03024782 Mon Sep 17 00:00:00 2001
26ba25
From: Fam Zheng <famz@redhat.com>
26ba25
Date: Tue, 9 Oct 2018 08:16:51 +0100
26ba25
Subject: [PATCH 07/17] aio-posix: do skip system call if ctx->notifier polling
26ba25
 succeeds
26ba25
26ba25
RH-Author: Fam Zheng <famz@redhat.com>
26ba25
Message-id: <20181009081651.15463-6-famz@redhat.com>
26ba25
Patchwork-id: 82449
26ba25
O-Subject: [RHEL8/rhel qemu-kvm PATCH 5/5] aio-posix: do skip system call if ctx->notifier polling succeeds
26ba25
Bugzilla: 1632622
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
26ba25
26ba25
From: Paolo Bonzini <pbonzini@redhat.com>
26ba25
26ba25
BZ: 1632622
26ba25
26ba25
Commit 70232b5253 ("aio-posix: Don't count ctx->notifier as progress when
26ba25
2018-08-15), by not reporting progress, causes aio_poll to execute the
26ba25
system call when polling succeeds because of ctx->notifier.  This introduces
26ba25
latency before the call to aio_bh_poll() and negates the advantages of
26ba25
polling, unfortunately.
26ba25
26ba25
The fix builds on the previous patch, separating the effect of polling on
26ba25
the timeout from the progress reported to aio_poll().  ctx->notifier
26ba25
does zero the timeout, causing the caller to skip the system call,
26ba25
but it does not report progress, so that the bug fix of commit 70232b5253
26ba25
still stands.
26ba25
26ba25
Fixes: 70232b5253a3c4e03ed1ac47ef9246a8ac66c6fa
26ba25
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
26ba25
Message-Id: <20180912171040.1732-4-pbonzini@redhat.com>
26ba25
Reviewed-by: Fam Zheng <famz@redhat.com>
26ba25
Signed-off-by: Fam Zheng <famz@redhat.com>
26ba25
(cherry picked from commit cfeb35d6774b2e936046aa9923217818bd160299)
26ba25
Signed-off-by: Fam Zheng <famz@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 util/aio-posix.c | 7 ++++---
26ba25
 1 file changed, 4 insertions(+), 3 deletions(-)
26ba25
26ba25
diff --git a/util/aio-posix.c b/util/aio-posix.c
26ba25
index 1b17597..357de8a 100644
26ba25
--- a/util/aio-posix.c
26ba25
+++ b/util/aio-posix.c
26ba25
@@ -498,10 +498,11 @@ static bool run_poll_handlers_once(AioContext *ctx, int64_t *timeout)
26ba25
     QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
26ba25
         if (!node->deleted && node->io_poll &&
26ba25
             aio_node_check(ctx, node->is_external) &&
26ba25
-            node->io_poll(node->opaque) &&
26ba25
-            node->opaque != &ctx->notifier) {
26ba25
+            node->io_poll(node->opaque)) {
26ba25
             *timeout = 0;
26ba25
-            progress = true;
26ba25
+            if (node->opaque != &ctx->notifier) {
26ba25
+                progress = true;
26ba25
+            }
26ba25
         }
26ba25
 
26ba25
         /* Caller handles freeing deleted nodes.  Don't do it here. */
26ba25
-- 
26ba25
1.8.3.1
26ba25