Blame SOURCES/kvm-postcopy-Synchronize-usage-of-the-balloon-inhibitor.patch

7711c0
From 4c1361e2dfac092c94077a20610087871c7878f4 Mon Sep 17 00:00:00 2001
7711c0
From: Alex Williamson <alex.williamson@redhat.com>
7711c0
Date: Mon, 3 Dec 2018 21:54:25 +0100
7711c0
Subject: [PATCH 24/34] postcopy: Synchronize usage of the balloon inhibitor
7711c0
7711c0
RH-Author: Alex Williamson <alex.williamson@redhat.com>
7711c0
Message-id: <154387406568.26945.10032109321234466443.stgit@gimli.home>
7711c0
Patchwork-id: 83233
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 7/7] postcopy: Synchronize usage of the balloon inhibitor
7711c0
Bugzilla: 1619778
7711c0
RH-Acked-by: Peter Xu <peterx@redhat.com>
7711c0
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
7711c0
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
7711c0
RH-Acked-by: David Hildenbrand <david@redhat.com>
7711c0
7711c0
Bugzilla: 1619778
7711c0
7711c0
While the qemu_balloon_inhibit() interface appears rather general purpose,
7711c0
postcopy uses it in a last-caller-wins approach with no guarantee of balanced
7711c0
inhibits and de-inhibits.  Wrap postcopy's usage of the inhibitor to give it
7711c0
one vote overall, using the same last-caller-wins approach as previously
7711c0
implemented at the balloon level.
7711c0
7711c0
Fixes: 01ccbec7bdf6 ("balloon: Allow multiple inhibit users")
7711c0
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
7711c0
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
7711c0
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
7711c0
Reviewed-by: Juan Quintela <quintela@redhat.com>
7711c0
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
7711c0
(cherry picked from commit 154304cd6e99e4222ed762976f9d9aca33c094d3)
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 migration/postcopy-ram.c | 18 ++++++++++++++++--
7711c0
 1 file changed, 16 insertions(+), 2 deletions(-)
7711c0
7711c0
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
7711c0
index 001b041..4b65ff9 100644
7711c0
--- a/migration/postcopy-ram.c
7711c0
+++ b/migration/postcopy-ram.c
7711c0
@@ -400,6 +400,20 @@ int postcopy_ram_incoming_init(MigrationIncomingState *mis, size_t ram_pages)
7711c0
 }
7711c0
 
7711c0
 /*
7711c0
+ * Manage a single vote to the QEMU balloon inhibitor for all postcopy usage,
7711c0
+ * last caller wins.
7711c0
+ */
7711c0
+static void postcopy_balloon_inhibit(bool state)
7711c0
+{
7711c0
+    static bool cur_state = false;
7711c0
+
7711c0
+    if (state != cur_state) {
7711c0
+        qemu_balloon_inhibit(state);
7711c0
+        cur_state = state;
7711c0
+    }
7711c0
+}
7711c0
+
7711c0
+/*
7711c0
  * At the end of a migration where postcopy_ram_incoming_init was called.
7711c0
  */
7711c0
 int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
7711c0
@@ -429,7 +443,7 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
7711c0
         mis->have_fault_thread = false;
7711c0
     }
7711c0
 
7711c0
-    qemu_balloon_inhibit(false);
7711c0
+    postcopy_balloon_inhibit(false);
7711c0
 
7711c0
     if (enable_mlock) {
7711c0
         if (os_mlock() < 0) {
7711c0
@@ -801,7 +815,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState *mis)
7711c0
      * Ballooning can mark pages as absent while we're postcopying
7711c0
      * that would cause false userfaults.
7711c0
      */
7711c0
-    qemu_balloon_inhibit(true);
7711c0
+    postcopy_balloon_inhibit(true);
7711c0
 
7711c0
     trace_postcopy_ram_enable_notify();
7711c0
 
7711c0
-- 
7711c0
1.8.3.1
7711c0