diff mbox

KVM: x86: Break kvm_for_each_vcpu loop after finding the VP_INDEX

Message ID 20140227150831.cadb1e95.yoshikawa_takuya_b1@lab.ntt.co.jp (mailing list archive)
State New, archived
Headers show

Commit Message

Takuya Yoshikawa Feb. 27, 2014, 6:08 a.m. UTC
No need to scan the entire VCPU array.

Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
---
 BTW, this looks like hyperv support forces us to stick to the current
 implementation which stores VCPUs in an array, or at least something
 we can index them; not a good thing.

 arch/x86/kvm/x86.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini Feb. 27, 2014, 6:26 p.m. UTC | #1
Il 27/02/2014 07:08, Takuya Yoshikawa ha scritto:
> No need to scan the entire VCPU array.
>
> Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
> ---
>  BTW, this looks like hyperv support forces us to stick to the current
>  implementation which stores VCPUs in an array, or at least something
>  we can index them; not a good thing.
>
>  arch/x86/kvm/x86.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 4cca458..773eba7 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -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:
>

Applying to kvm/queue, thanks.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4cca458..773eba7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -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: