Received: from eggs.gnu.org ([208.118.235.92]:38426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEYf6-00011u-6n for qemu-devel@nongnu.org; Mon, 02 Apr 2012 00:14:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEYf4-0006y4-6y for qemu-devel@nongnu.org; Mon, 02 Apr 2012 00:14:35 -0400 Received: from gate.crashing.org ([63.228.1.57]:50584) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEYf3-0006xy-UE for qemu-devel@nongnu.org; Mon, 02 Apr 2012 00:14:34 -0400 Message-ID: <1333340061.30734.39.camel@pasglop> From: Benjamin Herrenschmidt Date: Mon, 02 Apr 2012 14:14:21 +1000 In-Reply-To: <1333339457-13854-1-git-send-email-david@gibson.dropbear.id.au> References: <1333339457-13854-1-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: Avi Kivity , aliguori@us.ibm.com, mtosatti@redhat.com, qemu-devel@nongnu.org, avi@readhat.com On Mon, 2012-04-02 at 14:04 +1000, David Gibson wrote: > From: Ben Herrenschmidt > > If the kernel page size is larger than TARGET_PAGE_SIZE, which > happens for example on ppc64 with kernels compiled for 64K pages, > the dirty tracking doesn't work. BTW. That was discussed ages back on the list and we basically agreed it was the right fix for now, but for some reason the patch then went into a black hole :-) Cheers, Ben. > Cc: Avi Kivity > Cc: Marcelo Tosatti > > Signed-off-by: Benjamin Herrenschmidt > Signed-off-by: David Gibson > --- > kvm-all.c | 6 ++++-- > 1 files changed, 4 insertions(+), 2 deletions(-) > > I've sent this a number of times now, the last couple without comment. > It fixes a real bug, please apply. > > diff --git a/kvm-all.c b/kvm-all.c > index ba2cee1..7e44429 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -354,6 +354,7 @@ static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, > unsigned long page_number, c; > target_phys_addr_t addr, addr1; > unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS; > + unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE; > > /* > * bitmap-traveling is faster than memory-traveling (for addr...) > @@ -365,10 +366,11 @@ static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, > do { > j = ffsl(c) - 1; > c &= ~(1ul << j); > - page_number = i * HOST_LONG_BITS + j; > + page_number = (i * HOST_LONG_BITS + j) * hpratio; > addr1 = page_number * TARGET_PAGE_SIZE; > addr = section->offset_within_region + addr1; > - memory_region_set_dirty(section->mr, addr, TARGET_PAGE_SIZE); > + memory_region_set_dirty(section->mr, addr, > + TARGET_PAGE_SIZE * hpratio); > } while (c != 0); > } > }