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>
This commit is contained in:
parent
4eb64dce8d
commit
251eb84144
1 changed files with 4 additions and 2 deletions
|
@ -1590,15 +1590,17 @@ int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data,
|
||||||
int offset, int len)
|
int offset, int len)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
struct kvm_memory_slot *memslot;
|
||||||
unsigned long addr;
|
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))
|
if (kvm_is_error_hva(addr))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
r = __copy_to_user((void __user *)addr + offset, data, len);
|
r = __copy_to_user((void __user *)addr + offset, data, len);
|
||||||
if (r)
|
if (r)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
mark_page_dirty(kvm, gfn);
|
mark_page_dirty_in_slot(kvm, memslot, gfn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(kvm_write_guest_page);
|
EXPORT_SYMBOL_GPL(kvm_write_guest_page);
|
||||||
|
|
Loading…
Reference in a new issue