public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Introduce configuration for LRU cache of previous CR3s
@ 2024-10-29  3:13 Yong He
  2024-10-29  3:13 ` [PATCH 1/2] KVM: x86: expand the " Yong He
  2024-10-29  3:14 ` [PATCH 2/2] KVM: x86: introduce cache configurations for " Yong He
  0 siblings, 2 replies; 8+ messages in thread
From: Yong He @ 2024-10-29  3:13 UTC (permalink / raw)
  To: pbonzini, seanjc, kvm; +Cc: wanpengli, alexyonghe, junaids

From: Yong He <alexyonghe@tencent.com>

When running function loading inside VM without EPT supported,
we found shadow page table rebuilds are very frequent even
only 3 process running inside VM, such as kvm_mmu_free_roots
if invoked frequently.

PTI is enabled inside our VM, so 3 process will have 6
valid CR3s, but there are only 3 LRU cache of previous CR3s,
so this made the cache is always invalid, and the shadow page
table is frequently rebuilt.

In this patch we enlarge the number of LRU cache, and introduce
a parameter for it, so that user could enlarge the cache when
needed.

Here is context switch latency test of lmbench3, run in Ice
lake server, after enlarge the LRU cache number, the switch
latency reduced 14%~18%.

process number     2      3      4      5      6      7      8
LRU cache = 3    4.857  6.802  7.518  7.836  7.770  7.287  7.271
LRU cache = 11   4.654  5.518  6.292  6.516  6.512  7.135  7.270

Also, the kvm_mmu_free_roots reduced from 7k+ to 60, when running
the latency test with 4 processes.

Yong He (2):
  KVM: x86: expand the LRU cache of previous CR3s
  KVM: x86: introduce cache configurations for previous CR3s

 arch/x86/include/asm/kvm_host.h |  7 +++---
 arch/x86/kvm/mmu.h              |  1 +
 arch/x86/kvm/mmu/mmu.c          | 40 +++++++++++++++++++++++----------
 arch/x86/kvm/vmx/nested.c       |  4 ++--
 arch/x86/kvm/x86.c              |  2 +-
 5 files changed, 36 insertions(+), 18 deletions(-)

-- 
2.43.5


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

end of thread, other threads:[~2024-11-06  1:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29  3:13 [PATCH 0/2] Introduce configuration for LRU cache of previous CR3s Yong He
2024-10-29  3:13 ` [PATCH 1/2] KVM: x86: expand the " Yong He
2024-10-29 14:40   ` Sean Christopherson
2024-10-30 12:08     ` zhuangel570
2024-10-29  3:14 ` [PATCH 2/2] KVM: x86: introduce cache configurations for " Yong He
2024-10-29 15:14   ` Sean Christopherson
2024-10-30 12:51     ` zhuangel570
2024-11-06  1:42       ` Sean Christopherson

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