aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-02-06 06:58:42 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2015-04-08 04:46:54 -0400
commit9c8fd1ba2201c072bd3cf6940e2ca4d0a7aed723 (patch)
treecd49f3c0f47344a99e6337da700527ff10ff7a21 /arch/x86/kvm
parent362c698f8220e636edf1c40b1935715fa57f492f (diff)
KVM: x86: optimize delivery of TSC deadline timer interrupt
The newly-added tracepoint shows the following results on the tscdeadline_latency test: qemu-kvm-8387 [002] 6425.558974: kvm_vcpu_wakeup: poll time 10407 ns qemu-kvm-8387 [002] 6425.558984: kvm_vcpu_wakeup: poll time 0 ns qemu-kvm-8387 [002] 6425.561242: kvm_vcpu_wakeup: poll time 10477 ns qemu-kvm-8387 [002] 6425.561251: kvm_vcpu_wakeup: poll time 0 ns and so on. This is because we need to go through kvm_vcpu_block again after the timer IRQ is injected. Avoid it by polling once before entering kvm_vcpu_block. On my machine (Xeon E5 Sandy Bridge) this removes about 500 cycles (7%) from the latency of the TSC deadline timer. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/x86.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6256dfa598a1..50861dd15a94 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6406,12 +6406,13 @@ out:
6406 6406
6407static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu) 6407static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu)
6408{ 6408{
6409 srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); 6409 if (!kvm_arch_vcpu_runnable(vcpu)) {
6410 kvm_vcpu_block(vcpu); 6410 srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
6411 vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); 6411 kvm_vcpu_block(vcpu);
6412 6412 vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
6413 if (!kvm_check_request(KVM_REQ_UNHALT, vcpu)) 6413 if (!kvm_check_request(KVM_REQ_UNHALT, vcpu))
6414 return 1; 6414 return 1;
6415 }
6415 6416
6416 kvm_apic_accept_events(vcpu); 6417 kvm_apic_accept_events(vcpu);
6417 switch(vcpu->arch.mp_state) { 6418 switch(vcpu->arch.mp_state) {