Skip to contentSkip to conversation

kvm: Fix dirty tracking with large kernel page size

PATCH RESEND Applied David Gibson 4 participants 6 messages Apr 4, 2012 – May 10, 2012

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 kvm: Fix dirty tracking with large kernel page size

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 <[email protected]>
Cc Marcelo Tosatti <[email protected]>
---
 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

kvm-all.c +12 -2
index ba2cee1..1f49d0a 100644
@@ -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
Signature · 1 line
1.7.9.1
Applied
#1 lore raw
Quoted 7 lines · 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 <[email protected]>
Cc Marcelo Tosatti <[email protected]>

Thanks, applied to uq/master.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#2 lore raw
Quoted 10 lines · Avi Kivity
Quoted 7 lines · 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<[email protected]>
Cc Marcelo Tosatti<[email protected]>

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

Quoted 1 line
#3 lore raw
Quoted 6 lines · Anthony Liguori
Quoted 5 lines · Avi Kivity
Quoted 4 lines · 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.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Cc Avi Kivity<[email protected]>
Cc Marcelo Tosatti<[email protected]>

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.

Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw
Quoted 11 lines · Avi Kivity
Quoted 10 lines · Anthony Liguori
Quoted 9 lines · Avi Kivity
Quoted 7 lines · 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<[email protected]>
Cc Marcelo Tosatti<[email protected]>
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

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

#5 lore raw
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Avi Kivity
Quoted 10 lines · Anthony Liguori
Quoted 9 lines · Avi Kivity
Quoted 7 lines · 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<[email protected]>
Cc Marcelo Tosatti<[email protected]>
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

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.

Signature · 1 line
error compiling committee.c: too many arguments to function