All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
@ 2012-04-02  4:04 David Gibson
  2012-04-02  4:14 ` Benjamin Herrenschmidt
  2012-04-03  7:08 ` Jan Kiszka
  0 siblings, 2 replies; 13+ messages in thread
From: David Gibson @ 2012-04-02  4:04 UTC (permalink / raw)
  To: avi, mtosatti; +Cc: aliguori, David Gibson, qemu-devel, Avi Kivity

From: Ben Herrenschmidt <benh@kernel.crashing.org>

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.

Cc: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 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);
         }
     }
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-04-02  4:04 [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size David Gibson
@ 2012-04-02  4:14 ` Benjamin Herrenschmidt
  2012-04-03  7:08 ` Jan Kiszka
  1 sibling, 0 replies; 13+ messages in thread
From: Benjamin Herrenschmidt @ 2012-04-02  4:14 UTC (permalink / raw)
  To: David Gibson; +Cc: Avi Kivity, aliguori, mtosatti, qemu-devel, avi

On Mon, 2012-04-02 at 14:04 +1000, David Gibson wrote:
> From: Ben Herrenschmidt <benh@kernel.crashing.org>
> 
> 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 <avi@redhat.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  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);
>          }
>      }

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-04-02  4:04 [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size David Gibson
  2012-04-02  4:14 ` Benjamin Herrenschmidt
@ 2012-04-03  7:08 ` Jan Kiszka
  2012-04-04  1:12   ` David Gibson
  1 sibling, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:08 UTC (permalink / raw)
  To: David Gibson; +Cc: aliguori, mtosatti, qemu-devel, Avi Kivity

[-- Attachment #1: Type: text/plain, Size: 2295 bytes --]

On 2012-04-02 06:04, David Gibson wrote:
> From: Ben Herrenschmidt <benh@kernel.crashing.org>
> 
> 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.
> 
> Cc: Avi Kivity <avi@redhat.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  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);
>          }
>      }

Ack for this, but - as proposed earlier - please add an
assert(TARGET_PAGE_SIZE <= getpagesize()) + comment to kvm_init().

Also, what's about coalesced MMIO? I see that the ring definition
depends on [TARGET_]PAGE_SIZE. What page size does the power kernel use
for it, and does it make a relevant difference for space?

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-04-03  7:08 ` Jan Kiszka
@ 2012-04-04  1:12   ` David Gibson
  2012-04-04 10:58     ` Jan Kiszka
  0 siblings, 1 reply; 13+ messages in thread
From: David Gibson @ 2012-04-04  1:12 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: aliguori, mtosatti, qemu-devel, Avi Kivity

[-- Attachment #1: Type: text/plain, Size: 2882 bytes --]

On Tue, Apr 03, 2012 at 09:08:16AM +0200, Jan Kiszka wrote:
> On 2012-04-02 06:04, David Gibson wrote:
> > From: Ben Herrenschmidt <benh@kernel.crashing.org>
> > 
> > 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.
> > 
> > Cc: Avi Kivity <avi@redhat.com>
> > Cc: Marcelo Tosatti <mtosatti@redhat.com>
> > 
> > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> >  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);
> >          }
> >      }
> 
> Ack for this, but - as proposed earlier - please add an
> assert(TARGET_PAGE_SIZE <= getpagesize()) + comment to kvm_init().

Ok.

> Also, what's about coalesced MMIO? I see that the ring definition
> depends on [TARGET_]PAGE_SIZE. What page size does the power kernel use
> for it, and does it make a relevant difference for space?

Hr, so the HV variant of Power KVM doesn't do coalesced mmio.  The PR
variant does, but I don't know enough about it to easily answer that.
If there's a bug there, it hasn't bitten yet, so how about we fix that
another day.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-04-04  1:12   ` David Gibson
@ 2012-04-04 10:58     ` Jan Kiszka
  2012-04-04 14:24       ` David Gibson
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2012-04-04 10:58 UTC (permalink / raw)
  To: mtosatti, aliguori, qemu-devel, Avi Kivity

On 2012-04-04 03:12, David Gibson wrote:
>> Also, what's about coalesced MMIO? I see that the ring definition
>> depends on [TARGET_]PAGE_SIZE. What page size does the power kernel use
>> for it, and does it make a relevant difference for space?
> 
> Hr, so the HV variant of Power KVM doesn't do coalesced mmio.  The PR
> variant does, but I don't know enough about it to easily answer that.
> If there's a bug there, it hasn't bitten yet, so how about we fix that
> another day.

Not really a smart approach, specifically now that we are aware of a
potential problem here.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-04-04 10:58     ` Jan Kiszka
@ 2012-04-04 14:24       ` David Gibson
  2012-04-05  7:32         ` Jan Kiszka
  0 siblings, 1 reply; 13+ messages in thread
