From patchwork Tue Apr 6 00:51:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshiaki Tamura X-Patchwork-Id: 90715 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o360vWw1030469 for ; Tue, 6 Apr 2010 00:57:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756460Ab0DFA5b (ORCPT ); Mon, 5 Apr 2010 20:57:31 -0400 Received: from sh.osrg.net ([192.16.179.4]:47258 "EHLO sh.osrg.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756211Ab0DFA5Q (ORCPT ); Mon, 5 Apr 2010 20:57:16 -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 o360uo9G018680; Tue, 6 Apr 2010 09:56:50 +0900 Received: from localhost (hype-wd0.osrg.net [10.72.1.16]) by fs.osrg.net (Postfix) with ESMTP id 208B93E02EB; Tue, 6 Apr 2010 09:56:50 +0900 (JST) From: Yoshiaki Tamura To: kvm@vger.kernel.org, qemu-devel@nongnu.org Cc: avi@redhat.com, anthony@codemonkey.ws, aliguori@us.ibm.com, mtosatti@redhat.com, ohmura.kei@lab.ntt.co.jp, Yoshiaki Tamura Subject: [PATCH v2 2/6] Introduce bit-based phys_ram_dirty for VGA, CODE, MIGRATION and MASTER. Date: Tue, 6 Apr 2010 09:51:20 +0900 Message-Id: <1270515084-24120-3-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Mailer: git-send-email 1.7.0.31.g1df487 In-Reply-To: <1270515084-24120-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> References: <1270515084-24120-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Dispatcher: imput version 20070423(IM149) Lines: 62 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 06 Apr 2010 00:57:34 +0000 (UTC) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Tue, 06 Apr 2010 09:56:52 +0900 (JST) X-Virus-Scanned: clamav-milter 0.95.3 at sh X-Virus-Status: Clean Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/exec.c b/exec.c index c74b0a4..9733892 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_FLAGS]; static int in_migration; typedef struct RAMBlock { @@ -2825,10 +2825,32 @@ 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); +/* temporarily copy from qemu-kvm.git/qemu-kvm.h */ +#define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1)) +#define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8) + + if (BITMAP_SIZE(last_ram_offset + size) != BITMAP_SIZE(last_ram_offset)) { + phys_ram_dirty[MASTER_DIRTY_FLAG] = + qemu_realloc(phys_ram_dirty[MASTER_DIRTY_FLAG], + BITMAP_SIZE(last_ram_offset + size)); + phys_ram_dirty[VGA_DIRTY_FLAG] + = qemu_realloc(phys_ram_dirty[VGA_DIRTY_FLAG], + BITMAP_SIZE(last_ram_offset + size)); + phys_ram_dirty[CODE_DIRTY_FLAG] = + qemu_realloc(phys_ram_dirty[CODE_DIRTY_FLAG], + BITMAP_SIZE(last_ram_offset + size)); + phys_ram_dirty[MIGRATION_DIRTY_FLAG] = + qemu_realloc(phys_ram_dirty[MIGRATION_DIRTY_FLAG], + BITMAP_SIZE(last_ram_offset + size)); + memset((uint8_t *)phys_ram_dirty[MASTER_DIRTY_FLAG] + + BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size)); + memset((uint8_t *)phys_ram_dirty[VGA_DIRTY_FLAG] + + BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size)); + memset((uint8_t *)phys_ram_dirty[CODE_DIRTY_FLAG] + + BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size)); + memset((uint8_t *)phys_ram_dirty[MIGRATION_DIRTY_FLAG] + + BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size)); + } last_ram_offset += size;