cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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