From: David Gibson @ 2012-04-04 14:24 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: aliguori, mtosatti, qemu-devel, Avi Kivity

On Wed, Apr 04, 2012 at 12:58:37PM +0200, Jan Kiszka wrote:
> On 2012-04-04 03:12, David Gibson wrote:
> >> Also, what's about coalesced MMIO? I see that the ring definition
> >> depends on [TARGET_]PAGE_SIZE. What page size does the power kernel use
> >> for it, and does it make a relevant difference for space?
> > 
> > Hr, so the HV variant of Power KVM doesn't do coalesced mmio.  The PR
> > variant does, but I don't know enough about it to easily answer that.
> > If there's a bug there, it hasn't bitten yet, so how about we fix that
> > another day.
> 
> Not really a smart approach, specifically now that we are aware of a
> potential problem here.

My point is that the fact that there may be another bug out there
should sure as hell not hold up putting this bug fix in.  The bugs may
have similar causes and solutions, but they're entirely different code
paths and the other fix will in no way replace or subsume this one.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-04-04 14:24       ` David Gibson
@ 2012-04-05  7:32         ` Jan Kiszka
  0 siblings, 0 replies; 13+ messages in thread
From: Jan Kiszka @ 2012-04-05  7:32 UTC (permalink / raw)
  To: mtosatti, aliguori, qemu-devel, Avi Kivity

On 2012-04-04 16:24, David Gibson wrote:
> On Wed, Apr 04, 2012 at 12:58:37PM +0200, Jan Kiszka wrote:
>> On 2012-04-04 03:12, David Gibson wrote:
>>>> Also, what's about coalesced MMIO? I see that the ring definition
>>>> depends on [TARGET_]PAGE_SIZE. What page size does the power kernel use
>>>> for it, and does it make a relevant difference for space?
>>>
>>> Hr, so the HV variant of Power KVM doesn't do coalesced mmio.  The PR
>>> variant does, but I don't know enough about it to easily answer that.
>>> If there's a bug there, it hasn't bitten yet, so how about we fix that
>>> another day.
>>
>> Not really a smart approach, specifically now that we are aware of a
>> potential problem here.
> 
> My point is that the fact that there may be another bug out there
> should sure as hell not hold up putting this bug fix in.  The bugs may
> have similar causes and solutions, but they're entirely different code
> paths and the other fix will in no way replace or subsume this one.

I don't disagree. Maybe I over-interpreted your reply as "let's wait if
this actually bites us".

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-05-10 10:49       ` Jan Kiszka
@ 2012-05-10 10:55         ` Avi Kivity
  0 siblings, 0 replies; 13+ messages in thread
From: Avi Kivity @ 2012-05-10 10:55 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: aliguori, mtosatti, qemu-devel, Anthony Liguori, David Gibson

On 05/10/2012 01:49 PM, Jan Kiszka wrote:
> On 2012-05-10 06:27, Avi Kivity wrote:
> > On 05/10/2012 01:23 AM, Anthony Liguori wrote:
> >> On 04/04/2012 03:41 AM, Avi Kivity wrote:
> >>> On 04/04/2012 04:15 AM, David Gibson wrote:
> >>>> 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.
> >>>>
> >>>> Cc: Avi Kivity<avi@redhat.com>
> >>>> Cc: Marcelo Tosatti<mtosatti@redhat.com>
> >>>>
> >>>
> >>> Thanks, applied to uq/master.
> >>
> >> Can ya'll send a PULL request for 1.1 with any bug fixes from uq/master?
> > 
> > Sure, I'll trawl the list for missed patches (Jan, any known?) and let
> > autotest at it.
>
> Don't recall any ATM for which there wasn't a "thanks, applied".
>

Okay, so we have that one patch.  Since it's a nop for x86, which is the
only thing I test, I'll push it along.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-05-10  9:27     ` Avi Kivity
@ 2012-05-10 10:49       ` Jan Kiszka
  2012-05-10 10:55         ` Avi Kivity
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2012-05-10 10:49 UTC (permalink / raw)
  To: Avi Kivity; +Cc: aliguori, mtosatti, qemu-devel, Anthony Liguori, David Gibson

