cryptospore / rpms / qemu-kvm

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