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

From: Huacai Chen

Date: Tue Jun 09 2026 - 23:19:08 EST


Applied, thanks.

Huacai

On Mon, Jun 8, 2026 at 9:32 AM Bibo Mao <maobibo@xxxxxxxxxxx> wrote:
>
> 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%
>
> ---
> v3 ... v4:
> 1. Fix one issue on patch 4 with function kvm_lose_fpu(), where flag
> KVM_LARCH_FPU is checked too early so that LBT disabling is
> skipped, since API kvm_lose_fpu() implies kvm_lose_lbt().
>
> 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, 31 insertions(+), 74 deletions(-)
>
>
> base-commit: c10130c234c81f4a7a143edbf413080235f8d8ce
> --
> 2.39.3
>