[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

On 2012-05-10 06:27, Avi Kivity wrote:
> On 05/10/2012 01:23 AM, Anthony Liguori wrote:
>> On 04/04/2012 03:41 AM, Avi Kivity wrote:
>>> On 04/04/2012 04:15 AM, David Gibson wrote:
>>>> 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.
>>>>
>>>> Cc: Avi Kivity<avi@redhat.com>
>>>> Cc: Marcelo Tosatti<mtosatti@redhat.com>
>>>>
>>>
>>> Thanks, applied to uq/master.
>>
>> Can ya'll send a PULL request for 1.1 with any bug fixes from uq/master?
> 
> Sure, I'll trawl the list for missed patches (Jan, any known?) and let
> autotest at it.

Don't recall any ATM for which there wasn't a "thanks, applied".

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-05-09 22:23   ` Anthony Liguori
@ 2012-05-10  9:27     ` Avi Kivity
  2012-05-10 10:49       ` Jan Kiszka
  0 siblings, 1 reply; 13+ messages in thread
From: Avi Kivity @ 2012-05-10  9:27 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: aliguori, mtosatti, jan.kiszka, qemu-devel, David Gibson

On 05/10/2012 01:23 AM, Anthony Liguori wrote:
> On 04/04/2012 03:41 AM, Avi Kivity wrote:
>> On 04/04/2012 04:15 AM, David Gibson wrote:
>>> 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.
>>>
>>> Cc: Avi Kivity<avi@redhat.com>
>>> Cc: Marcelo Tosatti<mtosatti@redhat.com>
>>>
>>
>> Thanks, applied to uq/master.
>
> Can ya'll send a PULL request for 1.1 with any bug fixes from uq/master?

Sure, I'll trawl the list for missed patches (Jan, any known?) and let
autotest at it.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-04-04  8:41 ` Avi Kivity
@ 2012-05-09 22:23   ` Anthony Liguori
  2012-05-10  9:27     ` Avi Kivity
  0 siblings, 1 reply; 13+ messages in thread
From: Anthony Liguori @ 2012-05-09 22:23 UTC (permalink / raw)
  To: Avi Kivity; +Cc: aliguori, mtosatti, jan.kiszka, qemu-devel, David Gibson

On 04/04/2012 03:41 AM, Avi Kivity wrote:
> On 04/04/2012 04:15 AM, David Gibson wrote:
>> 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.
>>
>> Cc: Avi Kivity<avi@redhat.com>
>> Cc: Marcelo Tosatti<mtosatti@redhat.com>
>>
>
> Thanks, applied to uq/master.

Can ya'll send a PULL request for 1.1 with any bug fixes from uq/master?

Thanks,

Anthony Liguori

>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
  2012-04-04  1:15 David Gibson
@ 2012-04-04  8:41 ` Avi Kivity
  2012-05-09 22:23   ` Anthony Liguori
  0 siblings, 1 reply; 13+ messages in thread
From: Avi Kivity @ 2012-04-04  8:41 UTC (permalink / raw)
  To: David Gibson; +Cc: aliguori, mtosatti, jan.kiszka, qemu-devel

On 04/04/2012 04:15 AM, David Gibson wrote:
> 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.
>
> Cc: Avi Kivity <avi@redhat.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
>

Thanks, applied to uq/master.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size
@ 2012-04-04  1:15 David Gibson
  2012-04-04  8:41 ` Avi Kivity
  0 siblings, 1 reply; 13+ messages in thread
From: David Gibson @ 2012-04-04  1:15 UTC (permalink / raw)
  To: avi, mtosatti; +Cc: aliguori, jan.kiszka, qemu-devel, David Gibson

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.

Cc: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 kvm-all.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

Please apply.

Changes since last post:
 * Added assertion and comment in kvm_init() as requested by Jan Kiszka

diff --git a/kvm-all.c b/kvm-all.c
index ba2cee1..1f49d0a 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);
         }
     }
@@ -986,6 +988,14 @@ int kvm_init(void)
 
     s = g_malloc0(sizeof(KVMState));
 
+    /*
+     * On systems where the kernel can support different base page
+     * sizes, host page size may be different from TARGET_PAGE_SIZE,
+     * even with KVM.  TARGET_PAGE_SIZE is assumed to be the minimum
+     * page size for the system though.
+     */
+    assert(TARGET_PAGE_SIZE <= getpagesize());
+
 #ifdef KVM_CAP_SET_GUEST_DEBUG
     QTAILQ_INIT(&s->kvm_sw_breakpoints);
 #endif
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-05-10 10:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-02  4:04 [Qemu-devel] [PATCH, RESEND] kvm: Fix dirty tracking with large kernel page size David Gibson
2012-04-02  4:14 ` Benjamin Herrenschmidt
2012-04-03  7:08 ` Jan Kiszka
2012-04-04  1:12   ` David Gibson
2012-04-04 10:58     ` Jan Kiszka
2012-04-04 14:24       ` David Gibson
2012-04-05  7:32         ` Jan Kiszka
2012-04-04  1:15 David Gibson
2012-04-04  8:41 ` Avi Kivity
2012-05-09 22:23   ` Anthony Liguori
2012-05-10  9:27     ` Avi Kivity
2012-05-10 10:49       ` Jan Kiszka
2012-05-10 10:55         ` Avi Kivity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.