KVM/MMU: Move tlb flush in kvm_set_pte_rmapp() to kvm_mmu_notifier_change_pte()

This patch is to move tlb flush in kvm_set_pte_rmapp() to
kvm_mmu_notifier_change_pte() in order to avoid redundant tlb flush.

Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Lan Tianyu 2018-12-06 21:21:11 +08:00 committed by Paolo Bonzini
parent 748c0e312f
commit 0cf853c5e2
2 changed files with 6 additions and 7 deletions

View File

@ -1776,10 +1776,7 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
} }
} }
if (need_flush) return need_flush;
kvm_flush_remote_tlbs(kvm);
return 0;
} }
struct slot_rmap_walk_iterator { struct slot_rmap_walk_iterator {
@ -1915,8 +1912,7 @@ int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte) int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte)
{ {
kvm_handle_hva(kvm, hva, (unsigned long)&pte, kvm_set_pte_rmapp); return kvm_handle_hva(kvm, hva, (unsigned long)&pte, kvm_set_pte_rmapp);
return 0;
} }
static int kvm_age_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head, static int kvm_age_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,

View File

@ -354,7 +354,10 @@ static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn,
idx = srcu_read_lock(&kvm->srcu); idx = srcu_read_lock(&kvm->srcu);
spin_lock(&kvm->mmu_lock); spin_lock(&kvm->mmu_lock);
kvm->mmu_notifier_seq++; kvm->mmu_notifier_seq++;
kvm_set_spte_hva(kvm, address, pte);
if (kvm_set_spte_hva(kvm, address, pte))
kvm_flush_remote_tlbs(kvm);
spin_unlock(&kvm->mmu_lock); spin_unlock(&kvm->mmu_lock);
srcu_read_unlock(&kvm->srcu, idx); srcu_read_unlock(&kvm->srcu, idx);
} }