Re: [PATCH v2 23/28] KVM: x86/mmu: Allow parallel page faults for the TDP MMU

From: Paolo Bonzini
Date: Wed Feb 03 2021 - 07:41:53 EST


On 02/02/21 19:57, Ben Gardon wrote:

- write_lock(&vcpu->kvm->mmu_lock);
+
+ if (is_tdp_mmu_root(vcpu->kvm, vcpu->arch.mmu->root_hpa))
+ read_lock(&vcpu->kvm->mmu_lock);
+ else
+ write_lock(&vcpu->kvm->mmu_lock);
+

I'd like to make this into two helper functions, but I'm not sure about the naming:

- kvm_mmu_read_lock_for_root/kvm_mmu_read_unlock_for_root: not precise because it's really write-locked for shadow MMU roots

- kvm_mmu_lock_for_root/kvm_mmu_unlock_for_root: not clear that TDP MMU operations will need to operate in shared-lock mode

I prefer the first because at least it's the conservative option, but I'm open to other opinions and suggestions.

Paolo