[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e87d4a5d-f6ac-677a-87aa-0c30977c92f1@redhat.com>
Date: Wed, 3 Feb 2021 12:34:24 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Ben Gardon <bgardon@...gle.com>, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
Cc: Peter Xu <peterx@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Peter Shier <pshier@...gle.com>,
Peter Feiner <pfeiner@...gle.com>,
Junaid Shahid <junaids@...gle.com>,
Jim Mattson <jmattson@...gle.com>,
Yulei Zhang <yulei.kernel@...il.com>,
Wanpeng Li <kernellwp@...il.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Xiao Guangrong <xiaoguangrong.eric@...il.com>
Subject: Re: [PATCH v2 25/28] KVM: x86/mmu: Allow zapping collapsible SPTEs to
use MMU read lock
On 02/02/21 19:57, Ben Gardon wrote:
> @@ -1485,7 +1489,9 @@ void kvm_tdp_mmu_zap_collapsible_sptes(struct kvm *kvm,
> struct kvm_mmu_page *root;
> int root_as_id;
>
> - for_each_tdp_mmu_root_yield_safe(kvm, root, false) {
> + read_lock(&kvm->mmu_lock);
> +
> + for_each_tdp_mmu_root_yield_safe(kvm, root, true) {
> root_as_id = kvm_mmu_page_as_id(root);
> if (root_as_id != slot->as_id)
> continue;
> @@ -1493,6 +1499,8 @@ void kvm_tdp_mmu_zap_collapsible_sptes(struct kvm *kvm,
> zap_collapsible_spte_range(kvm, root, slot->base_gfn,
> slot->base_gfn + slot->npages);
> }
> +
> + read_unlock(&kvm->mmu_lock);
> }
I'd prefer the functions to be consistent about who takes the lock,
either mmu.c or tdp_mmu.c. Since everywhere else you're doing it in
mmu.c, that would be:
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 0554d9c5c5d4..386ee4b703d9 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -5567,10 +5567,13 @@ void kvm_mmu_zap_collapsible_sptes(struct kvm *kvm,
write_lock(&kvm->mmu_lock);
slot_handle_leaf(kvm, (struct kvm_memory_slot *)memslot,
kvm_mmu_zap_collapsible_spte, true);
+ write_unlock(&kvm->mmu_lock);
- if (kvm->arch.tdp_mmu_enabled)
+ if (kvm->arch.tdp_mmu_enabled) {
+ read_lock(&kvm->mmu_lock);
kvm_tdp_mmu_zap_collapsible_sptes(kvm, memslot);
- write_unlock(&kvm->mmu_lock);
+ read_unlock(&kvm->mmu_lock);
+ }
}
void kvm_arch_flush_remote_tlbs_memslot(struct kvm *kvm,
and just lockdep_assert_held_read here.
> - tdp_mmu_set_spte(kvm, &iter, 0);
> -
> - spte_set = true;
Is it correct to remove this assignment?
Paolo
Powered by blists - more mailing lists