From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O1Ea8-00008g-6M for qemu-devel@nongnu.org; Mon, 12 Apr 2010 04:01:20 -0400 Received: from [140.186.70.92] (port=40876 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1Ea6-00008D-UR for qemu-devel@nongnu.org; Mon, 12 Apr 2010 04:01:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O1Ea5-0004p6-7a for qemu-devel@nongnu.org; Mon, 12 Apr 2010 04:01:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38601) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1Ea4-0004oq-Vy for qemu-devel@nongnu.org; Mon, 12 Apr 2010 04:01:17 -0400 Message-ID: <4BC2D340.2030402@redhat.com> Date: Mon, 12 Apr 2010 11:01:04 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1270515084-24120-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> <1270515084-24120-3-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> In-Reply-To: <1270515084-24120-3-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH v2 2/6] Introduce bit-based phys_ram_dirty for VGA, CODE, MIGRATION and MASTER. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yoshiaki Tamura Cc: aliguori@us.ibm.com, kvm@vger.kernel.org, ohmura.kei@lab.ntt.co.jp, mtosatti@redhat.com, qemu-devel@nongnu.org On 04/06/2010 03:51 AM, Yoshiaki Tamura wrote: > Replaces byte-based phys_ram_dirty bitmap with three bit-based phys_ram_dirty > bitmap. On allocation, it sets all bits in the bitmap. > > > > 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) > Please put in some header file, maybe qemu-common.h. > + > + 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)); > + } > > Should be nicer as a loop calling a helper to allocate each bitmap. This patch won't work by itself, will it? I think you need to merge it with the succeeding patches. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.