From patchwork Mon Jan 13 17:40:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 310287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 926CC2C0079 for ; Tue, 14 Jan 2014 04:55:17 +1100 (EST) Received: from localhost ([::1]:44234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2ljH-0006GV-85 for incoming@patchwork.ozlabs.org; Mon, 13 Jan 2014 12:55:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2lVw-0002WL-RD for qemu-devel@nongnu.org; Mon, 13 Jan 2014 12:41:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2lVq-0006zv-KR for qemu-devel@nongnu.org; Mon, 13 Jan 2014 12:41:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2lVq-0006ze-Cs for qemu-devel@nongnu.org; Mon, 13 Jan 2014 12:41:22 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0DHfHAs032056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Jan 2014 12:41:17 -0500 Received: from trasno.mitica (ovpn-113-92.phx2.redhat.com [10.3.113.92]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0DHeZYc019893; Mon, 13 Jan 2014 12:41:16 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 13 Jan 2014 18:40:14 +0100 Message-Id: <1389634834-24181-30-git-send-email-quintela@redhat.com> In-Reply-To: <1389634834-24181-1-git-send-email-quintela@redhat.com> References: <1389634834-24181-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH 29/49] memory: split dirty bitmap into three X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Eric Blake Reviewed-by: Orit Wasserman --- 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 #include #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];