LoongArch: KVM: Start SW timer only when vcpu is blocking
authorBibo Mao <maobibo@loongson.cn>
Wed, 6 Mar 2024 01:12:13 +0000 (09:12 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Wed, 6 Mar 2024 01:12:13 +0000 (09:12 +0800)
commit8bc15d02d5fdff31bfeca02e58e22e26880dde39
treec3188804545239f6e62cef87efa565570280cec1
parentaebd3bd586c67a29ddbe7be7db06b45754477b52
LoongArch: KVM: Start SW timer only when vcpu is blocking

SW timer is enabled when vcpu thread is scheduled out, and it is to wake
up vcpu from blocked queue. If vcpu thread is scheduled out but is not
blocked, such as it is preempted by other threads, it is not necessary
to enable SW timer. Since vcpu thread is still on running queue if it is
preempted and SW timer is only to wake up vcpu on blocking queue, so SW
timer is not useful in this situation.

This patch enables SW timer only when vcpu is scheduled out and is
blocking.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kvm/timer.c