From: Yaozu Dong Date: Wed, 25 Apr 2007 13:49:19 +0000 (+0300) Subject: KVM: VMX: Avoid unnecessary vcpu_load()/vcpu_put() cycles X-Git-Tag: v2.6.22-rc1~1008^2~11 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fca03653010b8c5fa63b99fc94c78cbfb433d00;p=linux-2.6 KVM: VMX: Avoid unnecessary vcpu_load()/vcpu_put() cycles By checking if a reschedule is needed, we avoid dropping the vcpu. [With changes by me, based on Anthony Liguori's observations] Signed-off-by: Avi Kivity --- diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 03c0ee74d7..f5356358ac 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -1590,6 +1590,8 @@ static int set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data) void kvm_resched(struct kvm_vcpu *vcpu) { + if (!need_resched()) + return; vcpu_put(vcpu); cond_resched(); vcpu_load(vcpu);