yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-memory-only-resize-dirty-bitmap-when-memory-size-inc.patch

9ae3a8
From 1e5621a56dcf27b1b9d04bc749e7fbeaa1e17729 Mon Sep 17 00:00:00 2001
9ae3a8
From: Juan Quintela <quintela@redhat.com>
9ae3a8
Date: Tue, 14 Jan 2014 15:07:26 +0100
9ae3a8
Subject: [PATCH 15/40] memory: only resize dirty bitmap when memory size increases
9ae3a8
9ae3a8
RH-Author: Juan Quintela <quintela@redhat.com>
9ae3a8
Message-id: <1389712071-23303-16-git-send-email-quintela@redhat.com>
9ae3a8
Patchwork-id: 56672
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 15/40] memory: only resize dirty bitmap when memory size increases
9ae3a8
Bugzilla: 997559
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
9ae3a8
9ae3a8
Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
(cherry picked from commit 2152f5ca782e51a4d05a1f7d9bfa83286323cbc9)
9ae3a8
Signed-off-by: Juan Quintela <quintela@trasno.org>
9ae3a8
---
9ae3a8
 exec.c | 12 +++++++++---
9ae3a8
 1 file changed, 9 insertions(+), 3 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 exec.c |   12 +++++++++---
9ae3a8
 1 files changed, 9 insertions(+), 3 deletions(-)
9ae3a8
9ae3a8
diff --git a/exec.c b/exec.c
9ae3a8
index 8942d50..be99d45 100644
9ae3a8
--- a/exec.c
9ae3a8
+++ b/exec.c
9ae3a8
@@ -1098,6 +1098,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
9ae3a8
                                    MemoryRegion *mr)
9ae3a8
 {
9ae3a8
     RAMBlock *block, *new_block;
9ae3a8
+    ram_addr_t old_ram_size, new_ram_size;
9ae3a8
+
9ae3a8
+    old_ram_size = last_ram_offset() >> TARGET_PAGE_BITS;
9ae3a8
 
9ae3a8
     size = TARGET_PAGE_ALIGN(size);
9ae3a8
     new_block = g_malloc0(sizeof(*new_block));
9ae3a8
@@ -1158,10 +1161,13 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
9ae3a8
     ram_list.version++;
9ae3a8
     qemu_mutex_unlock_ramlist();
9ae3a8
 
9ae3a8
-    ram_list.phys_dirty = g_realloc(ram_list.phys_dirty,
9ae3a8
-                                       last_ram_offset() >> TARGET_PAGE_BITS);
9ae3a8
-    memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
9ae3a8
+    new_ram_size = last_ram_offset() >> TARGET_PAGE_BITS;
9ae3a8
+
9ae3a8
+    if (new_ram_size > old_ram_size) {
9ae3a8
+        ram_list.phys_dirty = g_realloc(ram_list.phys_dirty, new_ram_size);
9ae3a8
+        memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
9ae3a8
            0, size >> TARGET_PAGE_BITS);
9ae3a8
+    }
9ae3a8
     cpu_physical_memory_set_dirty_range(new_block->offset, size);
9ae3a8
 
9ae3a8
     qemu_ram_setup_dump(new_block->host, size);
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8