提交 5d6317ca 编写于 作者: S Sean Christopherson 提交者: Paolo Bonzini

KVM: x86/mmu: Voluntarily reschedule as needed when zapping all sptes

Call cond_resched_lock() when zapping all sptes to reschedule if needed
or to release and reacquire mmu_lock in case of contention.  There is no
need to flush or zap when temporarily dropping mmu_lock as zapping all
sptes is done only when the owning userspace VMM has exited or when the
VM is being destroyed, i.e. there is no interplay with memslots or MMIO
generations to worry about.

Be paranoid and restart the walk if mmu_lock is dropped to avoid any
potential issues with consuming a stale iterator.  The overhead in doing
so is negligible as at worst there will be a few root shadow pages at
the head of the list, i.e. the iterator is essentially the head of the
list already.
Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 8a674adc
...@@ -5856,7 +5856,8 @@ void kvm_mmu_zap_all(struct kvm *kvm) ...@@ -5856,7 +5856,8 @@ void kvm_mmu_zap_all(struct kvm *kvm)
list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link) { list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link) {
if (sp->role.invalid && sp->root_count) if (sp->role.invalid && sp->root_count)
continue; continue;
if (kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list)) if (kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list) ||
cond_resched_lock(&kvm->mmu_lock))
goto restart; goto restart;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册