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

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