KVM: x86: Break kvm_for_each_vcpu loop after finding the VP_INDEX
authorTakuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Thu, 27 Feb 2014 06:08:31 +0000 (15:08 +0900)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 27 Feb 2014 18:25:39 +0000 (19:25 +0100)
No need to scan the entire VCPU array.

Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c

index 4cca45853dfeb9ac96b47062fbe87211d4c14be2..773eba799c453c89ad10d0cbdf259f96035e00ff 100644 (file)
@@ -2328,9 +2328,12 @@ static int get_msr_hyperv(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
        case HV_X64_MSR_VP_INDEX: {
                int r;
                struct kvm_vcpu *v;
-               kvm_for_each_vcpu(r, v, vcpu->kvm)
-                       if (v == vcpu)
+               kvm_for_each_vcpu(r, v, vcpu->kvm) {
+                       if (v == vcpu) {
                                data = r;
+                               break;
+                       }
+               }
                break;
        }
        case HV_X64_MSR_EOI: