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