[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/39] memory: split dirty bitmap into three
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 19/39] memory: split dirty bitmap into three |
Date: |
Wed, 6 Nov 2013 14:04:28 +0100 |
After all the previous patches, spliting the bitmap gets direct.
ToDo: Why can't i include "exec/memory.h" into cpu-all.h? This is the
reason that I have duplicated DIRTY_MEMORY_NUM.
ToDo2: current bitmaps have one int as index, this limit us to 8TB RAM
guest, Should we move to longs?
Signed-off-by: Juan Quintela <address@hidden>
---
exec.c | 9 ++++++---
include/exec/cpu-all.h | 4 +++-
include/exec/memory-internal.h | 11 ++++-------
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/exec.c b/exec.c
index 38b5c1c..98700d3 100644
--- a/exec.c
+++ b/exec.c
@@ -1166,9 +1166,12 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void
*host,
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);
+ int i;
+ for (i = 0; i < DIRTY_MEMORY_NUM; i++) {
+ ram_list.dirty_memory[i] =
+ bitmap_zero_extend(ram_list.dirty_memory[i],
+ old_ram_size, new_ram_size);
+ }
}
cpu_physical_memory_set_dirty_range(new_block->offset, size);
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index b6998f0..019dc20 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -456,10 +456,12 @@ typedef struct RAMBlock {
int fd;
} RAMBlock;
+#define DIRTY_MEMORY_NUM 3
+
typedef struct RAMList {
QemuMutex mutex;
/* Protected by the iothread lock. */
- uint8_t *phys_dirty;
+ unsigned long *dirty_memory[DIRTY_MEMORY_NUM];
RAMBlock *mru_block;
/* Protected by the ramlist lock. */
QTAILQ_HEAD(, RAMBlock) blocks;
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
index 3f885a6..71f198e 100644
--- a/include/exec/memory-internal.h
+++ b/include/exec/memory-internal.h
@@ -44,7 +44,7 @@ static inline bool
cpu_physical_memory_get_dirty_flag(ram_addr_t addr,
unsigned client)
{
assert(client < DIRTY_MEMORY_NUM);
- return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & (1 << client);
+ return test_bit(addr >> TARGET_PAGE_BITS, ram_list.dirty_memory[client]);
}
/* read dirty bit (return 0 or 1) */
@@ -75,7 +75,8 @@ static inline void
cpu_physical_memory_set_dirty_flag(ram_addr_t addr,
unsigned client)
{
assert(client < DIRTY_MEMORY_NUM);
- ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= (1 << client);
+
+ set_bit(addr >> TARGET_PAGE_BITS, ram_list.dirty_memory[client]);
}
static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
@@ -88,11 +89,7 @@ static inline void cpu_physical_memory_set_dirty(ram_addr_t
addr)
static inline void cpu_physical_memory_clear_dirty_flag(ram_addr_t addr,
unsigned client)
{
- int mask = ~(1 << client);
-
- assert(client < DIRTY_MEMORY_NUM);
-
- ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask;
+ clear_bit(addr >> TARGET_PAGE_BITS, ram_list.dirty_memory[client]);
}
static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
--
1.8.3.1
- [Qemu-devel] [PATCH 09/39] memory: all users of cpu_physical_memory_get_dirty used only one flag, (continued)
- [Qemu-devel] [PATCH 09/39] memory: all users of cpu_physical_memory_get_dirty used only one flag, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 12/39] memory: cpu_physical_memory_mask_dirty_range() always clear a single flag, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 13/39] memory: use DIRTY_MEMORY_* instead of *_DIRTY_FLAG, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 14/39] memory: use bit 2 for migration, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 15/39] memory: make sure that client is always inside range, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 16/39] memory: only resize dirty bitmap when memory size increases, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 17/39] memory: cpu_physical_memory_clear_dirty_flag() result is never used, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 18/39] bitmap: Add bitmap_zero_extend operation, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 19/39] memory: split dirty bitmap into three,
Juan Quintela <=
- [Qemu-devel] [PATCH 20/39] memory: unfold cpu_physical_memory_clear_dirty_flag() in its only user, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 21/39] memory: unfold cpu_physical_memory_set_dirty() in its only user, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 22/39] memory: unfold cpu_physical_memory_set_dirty_flag(), Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 23/39] memory: make cpu_physical_memory_get_dirty() the main function, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 24/39] memory: cpu_physical_memory_get_dirty() is used as returning a bool, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 26/39] memory: use find_next_bit() to find dirty bits, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 25/39] memory: s/mask/clear/ cpu_physical_memory_mask_dirty_range, Juan Quintela, 2013/11/06
- [Qemu-devel] [PATCH 27/39] memory: cpu_physical_memory_set_dirty_range() now uses bitmap operations, Juan Quintela, 2013/11/06