Rework the TDP MMU eager page splitting code to always drop mmu_lock when allocation shadow pages, to avoid causing lock contention with vCPU threads during CLEAR_DIRTY_LOG (where mmu_lock is held for write). The first patch changes KVM to always drop mmu_lock lock and the subsequent patches clean up and simplify the code now that conditional locking is gone. v4: - Use kmem_cache_zalloc() instead of __GFP_ZERO [Sean] - Move mmu_lock and RCU acquire/release into the loop [Sean] - Avoid unnecessary reaquire of RCU read lock [Sean] v3: https://lore.kernel.org/kvm/20240509181133.837001-1-dmatlack@xxxxxxxxxx/ - Only drop mmu_lock during TDP MMU eager page splitting. This fixes the performance regression without regressing CLEAR_DIRTY_LOG performance on other architectures from frequent lock dropping. v2: https://lore.kernel.org/kvm/20240402213656.3068504-1-dmatlack@xxxxxxxxxx/ - Rebase onto kvm/queue [Marc] v1: https://lore.kernel.org/kvm/20231205181645.482037-1-dmatlack@xxxxxxxxxx/ Cc: Bibo Mao <maobibo@xxxxxxxxxxx> Cc: Sean Christopherson <seanjc@xxxxxxxxxx> David Matlack (4): KVM: x86/mmu: Always drop mmu_lock to allocate TDP MMU SPs for eager splitting KVM: x86/mmu: Hard code GFP flags for TDP MMU eager split allocations KVM: x86/mmu: Unnest TDP MMU helpers to allocate SPs for eager splitting KVM: x86/mmu: Avoid reacquiring RCU if TDP MMU fails to allocate an SP arch/x86/kvm/mmu/tdp_mmu.c | 78 ++++++++++++-------------------------- 1 file changed, 24 insertions(+), 54 deletions(-) base-commit: af0903ab52ee6d6f0f63af67fa73d5eb00f79b9a -- 2.45.2.505.gda0bf45e8d-goog