9ae3a8
From 325f2d5f89e8275844a08c5fd0ea0e2ebe4874ca Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <325f2d5f89e8275844a08c5fd0ea0e2ebe4874ca.1387382496.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
9ae3a8
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
9ae3a8
From: Nigel Croxon <ncroxon@redhat.com>
9ae3a8
Date: Thu, 14 Nov 2013 22:53:16 +0100
9ae3a8
Subject: [PATCH 40/46] migration: ram_handle_compressed
9ae3a8
9ae3a8
RH-Author: Nigel Croxon <ncroxon@redhat.com>
9ae3a8
Message-id: <1384469598-13137-41-git-send-email-ncroxon@redhat.com>
9ae3a8
Patchwork-id: 55727
9ae3a8
O-Subject: [RHEL7.0 PATCH 40/42] migration: ram_handle_compressed
9ae3a8
Bugzilla: 1011720
9ae3a8
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
Bugzilla: 1011720
9ae3a8
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
9ae3a8
9ae3a8
>From commit ID:
9ae3a8
commit d613a56f845788412a442c6b5aff88b38244f99a
9ae3a8
Author: Isaku Yamahata <yamahata@private.email.ne.jp>
9ae3a8
Date:   Sat Sep 21 01:23:37 2013 +0900
9ae3a8
9ae3a8
    migration: ram_handle_compressed
9ae3a8
9ae3a8
    ram_handle_compressed() should be aware of size > TARGET_PAGE_SIZE.
9ae3a8
    migration-rdma can call it with larger size.
9ae3a8
9ae3a8
    Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
9ae3a8
    Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
---
9ae3a8
 arch_init.c |   11 ++++++-----
9ae3a8
 1 files changed, 6 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 arch_init.c | 11 ++++++-----
9ae3a8
 1 file changed, 6 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
diff --git a/arch_init.c b/arch_init.c
9ae3a8
index 5ce9c61..d71fb33 100644
9ae3a8
--- a/arch_init.c
9ae3a8
+++ b/arch_init.c
9ae3a8
@@ -848,13 +848,14 @@ static inline void *host_from_stream_offset(QEMUFile *f,
9ae3a8
  */
9ae3a8
 void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
9ae3a8
 {
9ae3a8
-    if (ch != 0 || !is_zero_range(host, TARGET_PAGE_SIZE)) {
9ae3a8
+    if (ch != 0 || !is_zero_range(host, size)) {
9ae3a8
         memset(host, ch, size);
9ae3a8
 #ifndef _WIN32
9ae3a8
-        if (ch == 0 &&
9ae3a8
-            (!kvm_enabled() || kvm_has_sync_mmu()) &&
9ae3a8
-            getpagesize() <= TARGET_PAGE_SIZE) {
9ae3a8
-            qemu_madvise(host, TARGET_PAGE_SIZE, QEMU_MADV_DONTNEED);
9ae3a8
+        if (ch == 0 && (!kvm_enabled() || kvm_has_sync_mmu())) {
9ae3a8
+            size = size & ~(getpagesize() - 1);
9ae3a8
+            if (size > 0) {
9ae3a8
+                qemu_madvise(host, size, QEMU_MADV_DONTNEED);
9ae3a8
+            }
9ae3a8
         }
9ae3a8
 #endif
9ae3a8
     }
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8