From patchwork Mon Apr 19 09:43:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshiaki Tamura X-Patchwork-Id: 50439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A3AACB7D0F for ; Mon, 19 Apr 2010 20:28:59 +1000 (EST) Received: from localhost ([127.0.0.1]:51586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3o6z-0005Cz-Uk for incoming@patchwork.ozlabs.org; Mon, 19 Apr 2010 06:21:53 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O3nav-00071W-NJ for qemu-devel@nongnu.org; Mon, 19 Apr 2010 05:48:45 -0400 Received: from [140.186.70.92] (port=52064 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3nat-0006zG-4o for qemu-devel@nongnu.org; Mon, 19 Apr 2010 05:48:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O3nah-0007uk-8a for qemu-devel@nongnu.org; Mon, 19 Apr 2010 05:48:43 -0400 Received: from sh.osrg.net ([192.16.179.4]:33416) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O3nag-0007t2-Ly for qemu-devel@nongnu.org; Mon, 19 Apr 2010 05:48:31 -0400 Received: from fs.osrg.net (postfix@fs.osrg.net [10.0.0.12]) by sh.osrg.net (8.14.3/8.14.3/OSRG-NET) with ESMTP id o3J9mKxN008806; Mon, 19 Apr 2010 18:48:21 +0900 Received: from localhost (hype-wd0.osrg.net [10.72.1.16]) by fs.osrg.net (Postfix) with ESMTP id 4CAEB3E02EF; Mon, 19 Apr 2010 18:48:20 +0900 (JST) From: Yoshiaki Tamura To: qemu-devel@nongnu.org Date: Mon, 19 Apr 2010 18:43:14 +0900 Message-Id: <1271670198-12793-3-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Mailer: git-send-email 1.7.0.31.g1df487 In-Reply-To: <1271670198-12793-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> References: <1271670198-12793-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Dispatcher: imput version 20070423(IM149) Lines: 60 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Mon, 19 Apr 2010 18:48:22 +0900 (JST) X-Virus-Scanned: clamav-milter 0.95.3 at sh X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: aliguori@us.ibm.com, ohmura.kei@lab.ntt.co.jp, mtosatti@redhat.com, Yoshiaki Tamura , avi@redhat.com Subject: [Qemu-devel] [PATCH v3 2/6] Introduce bit-based phys_ram_dirty for VGA, CODE, MIGRATION and MASTER. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Replaces byte-based phys_ram_dirty bitmap with four bit-based phys_ram_dirty bitmap. On allocation, it sets all bits in the bitmap. Signed-off-by: Yoshiaki Tamura --- exec.c | 16 +++++++++++----- qemu-common.h | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/exec.c b/exec.c index c74b0a4..b85cb26 100644 --- a/exec.c +++ b/exec.c @@ -110,7 +110,7 @@ uint8_t *code_gen_ptr; #if !defined(CONFIG_USER_ONLY) int phys_ram_fd; -uint8_t *phys_ram_dirty; +unsigned long *phys_ram_dirty[NUM_DIRTY_IDX]; static int in_migration; typedef struct RAMBlock { @@ -2825,10 +2825,16 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size) new_block->next = ram_blocks; ram_blocks = new_block; - phys_ram_dirty = qemu_realloc(phys_ram_dirty, - (last_ram_offset + size) >> TARGET_PAGE_BITS); - memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS), - 0xff, size >> TARGET_PAGE_BITS); + if (BITMAP_SIZE(last_ram_offset + size) != BITMAP_SIZE(last_ram_offset)) { + int i; + for (i = MASTER_DIRTY_IDX; i < NUM_DIRTY_IDX; i++) { + phys_ram_dirty[i] + = qemu_realloc(phys_ram_dirty[i], + BITMAP_SIZE(last_ram_offset + size)); + memset((uint8_t *)phys_ram_dirty[i] + + BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size)); + } + } last_ram_offset += size; diff --git a/qemu-common.h b/qemu-common.h index 4ba0cda..efe5b1f 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -285,6 +285,9 @@ static inline uint8_t from_bcd(uint8_t val) return ((val >> 4) * 10) + (val & 0x0f); } +#define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1)) +#define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8) + #include "module.h" #endif /* dyngen-exec.h hack */