Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: Eliminate extra function calls in kvm_get_dirty_log_protect()

When all bits in mask are not set,
kvm_arch_mmu_enable_log_dirty_pt_masked() has nothing to do. But since
it needs to be called from the generic code, it cannot be inlined, and
a few function calls, two when PML is enabled, are wasted.

Since it is common to see many pages remain clean, e.g. framebuffers can
stay calm for a long time, it is worth eliminating this overhead.

Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

authored by

Takuya Yoshikawa and committed by
Marcelo Tosatti
58d2930f faac2458

+5 -3
+5 -3
virt/kvm/kvm_main.c
··· 1053 1053 mask = xchg(&dirty_bitmap[i], 0); 1054 1054 dirty_bitmap_buffer[i] = mask; 1055 1055 1056 - offset = i * BITS_PER_LONG; 1057 - kvm_arch_mmu_enable_log_dirty_pt_masked(kvm, memslot, offset, 1058 - mask); 1056 + if (mask) { 1057 + offset = i * BITS_PER_LONG; 1058 + kvm_arch_mmu_enable_log_dirty_pt_masked(kvm, memslot, 1059 + offset, mask); 1060 + } 1059 1061 } 1060 1062 1061 1063 spin_unlock(&kvm->mmu_lock);