diff options
author | Radim Krčmář <rkrcmar@redhat.com> | 2015-04-10 21:47:27 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-05-08 10:51:38 +0200 |
commit | 251eb84144ec7aba5e344fb8553c67e749655aef (patch) | |
tree | 7bdf7614318665a65267d274cae7fbf3205b5263 /virt/kvm | |
parent | 4eb64dce8d0a3ceccc0036383e4683b7c3ea7a50 (diff) | |
download | op-kernel-dev-251eb84144ec7aba5e344fb8553c67e749655aef.zip op-kernel-dev-251eb84144ec7aba5e344fb8553c67e749655aef.tar.gz |
KVM: reuse memslot in kvm_write_guest_page
Caching memslot value and using mark_page_dirty_in_slot() avoids another
O(log N) search when dirtying the page.
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Message-Id: <1428695247-27603-1-git-send-email-rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r-- | virt/kvm/kvm_main.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 9097741..b6d4151 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1590,15 +1590,17 @@ int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data, int offset, int len) { int r; + struct kvm_memory_slot *memslot; unsigned long addr; - addr = gfn_to_hva(kvm, gfn); + memslot = gfn_to_memslot(kvm, gfn); + addr = gfn_to_hva_memslot(memslot, gfn); if (kvm_is_error_hva(addr)) return -EFAULT; r = __copy_to_user((void __user *)addr + offset, data, len); if (r) return -EFAULT; - mark_page_dirty(kvm, gfn); + mark_page_dirty_in_slot(kvm, memslot, gfn); return 0; } EXPORT_SYMBOL_GPL(kvm_write_guest_page); |