From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH 2/4] KVM: Flush TLB in mmu notifier without holding mmu_lock Date: Thu, 3 May 2012 14:23:00 +0300 Message-ID: <1336044182-12023-3-git-send-email-avi@redhat.com> References: <1336044182-12023-1-git-send-email-avi@redhat.com> To: kvm@vger.kernel.org, Marcelo Tosatti , Xiao Guangrong , takuya.yoshikawa@gmail.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:44542 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751144Ab2ECLXN (ORCPT ); Thu, 3 May 2012 07:23:13 -0400 In-Reply-To: <1336044182-12023-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Avi Kivity --- virt/kvm/kvm_main.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 643ce01..9e2db44 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -302,11 +302,11 @@ static void kvm_mmu_notifier_invalidate_page(struct mmu_notifier *mn, kvm->mmu_notifier_seq++; if (kvm_unmap_hva(kvm, address)) kvm_mark_tlb_dirty(kvm); - /* we've to flush the tlb before the pages can be freed */ - kvm_cond_flush_remote_tlbs(kvm); - spin_unlock(&kvm->mmu_lock); srcu_read_unlock(&kvm->srcu, idx); + + /* we've to flush the tlb before the pages can be freed */ + kvm_cond_flush_remote_tlbs(kvm); } static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn, @@ -347,11 +347,11 @@ static void kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, if (need_tlb_flush) kvm_mark_tlb_dirty(kvm); - /* we've to flush the tlb before the pages can be freed */ - kvm_cond_flush_remote_tlbs(kvm); - spin_unlock(&kvm->mmu_lock); srcu_read_unlock(&kvm->srcu, idx); + + /* we've to flush the tlb before the pages can be freed */ + kvm_cond_flush_remote_tlbs(kvm); } static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn, @@ -392,11 +392,13 @@ static int kvm_mmu_notifier_clear_flush_young(struct mmu_notifier *mn, young = kvm_age_hva(kvm, address); if (young) - kvm_flush_remote_tlbs(kvm); + kvm_mark_tlb_dirty(kvm); spin_unlock(&kvm->mmu_lock); srcu_read_unlock(&kvm->srcu, idx); + kvm_cond_flush_remote_tlbs(kvm); + return young; } -- 1.7.10