public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] KVM: x86/mmu: Run NX huge page recovery under MMU read lock
@ 2024-08-29 19:11 Vipin Sharma
  2024-08-29 19:11 ` [PATCH v2 1/4] KVM: x86/mmu: Track TDP MMU NX huge pages separately Vipin Sharma
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Vipin Sharma @ 2024-08-29 19:11 UTC (permalink / raw)
  To: seanjc, pbonzini, dmatlack; +Cc: kvm, linux-kernel, Vipin Sharma

Split NX huge page recovery in two separate flows, one for TDP MMU and
one for non-TDP MMU.

TDP MMU flow will use MMU read lock and non-TDP MMU flow will use MMU
write lock. This change unblocks vCPUs which are waiting for MMU read
lock while NX huge page recovery is running and zapping shadow pages.

A Windows guest was showing network latency jitters which was root
caused to vCPUs waiting for MMU read lock when NX huge page recovery
thread was holding MMU write lock. Disabling NX huge page recovery fixed
the jitter issue.

So, to optimize NX huge page recovery, it was modified to run under MMU
read lock, the switch made jitter issue disappear completely and vCPUs
wait time for MMU read lock reduced drastically. Patch 4 commit log has
the data from the tool to show improvement observed.

Patch 1 adds a little bit of code churn which is removed in Patch 2 and
3. It was done to make tracking NX huge pages separately in a separate
patch and then later split common recovery worker code.

v2:
- Track legacy and TDP MMU NX huge pages separately.
- Each list has their own calculation of "to_zap", i.e. number of pages
  to zap.
- Unaccount huge page before dirty log check and zap logic in TDP MMU recovery
  worker. Check patch 4 for more details.
- 32 bit build issue fix.
- Sparse warning fix for comparing RCU pointer with non-RCU pointer.
  (sp->spt == spte_to_child_pt())


v1: https://lore.kernel.org/kvm/20240812171341.1763297-1-vipinsh@google.com/#t

Vipin Sharma (4):
  KVM: x86/mmu: Track TDP MMU NX huge pages separately
  KVM: x86/mmu: Extract out TDP MMU NX huge page recovery code
  KVM: x86/mmu: Rearrange locks and to_zap count for NX huge page
    recovery
  KVM: x86/mmu: Recover TDP MMU NX huge pages using MMU read lock

 arch/x86/include/asm/kvm_host.h |  13 ++-
 arch/x86/kvm/mmu/mmu.c          | 135 +++++++++++++++++---------------
 arch/x86/kvm/mmu/mmu_internal.h |   3 +
 arch/x86/kvm/mmu/tdp_mmu.c      | 122 +++++++++++++++++++++++++++--
 arch/x86/kvm/mmu/tdp_mmu.h      |   3 +-
 5 files changed, 204 insertions(+), 72 deletions(-)


base-commit: 332d2c1d713e232e163386c35a3ba0c1b90df83f
-- 
2.46.0.469.g59c65b2a67-goog


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-09-03 20:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29 19:11 [PATCH v2 0/4] KVM: x86/mmu: Run NX huge page recovery under MMU read lock Vipin Sharma
2024-08-29 19:11 ` [PATCH v2 1/4] KVM: x86/mmu: Track TDP MMU NX huge pages separately Vipin Sharma
2024-08-29 20:18   ` Sean Christopherson
2024-09-03 20:26     ` Vipin Sharma
2024-08-29 19:11 ` [PATCH v2 2/4] KVM: x86/mmu: Extract out TDP MMU NX huge page recovery code Vipin Sharma
2024-08-29 19:11 ` [PATCH v2 3/4] KVM: x86/mmu: Rearrange locks and to_zap count for NX huge page recovery Vipin Sharma
2024-08-29 19:11 ` [PATCH v2 4/4] KVM: x86/mmu: Recover TDP MMU NX huge pages using MMU read lock Vipin Sharma
2024-08-29 20:06   ` Sean Christopherson
2024-09-03 20:23     ` Vipin Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox