thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-memory-move-bitmap-synchronization-to-its-own-functi.patch

9ae3a8
From e484992052b63d94c3bcdce6f070eb55f635212b Mon Sep 17 00:00:00 2001
9ae3a8
From: Juan Quintela <quintela@redhat.com>
9ae3a8
Date: Tue, 14 Jan 2014 15:07:48 +0100
9ae3a8
Subject: [PATCH 37/40] memory: move bitmap synchronization to its own function
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
RH-Author: Juan Quintela <quintela@redhat.com>
9ae3a8
Message-id: <1389712071-23303-38-git-send-email-quintela@redhat.com>
9ae3a8
Patchwork-id: 56692
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 37/40] memory: move bitmap synchronization to its own function
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
We want to have all the functions that handle directly the dirty
9ae3a8
bitmap near.  We will change it later.
9ae3a8
9ae3a8
Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
(cherry picked from commit 5ff7fb77b3cee8e26648e4fdccb23a77c2a6d3c6)
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	kvm-all.c
9ae3a8
9ae3a8
commit dd1750d7981cf9e38985c9dfa474dcdbbe236270
9ae3a8
Author: Andreas Färber <afaerber@suse.de>
9ae3a8
Date:   Wed May 1 13:45:44 2013 +0200
9ae3a8
9ae3a8
    kvm: Change kvm_cpu_synchronize_state() argument to CPUState
9ae3a8
9ae3a8
Signed-off-by: Juan Quintela <quintela@trasno.org>
9ae3a8
---
9ae3a8
 include/exec/ram_addr.h | 31 +++++++++++++++++++++++++++++++
9ae3a8
 kvm-all.c               | 26 ++------------------------
9ae3a8
 2 files changed, 33 insertions(+), 24 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 include/exec/ram_addr.h |   31 +++++++++++++++++++++++++++++++
9ae3a8
 kvm-all.c               |   28 +++-------------------------
9ae3a8
 2 files changed, 34 insertions(+), 25 deletions(-)
9ae3a8
9ae3a8
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
9ae3a8
index 0caa239..9962e12 100644
9ae3a8
--- a/include/exec/ram_addr.h
9ae3a8
+++ b/include/exec/ram_addr.h
9ae3a8
@@ -78,6 +78,37 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
9ae3a8
     xen_modified_memory(start, length);
9ae3a8
 }
9ae3a8
 
9ae3a8
+static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
9ae3a8
+                                                          ram_addr_t start,
9ae3a8
+                                                          ram_addr_t pages)
9ae3a8
+{
9ae3a8
+    unsigned int i, j;
9ae3a8
+    unsigned long page_number, c;
9ae3a8
+    hwaddr addr;
9ae3a8
+    ram_addr_t ram_addr;
9ae3a8
+    unsigned int len = (pages + HOST_LONG_BITS - 1) / HOST_LONG_BITS;
9ae3a8
+    unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE;
9ae3a8
+
9ae3a8
+    /*
9ae3a8
+     * bitmap-traveling is faster than memory-traveling (for addr...)
9ae3a8
+     * especially when most of the memory is not dirty.
9ae3a8
+     */
9ae3a8
+    for (i = 0; i < len; i++) {
9ae3a8
+        if (bitmap[i] != 0) {
9ae3a8
+            c = leul_to_cpu(bitmap[i]);
9ae3a8
+            do {
9ae3a8
+                j = ffsl(c) - 1;
9ae3a8
+                c &= ~(1ul << j);
9ae3a8
+                page_number = (i * HOST_LONG_BITS + j) * hpratio;
9ae3a8
+                addr = page_number * TARGET_PAGE_SIZE;
9ae3a8
+                ram_addr = start + addr;
9ae3a8
+                cpu_physical_memory_set_dirty_range(ram_addr,
9ae3a8
+                                                    TARGET_PAGE_SIZE * hpratio);
9ae3a8
+            } while (c != 0);
9ae3a8
+        }
9ae3a8
+    }
9ae3a8
+}
9ae3a8
+
9ae3a8
 static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start,
9ae3a8
                                                          ram_addr_t length,
9ae3a8
                                                          unsigned client)
9ae3a8
diff --git a/kvm-all.c b/kvm-all.c
9ae3a8
index d3aa869..19acd58 100644
9ae3a8
--- a/kvm-all.c
9ae3a8
+++ b/kvm-all.c
9ae3a8
@@ -365,32 +365,10 @@ static int kvm_set_migration_log(int enable)
9ae3a8
 static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section,
9ae3a8
                                          unsigned long *bitmap)
9ae3a8
 {
9ae3a8
-    unsigned int i, j;
9ae3a8
-    unsigned long page_number, c;
9ae3a8
-    hwaddr addr;
9ae3a8
     ram_addr_t start = section->offset_within_region + section->mr->ram_addr;
9ae3a8
-    ram_addr_t ram_addr;
9ae3a8
-    unsigned int len = ((section->size / getpagesize()) + HOST_LONG_BITS - 1) / HOST_LONG_BITS;
9ae3a8
-    unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE;
9ae3a8
+    ram_addr_t pages = section->size / getpagesize();
9ae3a8
 
9ae3a8
-    /*
9ae3a8
-     * bitmap-traveling is faster than memory-traveling (for addr...)
9ae3a8
-     * especially when most of the memory is not dirty.
9ae3a8
-     */
9ae3a8
-    for (i = 0; i < len; i++) {
9ae3a8
-        if (bitmap[i] != 0) {
9ae3a8
-            c = leul_to_cpu(bitmap[i]);
9ae3a8
-            do {
9ae3a8
-                j = ffsl(c) - 1;
9ae3a8
-                c &= ~(1ul << j);
9ae3a8
-                page_number = (i * HOST_LONG_BITS + j) * hpratio;
9ae3a8
-                addr = page_number * TARGET_PAGE_SIZE;
9ae3a8
-                ram_addr = start + addr;
9ae3a8
-                cpu_physical_memory_set_dirty_range(ram_addr,
9ae3a8
-                                                    TARGET_PAGE_SIZE * hpratio);
9ae3a8
-            } while (c != 0);
9ae3a8
-        }
9ae3a8
-    }
9ae3a8
+    cpu_physical_memory_set_dirty_lebitmap(bitmap, start, pages);
9ae3a8
     return 0;
9ae3a8
 }
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8