Skip to content

Commit 11f340e

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: KVM: Skip PMU checking on vCPU context switch
PMU hardware about VM is switched on VM exit to host rather than vCPU context sched off, PMU is checked and restored on return to VM. It is not necessary to check PMU on vCPU context sched on callback, since the request is made on the VM exit entry or VM PMU CSR access abort routine already. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 5001bcf commit 11f340e

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

arch/loongarch/kvm/vcpu.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,6 @@ static void kvm_lose_pmu(struct kvm_vcpu *vcpu)
148148
kvm_restore_host_pmu(vcpu);
149149
}
150150

151-
static void kvm_restore_pmu(struct kvm_vcpu *vcpu)
152-
{
153-
if ((vcpu->arch.aux_inuse & KVM_LARCH_PMU))
154-
kvm_make_request(KVM_REQ_PMU, vcpu);
155-
}
156-
157151
static void kvm_check_pmu(struct kvm_vcpu *vcpu)
158152
{
159153
if (kvm_check_request(KVM_REQ_PMU, vcpu)) {
@@ -304,7 +298,10 @@ static int kvm_pre_enter_guest(struct kvm_vcpu *vcpu)
304298
vcpu->arch.aux_inuse &= ~KVM_LARCH_SWCSR_LATEST;
305299

306300
if (kvm_request_pending(vcpu) || xfer_to_guest_mode_work_pending()) {
307-
kvm_lose_pmu(vcpu);
301+
if (vcpu->arch.aux_inuse & KVM_LARCH_PMU) {
302+
kvm_lose_pmu(vcpu);
303+
kvm_make_request(KVM_REQ_PMU, vcpu);
304+
}
308305
/* make sure the vcpu mode has been written */
309306
smp_store_mb(vcpu->mode, OUTSIDE_GUEST_MODE);
310307
local_irq_enable();
@@ -1609,9 +1606,6 @@ static int _kvm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
16091606
kvm_restore_timer(vcpu);
16101607
kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
16111608

1612-
/* Restore hardware PMU CSRs */
1613-
kvm_restore_pmu(vcpu);
1614-
16151609
/* Don't bother restoring registers multiple times unless necessary */
16161610
if (vcpu->arch.aux_inuse & KVM_LARCH_HWCSR_USABLE)
16171611
return 0;

0 commit comments

Comments
 (0)