All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v4 0/7] KVM: x86: add per-vCPU exits disable capability
@ 2022-06-22  0:49 Kechen Lu
  2022-06-22  0:49 ` [RFC PATCH v4 1/7] KVM: x86: only allow exits disable before vCPUs created Kechen Lu
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Kechen Lu @ 2022-06-22  0:49 UTC (permalink / raw)
  To: kvm, pbonzini
  Cc: seanjc, chao.gao, vkuznets, somduttar, kechenl, linux-kernel

Summary
===========
Introduce support of vCPU-scoped ioctl with KVM_CAP_X86_DISABLE_EXITS
cap for disabling exits to enable finer-grained VM exits disabling
on per vCPU scales instead of whole guest. This patch series enabled
the vCPU-scoped exits control and toggling.

Motivation
============
In use cases like Windows guest running heavy CPU-bound
workloads, disabling HLT VM-exits could mitigate host sched ctx switch
overhead. Simply HLT disabling on all vCPUs could bring
performance benefits, but if no pCPUs reserved for host threads, could
happened to the forced preemption as host does not know the time to do
the schedule for other host threads want to run. With this patch, we
could only disable part of vCPUs HLT exits for one guest, this still
keeps performance benefits, and also shows resiliency to host stressing
workload running at the same time.

Performance and Testing
=========================
In the host stressing workload experiment with Windows guest heavy
CPU-bound workloads, it shows good resiliency and having the ~3%
performance improvement. E.g. Passmark running in a Windows guest
with this patch disabling HLT exits on only half of vCPUs still
showing 2.4% higher main score v/s baseline.

Tested everything on AMD machines.

v3->v4 (Chao Gao) :
- Use kvm vCPU request KVM_REQ_DISABLE_EXIT to perform the arch
  VMCS updating (patch 5)
- Fix selftests redundant arguments (patch 7)
- Merge overlapped fix bits from patch 4 to patch 3

v2->v3 (Sean Christopherson) :
- Reject KVM_CAP_X86_DISABLE_EXITS if userspace disable MWAIT exits
  when MWAIT is not allowed in guest (patch 3)
- Make userspace able to re-enable previously disabled exits (patch 4)
- Add mwait/pause/cstate exits flag toggling instead of only hlt
  exits (patch 5)
- Add selftests for KVM_CAP_X86_DISABLE_EXITS (patch 7)

v1->v2 (Sean Christopherson) :
- Add explicit restriction for VM-scoped exits disabling to be called
  before vCPUs creation (patch 1)
- Use vCPU ioctl instead of 64bit vCPU bitmask (patch 5), and make exits
  disable flags check purely for vCPU instead of VM (patch 2)

Best Regards,
Kechen

Kechen Lu (4):
  KVM: x86: Move *_in_guest power management flags to vCPU scope
  KVM: x86: add vCPU scoped toggling for disabled exits
  KVM: x86: Add a new guest_debug flag forcing exit to userspace
  KVM: selftests: Add tests for VM and vCPU cap
    KVM_CAP_X86_DISABLE_EXITS

Sean Christopherson (3):
  KVM: x86: only allow exits disable before vCPUs created
  KVM: x86: Reject disabling of MWAIT interception when not allowed
  KVM: x86: Let userspace re-enable previously disabled exits

 Documentation/virt/kvm/api.rst                |   8 +-
 arch/x86/include/asm/kvm-x86-ops.h            |   1 +
 arch/x86/include/asm/kvm_host.h               |   8 +
 arch/x86/kvm/cpuid.c                          |   4 +-
 arch/x86/kvm/lapic.c                          |   7 +-
 arch/x86/kvm/svm/nested.c                     |   4 +-
 arch/x86/kvm/svm/svm.c                        |  44 +++++-
 arch/x86/kvm/vmx/vmx.c                        |  54 ++++++-
 arch/x86/kvm/x86.c                            |  79 ++++++++--
 arch/x86/kvm/x86.h                            |  16 +-
 include/uapi/linux/kvm.h                      |   5 +-
 tools/include/uapi/linux/kvm.h                |   1 +
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/include/x86_64/svm_util.h   |   1 +
 .../selftests/kvm/x86_64/disable_exits_test.c | 145 ++++++++++++++++++
 16 files changed, 332 insertions(+), 47 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/disable_exits_test.c

-- 
2.32.0


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

end of thread, other threads:[~2022-07-20 20:23 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22  0:49 [RFC PATCH v4 0/7] KVM: x86: add per-vCPU exits disable capability Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 1/7] KVM: x86: only allow exits disable before vCPUs created Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 2/7] KVM: x86: Move *_in_guest power management flags to vCPU scope Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 3/7] KVM: x86: Reject disabling of MWAIT interception when not allowed Kechen Lu
2022-07-20 17:53   ` Sean Christopherson
2022-07-20 18:37     ` Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 4/7] KVM: x86: Let userspace re-enable previously disabled exits Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 5/7] KVM: x86: add vCPU scoped toggling for " Kechen Lu
2022-07-20 18:41   ` Sean Christopherson
2022-07-20 19:04     ` Kechen Lu
2022-07-20 19:30       ` Sean Christopherson
2022-07-20 20:23         ` Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 6/7] KVM: x86: Add a new guest_debug flag forcing exit to userspace Kechen Lu
2022-07-20 17:06   ` Sean Christopherson
2022-07-20 19:11     ` Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 7/7] KVM: selftests: Add tests for VM and vCPU cap KVM_CAP_X86_DISABLE_EXITS Kechen Lu
2022-06-22  6:44   ` Huang, Shaoqin
2022-06-22 23:30     ` Kechen Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.