qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 14/38] memory: only resize dirty bitmap when mem


From: Orit Wasserman
Subject: Re: [Qemu-devel] [PATCH 14/38] memory: only resize dirty bitmap when memory size increases
Date: Wed, 18 Dec 2013 12:17:11 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 12/17/2013 05:25 PM, Juan Quintela wrote:
Signed-off-by: Juan Quintela <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
  exec.c | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/exec.c b/exec.c
index 9996da2..bed5c07 100644
--- a/exec.c
+++ b/exec.c
@@ -1210,6 +1210,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void 
*host,
                                     MemoryRegion *mr)
  {
      RAMBlock *block, *new_block;
+    ram_addr_t old_ram_size, new_ram_size;
+
+    old_ram_size = last_ram_offset() >> TARGET_PAGE_BITS;

      size = TARGET_PAGE_ALIGN(size);
      new_block = g_malloc0(sizeof(*new_block));
@@ -1270,10 +1273,13 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, 
void *host,
      ram_list.version++;
      qemu_mutex_unlock_ramlist();

-    ram_list.phys_dirty = g_realloc(ram_list.phys_dirty,
-                                       last_ram_offset() >> TARGET_PAGE_BITS);
-    memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
+    new_ram_size = last_ram_offset() >> TARGET_PAGE_BITS;
+
+    if (new_ram_size > old_ram_size) {
+        ram_list.phys_dirty = g_realloc(ram_list.phys_dirty, new_ram_size);
+        memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
             0, size >> TARGET_PAGE_BITS);
+    }
      cpu_physical_memory_set_dirty_range(new_block->offset, size);

      qemu_ram_setup_dump(new_block->host, size);


Reviewed-by: Orit Wasserman <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]