From patchwork Thu Feb 27 06:08:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 3730351 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C41C3BF13A for ; Thu, 27 Feb 2014 06:03:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0CCC92020F for ; Thu, 27 Feb 2014 06:03:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3AB9A2020A for ; Thu, 27 Feb 2014 06:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754643AbaB0GDs (ORCPT ); Thu, 27 Feb 2014 01:03:48 -0500 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]:35516 "EHLO tama500.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751421AbaB0GDs (ORCPT ); Thu, 27 Feb 2014 01:03:48 -0500 Received: from mfs5.rdh.ecl.ntt.co.jp (mfs5.rdh.ecl.ntt.co.jp [129.60.39.144]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id s1R63fkw023589; Thu, 27 Feb 2014 15:03:41 +0900 Received: from mfs5.rdh.ecl.ntt.co.jp (localhost.localdomain [127.0.0.1]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id 33DBCE0138; Thu, 27 Feb 2014 15:03:41 +0900 (JST) Received: from imail2.m.ecl.ntt.co.jp (imail2.m.ecl.ntt.co.jp [129.60.5.247]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id 1E94BE0135; Thu, 27 Feb 2014 15:03:41 +0900 (JST) Received: from yshpad ([129.60.241.157]) by imail2.m.ecl.ntt.co.jp (8.13.8/8.13.8) with SMTP id s1R63fcV032174; Thu, 27 Feb 2014 15:03:41 +0900 Date: Thu, 27 Feb 2014 15:08:31 +0900 From: Takuya Yoshikawa To: gleb@kernel.org, pbonzini@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH] KVM: x86: Break kvm_for_each_vcpu loop after finding the VP_INDEX Message-Id: <20140227150831.cadb1e95.yoshikawa_takuya_b1@lab.ntt.co.jp> X-Mailer: Sylpheed 3.1.0 (GTK+ 2.24.4; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-TM-AS-MML: No Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP No need to scan the entire VCPU array. Signed-off-by: Takuya Yoshikawa --- 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: