[PATCH v3 0/4] LoongArch: KVM: Set max VM supported FPU type with FPU exception

Bibo Mao posted 4 patches 5 days, 19 hours ago
There is a newer version of this series
arch/loongarch/include/asm/kvm_host.h |  6 +--
arch/loongarch/kvm/exit.c             | 21 +++-----
arch/loongarch/kvm/vcpu.c             | 78 ++++++++-------------------
3 files changed, 30 insertions(+), 75 deletions(-)
[PATCH v3 0/4] LoongArch: KVM: Set max VM supported FPU type with FPU exception
Posted by Bibo Mao 5 days, 19 hours ago
With FPU save and restore, the cost is the same with different FPU width
8/16/32 bytes, whatever from CPU cycle and cache line impaction.

Here is to enable FPU with max VM supported type, for example if
VM supports LASX instrction, enable FPU with LASX type with all FPU
exceptions including FPU/LSX/LASX exception. So if LASX is enabled with
FPU exception, it can avoid potential LSX/LASX exception in future.

With context switch microbench which touches FPU and LASX, there is 9%
improvement when halt_poll_ns is disabled. The command is
"./context --test=pipe" and source code located at:
  https://github.com/bibo-mao/context_switch/blob/main/context.c

Original     Wih patch      improvement
75232        82440          9%

---
v2 ... v3:
  1. Merge patch 1 and patch 3 together, patch 1 adds KVM_REQ_LBT_LOAD
     type, patch 3 renames KVM_REQ_AUX_LOAD with KVM_REQ_FPU_LOAD.
  2. Merge patch 5 and patch 6 together, which remove aux flags
     KVM_LARCH_LSX and KVM_LARCH_LASX

v1 ... v2:
  1. Enable FPU with max VM supported FPU type, rather than max used type.
  2. Add new request bit KVM_REQ_LBT_LOAD for LBT restore
  3. Rename KVM_REQ_AUX_LOAD with KVM_REQ_FPU_LOAD
  3. Remove aux_ldtype and KVM_LARCH_LSX/KVM_LARCH_LSX
  4. Remove middle FPU state handling in kvm_own_lsx() and kvm_own_lasx(),
     directly enable LSX or LASX from FPU none state.
---
Bibo Mao (4):
  LoongArch: KVM: Add separate KVM_REQ_LBT_LOAD request bit
  LoongArch: KVM: Enable FPU with max VM supported FPU type
  LoongArch: KVM: Remove some middle FPU states
  LoongArch: KVM: Remove KVM_LARCH_LASX and KVM_LARCH_LSX

 arch/loongarch/include/asm/kvm_host.h |  6 +--
 arch/loongarch/kvm/exit.c             | 21 +++-----
 arch/loongarch/kvm/vcpu.c             | 78 ++++++++-------------------
 3 files changed, 30 insertions(+), 75 deletions(-)


base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8
-- 
2.39.3