riscv: kvm: move preempt_disable() call in kvm_arch_vcpu_ioctl_run
Subsystems (2)
PATCH 1/1 riscv: kvm: move preempt_disable() call in kvm_arch_vcpu_ioctl_run
local_irq_disable provides stronger guarantees than preempt_disable so calling the latter is redundant when interrupts are disabled. Instead, explicitly disable preemption right before interrupts are enabled/disabled to ensure that the time accounted in guest_timing_exit_irqoff includes time taken by the guest or interrupts.
--- arch/riscv/kvm/vcpu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/riscv/kvm/vcpu.c +1 -3
@@ -888,8 +888,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)kvm_riscv_check_vcpu_requests (vcpu); -preempt_disable (); -local_irq_disable ();/*
@@ -926,7 +924,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) kvm_request_pending(vcpu)) { vcpu->mode =OUTSIDE_GUEST_MODE ;local_irq_enable (); -preempt_enable ();kvm_vcpu_srcu_read_lock (vcpu);continue ; }
@@ -960,6 +957,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)/* Syncup interrupts state with HW */ kvm_riscv_vcpu_sync_interrupts (vcpu); +preempt_disable ();/* * We must ensure that any pending interrupts are taken before * we exit guest timing so that timer ticks are accounted as
Signature · 1 line
2.25.1
Anup Patel
maintainerPATCH 1/1 riscv: kvm: move preempt_disable() call in kvm_arch_vcpu_ioctl_run
Quoted 8 lines · Nikolay Borisov
local_irq_disableprovides stronger guarantees thanpreempt_disableso calling the latter is redundant when interrupts are disabled. Instead, explicitly disable preemption right before interrupts are enabled/disabled to ensure that the time accounted inguest_timing_exit_irqoffincludes time taken by the guest or interrupts.Signed-off-by Nikolay Borisov <[email protected]>
Looks good to me.
I have queued it for 5.20
Thanks,
Anup
Quoted 36 lines
--- arch/riscv/kvm/vcpu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)arch/riscv/kvm/vcpu.c +1
-4@@ -888,8 +888,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)kvm_riscv_check_vcpu_requests (vcpu); -preempt_disable (); -local_irq_disable ();/* @@ -926,7 +924,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) kvm_request_pending(vcpu)) { vcpu->mode =OUTSIDE_GUEST_MODE ;local_irq_enable (); -preempt_enable ();kvm_vcpu_srcu_read_lock (vcpu);continue ; }@@ -960,6 +957,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)/* Syncup interrupts state with HW */ kvm_riscv_vcpu_sync_interrupts (vcpu); +preempt_disable ();/* * We must ensure that any pending interrupts are taken before * we exit guest timing so that timer ticks are accounted as -- 2.25.1