From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NfYNX-0007k7-JP for qemu-devel@nongnu.org; Thu, 11 Feb 2010 07:42:43 -0500 Received: from [199.232.76.173] (port=43812 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfYNV-0007iz-Bl for qemu-devel@nongnu.org; Thu, 11 Feb 2010 07:42:41 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NfYNU-0000LH-Ei for qemu-devel@nongnu.org; Thu, 11 Feb 2010 07:42:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31865) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NfYNU-0000L7-1A for qemu-devel@nongnu.org; Thu, 11 Feb 2010 07:42:40 -0500 Message-ID: <4B73FB39.1000200@redhat.com> Date: Thu, 11 Feb 2010 14:42:33 +0200 From: Avi Kivity MIME-Version: 1.0 References: <4B6FE5DA.6000502@lab.ntt.co.jp> In-Reply-To: <4B6FE5DA.6000502@lab.ntt.co.jp> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 1/3] qemu-kvm: Wrap phys_ram_dirty with additional inline functions. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: OHMURA Kei Cc: Jan Kiszka , qemu-devel@nongnu.org, kvm@vger.kernel.org On 02/08/2010 12:22 PM, OHMURA Kei wrote: > We think access phys_ram_dirty through inline functions is better > than directly for encoupseling reason. > > We devided the ram in a 64 pages block. Each block has a counter, which is > stored in phys_ram_dirty_by_word. It shows the number of dirty pages. > We will find the 64 pages block is dirty or non-dirty using > phys_ram_dirty_by_word. > > Signed-off-by: OHMURA Kei > --- > cpu-all.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > cpu-defs.h | 1 + > 2 files changed, 75 insertions(+), 0 deletions(-) > > diff --git a/cpu-all.h b/cpu-all.h > index 8ed76c7..2251f14 100644 > --- a/cpu-all.h > +++ b/cpu-all.h > @@ -168,6 +168,33 @@ typedef union { > } CPU_QuadU; > #endif > > +static inline unsigned long unroll_flags_to_ul(int flags) > +{ > + unsigned long ret = 0, flags_ul = (unsigned long)flags; > + > +#if TARGET_LONG_SIZE == 4 > + ret |= flags_ul << 0; > + ret |= flags_ul << 8; > + ret |= flags_ul << 16; > + ret |= flags_ul << 24; > +#elif TARGET_LONG_SIZE == 8 > + ret |= flags_ul << 0; > + ret |= flags_ul << 8; > + ret |= flags_ul << 16; > + ret |= flags_ul << 24; > + ret |= flags_ul << 32; > + ret |= flags_ul << 40; > + ret |= flags_ul << 48; > + ret |= flags_ul << 56; > HOST_LONG_SIZE, not TARGET_LONG_SIZE. > @@ -890,9 +923,50 @@ static inline int cpu_physical_memory_get_dirty(ram_addr_t addr, > > static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) > { > + if (phys_ram_dirty[addr >> TARGET_PAGE_BITS] != 0xff) > + ++phys_ram_dirty_by_word[(addr >> TARGET_PAGE_BITS) / > + TARGET_LONG_BITS]; > + > phys_ram_dirty[addr >> TARGET_PAGE_BITS] = 0xff; > } > Why do you need a counter? It may be sufficient to set a single bit. This reduces the memory overhead and perhaps cache thrashing. -- error compiling committee.c: too many arguments to function