From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH v2 3/5] KVM: Flush TLB in mmu notifier without holding mmu_lock Date: Thu, 17 May 2012 13:24:42 +0300 Message-ID: <1337250284-18607-3-git-send-email-avi@redhat.com> References: <1337250284-18607-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , Xiao Guangrong , Takuya Yoshikawa , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:30173 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761467Ab2EQKYx (ORCPT ); Thu, 17 May 2012 06:24:53 -0400 In-Reply-To: <1337250284-18607-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, 8 insertions(+), 8 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 585ab45..9f6d15d 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, @@ -394,11 +394,11 @@ static int kvm_mmu_notifier_clear_flush_young(struct mmu_notifier *mn, if (young) kvm_mark_tlb_dirty(kvm); - kvm_cond_flush_remote_tlbs(kvm); - spin_unlock(&kvm->mmu_lock); srcu_read_unlock(&kvm->srcu, idx); + kvm_cond_flush_remote_tlbs(kvm); + return young; } -- 1.7.10.1