From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTrxE-0005Kq-Uc for qemu-devel@nongnu.org; Wed, 09 Oct 2013 07:29:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTrx8-0001HC-MF for qemu-devel@nongnu.org; Wed, 09 Oct 2013 07:29:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44872) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTrx8-0001H5-EX for qemu-devel@nongnu.org; Wed, 09 Oct 2013 07:29:18 -0400 From: Juan Quintela Date: Wed, 9 Oct 2013 13:28:41 +0200 Message-Id: <1381318130-10620-20-git-send-email-quintela@redhat.com> In-Reply-To: <1381318130-10620-1-git-send-email-quintela@redhat.com> References: <1381318130-10620-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 19/28] memory: split dirty bitmap into three List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: chegu_vinod@hp.com 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 --- 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 f037473..6fd83c9 100644 --- a/exec.c +++ b/exec.c @@ -1182,9 +1182,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