thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ae23c9
From 473673fd0f834adf72f80caddab0d942a99dfe03 Mon Sep 17 00:00:00 2001
ae23c9
From: Jeffrey Cody <jcody@redhat.com>
ae23c9
Date: Wed, 20 Jun 2018 17:44:46 +0200
ae23c9
Subject: [PATCH 059/268] main-loop: drop spin_counter
ae23c9
ae23c9
RH-Author: Jeffrey Cody <jcody@redhat.com>
ae23c9
Message-id: <835200bb37bc622f0f6f9c471c809a1b73a08482.1529516334.git.jcody@redhat.com>
ae23c9
Patchwork-id: 80906
ae23c9
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH v2 1/1] main-loop: drop spin_counter
ae23c9
Bugzilla: 1168213
ae23c9
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
ae23c9
ae23c9
From: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
ae23c9
Commit d759c951f3287fad04210a52f2dc93f94cf58c7f ("replay: push
ae23c9
replay_mutex_lock up the call tree") removed the !timeout lock
ae23c9
optimization in the main loop.
ae23c9
ae23c9
The idea of the optimization was to avoid ping-pongs between threads by
ae23c9
keeping the Big QEMU Lock held across non-blocking (!timeout) main loop
ae23c9
iterations.
ae23c9
ae23c9
A warning is printed when the main loop spins without releasing BQL for
ae23c9
long periods of time.  These warnings were supposed to aid debugging but
ae23c9
in practice they just alarm users.  They are considered noise because
ae23c9
the cause of spinning is not shown and is hard to find.
ae23c9
ae23c9
Now that the lock optimization has been removed, there is no danger of
ae23c9
hogging the BQL.  Drop the spin counter and the infamous warning.
ae23c9
ae23c9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
Reviewed-by: Jeff Cody <jcody@redhat.com>
ae23c9
(cherry picked from commit 21891a5a3011608845b5d7f1f9cce60cdc2bcc62)
ae23c9
Note: The original patch series from Stefan makes note that the
ae23c9
      patch can be dropped because the lock optimization changed
ae23c9
      upstream.
ae23c9
ae23c9
      However, even without that optimization change upstream, this
ae23c9
      warning / debug message is not very useful, and is just noise that
ae23c9
      does not aid in debugging.  Go ahead and remove it anyway.
ae23c9
Signed-off-by: Jeff Cody <jcody@redhat.com>
ae23c9
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 tests/qemu-iotests/common.filter |  1 -
ae23c9
 util/main-loop.c                 | 25 -------------------------
ae23c9
 2 files changed, 26 deletions(-)
ae23c9
ae23c9
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
ae23c9
index c5f4bcf..7acb454 100644
ae23c9
--- a/tests/qemu-iotests/common.filter
ae23c9
+++ b/tests/qemu-iotests/common.filter
ae23c9
@@ -77,7 +77,6 @@ _filter_qemu()
ae23c9
 {
ae23c9
     sed -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
ae23c9
         -e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
ae23c9
-        -e '/main-loop: WARNING: I\/O thread spun for [0-9]\+ iterations/d' \
ae23c9
         -e $'s#\r##' # QEMU monitor uses \r\n line endings
ae23c9
 }
ae23c9
 
ae23c9
diff --git a/util/main-loop.c b/util/main-loop.c
ae23c9
index 992f9b0..affe040 100644
ae23c9
--- a/util/main-loop.c
ae23c9
+++ b/util/main-loop.c
ae23c9
@@ -222,36 +222,11 @@ static int os_host_main_loop_wait(int64_t timeout)
ae23c9
 {
ae23c9
     GMainContext *context = g_main_context_default();
ae23c9
     int ret;
ae23c9
-    static int spin_counter;
ae23c9
 
ae23c9
     g_main_context_acquire(context);
ae23c9
 
ae23c9
     glib_pollfds_fill(&timeout);
ae23c9
 
ae23c9
-    /* If the I/O thread is very busy or we are incorrectly busy waiting in
ae23c9
-     * the I/O thread, this can lead to starvation of the BQL such that the
ae23c9
-     * VCPU threads never run.  To make sure we can detect the later case,
ae23c9
-     * print a message to the screen.  If we run into this condition, create
ae23c9
-     * a fake timeout in order to give the VCPU threads a chance to run.
ae23c9
-     */
ae23c9
-    if (!timeout && (spin_counter > MAX_MAIN_LOOP_SPIN)) {
ae23c9
-        static bool notified;
ae23c9
-
ae23c9
-        if (!notified && !qtest_enabled() && !qtest_driver()) {
ae23c9
-            warn_report("I/O thread spun for %d iterations",
ae23c9
-                        MAX_MAIN_LOOP_SPIN);
ae23c9
-            notified = true;
ae23c9
-        }
ae23c9
-
ae23c9
-        timeout = SCALE_MS;
ae23c9
-    }
ae23c9
-
ae23c9
-
ae23c9
-    if (timeout) {
ae23c9
-        spin_counter = 0;
ae23c9
-    } else {
ae23c9
-        spin_counter++;
ae23c9
-    }
ae23c9
     qemu_mutex_unlock_iothread();
ae23c9
     replay_mutex_unlock();
ae23c9
 
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9