[PATCH v3 0/4] LoongArch: KVM: Some small enhanments

From: Bibo Mao

Date: Sun Mar 22 2026 - 23:00:09 EST


There are some small enhancements about LoongArch KVM. There is
improvement about VM entry path in patch 1 and patch, add pending
request checking in advance and it is empty at most time.

Also change vcpu_is_preempted() from function to macro method, by actual
benchmark test such as unixbench. It is affected on physical machine
with function method. With the macro method, only one nop instruction
is added and there is no parameter parsing, there is no obvious
performance influence with physical machine.
---
v2 ... v3:
1. Add new patch to move host CSR_GSTAT save and restore in context
switch stage rather than VM entry, update it only when VMID is
changed on VM entry.

v1 ... v2:
1. Add READ_ONCE() with src->preempted to avoid compiler optimization.
---
Bibo Mao (4):
LoongArch: KVM: Add kvm_request_pending checking in
kvm_late_check_requests()
LoongArch: KVM: Move host CSR_EENTRY save and restore in context
switch
LoongArch: KVM: Move host CSR_GSTAT save and restore in context switch
LoongArch: KVM: Set vcpu_is_preempted() with macro rather than
function

arch/loongarch/include/asm/qspinlock.h | 27 +++++++++++++++++++++-----
arch/loongarch/kernel/paravirt.c | 15 ++------------
arch/loongarch/kvm/main.c | 8 ++++----
arch/loongarch/kvm/vcpu.c | 26 +++++++++++++------------
4 files changed, 42 insertions(+), 34 deletions(-)


base-commit: c369299895a591d96745d6492d4888259b004a9e
--
2.39.3