mbox series

[v4,0/4] KVM: x86/mmu: Rework TDP MMU eager page splitting SP allocations

Message ID 20240611220512.2426439-1-dmatlack@google.com (mailing list archive)
Headers show
Series KVM: x86/mmu: Rework TDP MMU eager page splitting SP allocations | expand

Message

David Matlack June 11, 2024, 10:05 p.m. UTC
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@google.com/
 - 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@google.com/
 - Rebase onto kvm/queue [Marc]

v1: https://lore.kernel.org/kvm/20231205181645.482037-1-dmatlack@google.com/

Cc: Bibo Mao <maobibo@loongson.cn>
Cc: Sean Christopherson <seanjc@google.com>

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

Comments

Sean Christopherson June 15, 2024, 12:02 a.m. UTC | #1
On Tue, 11 Jun 2024 15:05:08 -0700, David Matlack wrote:
> 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.
> 
> [...]

Applied to kvm-x86 mmu, thanks!

[1/4] KVM: x86/mmu: Always drop mmu_lock to allocate TDP MMU SPs for eager splitting
      https://github.com/kvm-x86/linux/commit/cf3ff0ee24d6
[2/4] KVM: x86/mmu: Hard code GFP flags for TDP MMU eager split allocations
      https://github.com/kvm-x86/linux/commit/e1c04f7a9f42
[3/4] KVM: x86/mmu: Unnest TDP MMU helpers to allocate SPs for eager splitting
      https://github.com/kvm-x86/linux/commit/3d4a5a45ca26
[4/4] KVM: x86/mmu: Avoid reacquiring RCU if TDP MMU fails to allocate an SP
      https://github.com/kvm-x86/linux/commit/0089c055b560

--
https://github.com/kvm-x86/linux/tree/next