aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>2011-11-14 04:23:34 -0500
committerAvi Kivity <avi@redhat.com>2011-12-27 04:17:19 -0500
commit7850ac5420803996e2960d15b924021f28e0dffc (patch)
treedc4ed43a8e5ffcfbf45b48c8d78228ffe9762efa /virt/kvm
parent9b9b1492364758de82c19c36f07baa9ae162c7e5 (diff)
KVM: Count the number of dirty pages for dirty logging
Needed for the next patch which uses this number to decide how to write protect a slot. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/kvm_main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 4c5b9a23967..af5c988cafc 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -625,6 +625,7 @@ static int kvm_create_dirty_bitmap(struct kvm_memory_slot *memslot)
625 return -ENOMEM; 625 return -ENOMEM;
626 626
627 memslot->dirty_bitmap_head = memslot->dirty_bitmap; 627 memslot->dirty_bitmap_head = memslot->dirty_bitmap;
628 memslot->nr_dirty_pages = 0;
628 return 0; 629 return 0;
629} 630}
630#endif /* !CONFIG_S390 */ 631#endif /* !CONFIG_S390 */
@@ -1491,7 +1492,8 @@ void mark_page_dirty_in_slot(struct kvm *kvm, struct kvm_memory_slot *memslot,
1491 if (memslot && memslot->dirty_bitmap) { 1492 if (memslot && memslot->dirty_bitmap) {
1492 unsigned long rel_gfn = gfn - memslot->base_gfn; 1493 unsigned long rel_gfn = gfn - memslot->base_gfn;
1493 1494
1494 __set_bit_le(rel_gfn, memslot->dirty_bitmap); 1495 if (!__test_and_set_bit_le(rel_gfn, memslot->dirty_bitmap))
1496 memslot->nr_dirty_pages++;
1495 } 1497 }
1496} 1498}
1497 1499