[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 29/49] memory: split dirty bitmap into three
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 29/49] memory: split dirty bitmap into three |
Date: |
Mon, 13 Jan 2014 18:40:14 +0100 |
After all the previous patches, spliting the bitmap gets direct.
Note: For some reason, I have to move DIRTY_MEMORY_* definitions to
the beginning of memory.h to make compilation work.
Signed-off-by: Juan Quintela <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Orit Wasserman <address@hidden>
---
exec.c | 9 ++++++---
include/exec/cpu-all.h | 3 ++-
include/exec/memory-internal.h | 9 +++------
include/exec/memory.h | 10 +++++-----
4 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/exec.c b/exec.c
index db369dc..028eee4 100644
--- a/exec.c
+++ b/exec.c
@@ -1277,9 +1277,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..4cb4b4a 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -21,6 +21,7 @@
#include "qemu-common.h"
#include "exec/cpu-common.h"
+#include "exec/memory.h"
#include "qemu/thread.h"
#include "qom/cpu.h"
@@ -459,7 +460,7 @@ typedef struct RAMBlock {
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 666490c..6fb1b64 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) */
@@ -76,7 +76,7 @@ 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)
@@ -89,11 +89,8 @@ 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,
diff --git a/include/exec/memory.h b/include/exec/memory.h
index d5e9d58..296d6ab 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -16,6 +16,11 @@
#ifndef CONFIG_USER_ONLY
+#define DIRTY_MEMORY_VGA 0
+#define DIRTY_MEMORY_CODE 1
+#define DIRTY_MEMORY_MIGRATION 2
+#define DIRTY_MEMORY_NUM 3 /* num of dirty bits */
+
#include <stdint.h>
#include <stdbool.h>
#include "qemu-common.h"
@@ -33,11 +38,6 @@
typedef struct MemoryRegionOps MemoryRegionOps;
typedef struct MemoryRegionMmio MemoryRegionMmio;
-#define DIRTY_MEMORY_VGA 0
-#define DIRTY_MEMORY_CODE 1
-#define DIRTY_MEMORY_MIGRATION 2
-#define DIRTY_MEMORY_NUM 3 /* num of dirty bits */
-
struct MemoryRegionMmio {
CPUReadMemoryFunc *read[3];
CPUWriteMemoryFunc *write[3];
--
1.8.4.2
- [Qemu-devel] [PATCH 22/49] memory: cpu_physical_memory_set_dirty_range() always dirty all flags, (continued)
- [Qemu-devel] [PATCH 22/49] memory: cpu_physical_memory_set_dirty_range() always dirty all flags, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 19/49] memory: make cpu_physical_memory_is_dirty return bool, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 23/49] memory: cpu_physical_memory_mask_dirty_range() always clears a single flag, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 24/49] memory: use bit 2 for migration, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 25/49] memory: make sure that client is always inside range, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 26/49] memory: only resize dirty bitmap when memory size increases, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 27/49] memory: cpu_physical_memory_clear_dirty_flag() result is never used, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 28/49] bitmap: Add bitmap_zero_extend operation, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 30/49] memory: unfold cpu_physical_memory_clear_dirty_flag() in its only user, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 31/49] memory: unfold cpu_physical_memory_set_dirty() in its only user, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 29/49] memory: split dirty bitmap into three,
Juan Quintela <=
- [Qemu-devel] [PATCH 33/49] memory: make cpu_physical_memory_get_dirty() the main function, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 32/49] memory: unfold cpu_physical_memory_set_dirty_flag(), Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 35/49] memory: s/mask/clear/ cpu_physical_memory_mask_dirty_range, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 34/49] memory: cpu_physical_memory_get_dirty() is used as returning a bool, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 36/49] memory: use find_next_bit() to find dirty bits, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 38/49] memory: cpu_physical_memory_clear_dirty_range() now uses bitmap operations, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 39/49] memory: s/dirty/clean/ in cpu_physical_memory_is_dirty(), Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 37/49] memory: cpu_physical_memory_set_dirty_range() now uses bitmap operations, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 41/49] memory: cpu_physical_memory_set_dirty_tracking() should return void, Juan Quintela, 2014/01/13
- [Qemu-devel] [PATCH 42/49] memory: split cpu_physical_memory_* functions to its own include, Juan Quintela, 2014/01/13