KVM: x86/mmu: Free TDP MMU roots while holding mmy_lock for read
authorSean Christopherson <seanjc@google.com>
Thu, 11 Jan 2024 02:00:48 +0000 (18:00 -0800)
committerSean Christopherson <seanjc@google.com>
Fri, 23 Feb 2024 00:28:45 +0000 (16:28 -0800)
commit576a15de8d299d9d225b86504547ff6498bc2eeb
tree206a3f4d6a4de75c1d8ccc7eb1dfadd28efd9c7f
parentdab285e4ec736d964cfa6c7fd6eebd22666b5ebc
KVM: x86/mmu: Free TDP MMU roots while holding mmy_lock for read

Free TDP MMU roots from vCPU context while holding mmu_lock for read, it
is completely legal to invoke kvm_tdp_mmu_put_root() as a reader.  This
eliminates the last mmu_lock writer in the TDP MMU's "fast zap" path
after requesting vCPUs to reload roots, i.e. allows KVM to zap invalidated
roots, free obsolete roots, and allocate new roots in parallel.

On large VMs, e.g. 100+ vCPUs, allowing the bulk of the "fast zap"
operation to run in parallel with freeing and allocating roots reduces the
worst case latency for a vCPU to reload a root from 2-3ms to <100us.

Link: https://lore.kernel.org/r/20240111020048.844847-9-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/mmu.c