26ba25
From 486481ac5bddfab22b74bcebcbd27af1f7a604f5 Mon Sep 17 00:00:00 2001
26ba25
From: Alex Williamson <alex.williamson@redhat.com>
26ba25
Date: Mon, 3 Dec 2018 22:01:34 +0000
26ba25
Subject: [PATCH 11/16] kvm: Use inhibit to prevent ballooning without
26ba25
 synchronous mmu
26ba25
26ba25
RH-Author: Alex Williamson <alex.williamson@redhat.com>
26ba25
Message-id: <154387449407.27651.8902076548922742582.stgit@gimli.home>
26ba25
Patchwork-id: 83237
26ba25
O-Subject: [RHEL-8.0 qemu-kvm PATCH 2/7] kvm: Use inhibit to prevent ballooning without synchronous mmu
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
Remove KVM specific tests in balloon_page(), instead marking
26ba25
ballooning as inhibited without KVM_CAP_SYNC_MMU support.
26ba25
26ba25
Reviewed-by: David Hildenbrand <david@redhat.com>
26ba25
Reviewed-by: Peter Xu <peterx@redhat.com>
26ba25
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
26ba25
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
26ba25
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
26ba25
(cherry picked from commit f59489423ab79852e98d9b3025b7d99ba8da584f)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 accel/kvm/kvm-all.c        | 4 ++++
26ba25
 hw/virtio/virtio-balloon.c | 4 +---
26ba25
 2 files changed, 5 insertions(+), 3 deletions(-)
26ba25
26ba25
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
26ba25
index 3f1c06e..3a7c8a3 100644
26ba25
--- a/accel/kvm/kvm-all.c
26ba25
+++ b/accel/kvm/kvm-all.c
26ba25
@@ -39,6 +39,7 @@
26ba25
 #include "trace.h"
26ba25
 #include "hw/irq.h"
26ba25
 #include "sysemu/sev.h"
26ba25
+#include "sysemu/balloon.h"
26ba25
 
26ba25
 #include "hw/boards.h"
26ba25
 
26ba25
@@ -1711,6 +1712,9 @@ static int kvm_init(MachineState *ms)
26ba25
     s->many_ioeventfds = kvm_check_many_ioeventfds();
26ba25
 
26ba25
     s->sync_mmu = !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
26ba25
+    if (!s->sync_mmu) {
26ba25
+        qemu_balloon_inhibit(true);
26ba25
+    }
26ba25
 
26ba25
     return 0;
26ba25
 
26ba25
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
26ba25
index f456cea..4aab291 100644
26ba25
--- a/hw/virtio/virtio-balloon.c
26ba25
+++ b/hw/virtio/virtio-balloon.c
26ba25
@@ -21,7 +21,6 @@
26ba25
 #include "hw/mem/pc-dimm.h"
26ba25
 #include "sysemu/balloon.h"
26ba25
 #include "hw/virtio/virtio-balloon.h"
26ba25
-#include "sysemu/kvm.h"
26ba25
 #include "exec/address-spaces.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "qapi/qapi-events-misc.h"
26ba25
@@ -36,8 +35,7 @@
26ba25
 
26ba25
 static void balloon_page(void *addr, int deflate)
26ba25
 {
26ba25
-    if (!qemu_balloon_is_inhibited() && (!kvm_enabled() ||
26ba25
-                                         kvm_has_sync_mmu())) {
26ba25
+    if (!qemu_balloon_is_inhibited()) {
26ba25
         qemu_madvise(addr, BALLOON_PAGE_SIZE,
26ba25
                 deflate ? QEMU_MADV_WILLNEED : QEMU_MADV_DONTNEED);
26ba25
     }
26ba25
-- 
26ba25
1.8.3.1
26ba25