thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-aio-posix-do-skip-system-call-if-ctx-notifier-pollin.patch

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