diff options
author | Luca Tettamanti <kronos.it@gmail.com> | 2007-06-19 22:41:38 +0200 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-07-16 12:05:48 +0300 |
commit | a3c870bdce4d34332ebdba7eb9969592c4c6b243 (patch) | |
tree | ea0d54e333f133a6e96a56356c5e516fc79e5580 /drivers/kvm | |
parent | 02c03a326a5df825cc01de426f72e160db2b9538 (diff) | |
download | linux-3.10-a3c870bdce4d34332ebdba7eb9969592c4c6b243.tar.gz linux-3.10-a3c870bdce4d34332ebdba7eb9969592c4c6b243.tar.bz2 linux-3.10-a3c870bdce4d34332ebdba7eb9969592c4c6b243.zip |
KVM: Avoid useless memory write when possible
When writing to normal memory and the memory area is unchanged the write
can be safely skipped, avoiding the costly kvm_mmu_pte_write.
Signed-Off-By: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r-- | drivers/kvm/kvm_main.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 7826f16271e..5603000573e 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -1170,8 +1170,10 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, return 0; mark_page_dirty(vcpu->kvm, gpa >> PAGE_SHIFT); virt = kmap_atomic(page, KM_USER0); - kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes); - memcpy(virt + offset_in_page(gpa), val, bytes); + if (memcmp(virt + offset_in_page(gpa), val, bytes)) { + kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes); + memcpy(virt + offset_in_page(gpa), val, bytes); + } kunmap_atomic(virt, KM_USER0); return 1; } |