From patchwork Tue Dec 9 11:26:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 5461961 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9CEF59F2E8 for ; Tue, 9 Dec 2014 11:25:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C03252015A for ; Tue, 9 Dec 2014 11:25:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8E1020172 for ; Tue, 9 Dec 2014 11:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932226AbaLILZh (ORCPT ); Tue, 9 Dec 2014 06:25:37 -0500 Received: from mail-lb0-f172.google.com ([209.85.217.172]:63256 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932212AbaLILZf (ORCPT ); Tue, 9 Dec 2014 06:25:35 -0500 Received: by mail-lb0-f172.google.com with SMTP id u10so302962lbd.31 for ; Tue, 09 Dec 2014 03:25:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=spd+IGsGeQJj/Cin7wlGNrO4PRFbgE7jYT2xuse39WY=; b=E6icdpltq3WWPtrl8bf4Dtrf3AeukScm9LBumdmCHpHdnQsc1IwriPRnjB12LgNOEM XqTQuFcaNxQ0C38GZUqPwkUbtn3+FMUT1GNDbBn11cLKayy6OZQWTIm0V1483+Wd/Nt/ 2aLaQACRuhCJdTHuadwQo7QGglohtEJwVUCSH+qecwZ5eHRCvZ1LrYfL7+M+9udpH/rD lk3tH+CFyfq/2j5/yctxBiO3/5boa23vlIrVZWpbDMwTLssucbkQQ3h2WJdVJg0mxXsr lVBgZA1CX5ekDfmznlmuIoNSyPOHOgp8f0uN0XHR/YVkdA7eQ9eL6cQSpumLO1+qTTER Iv7Q== X-Gm-Message-State: ALoCoQkxsfP/9liiZqEghVV/K1656i9VIhHAzDnzVDlSsEOqsAw8IkJcbeX2vyv08h5Cw+I5tKqW X-Received: by 10.152.37.38 with SMTP id v6mr21695402laj.10.1418124334143; Tue, 09 Dec 2014 03:25:34 -0800 (PST) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id w3sm279709law.36.2014.12.09.03.25.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Dec 2014 03:25:33 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , kvm@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Marc Zyngier , Shannon Zhao Subject: [GIT PULL 9/9] arm/arm64: KVM: vgic: kick the specific vcpu instead of iterating through all Date: Tue, 9 Dec 2014 12:26:08 +0100 Message-Id: <1418124368-28418-10-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1418124368-28418-1-git-send-email-christoffer.dall@linaro.org> References: <1418124368-28418-1-git-send-email-christoffer.dall@linaro.org> 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, T_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 From: Shannon Zhao When call kvm_vgic_inject_irq to inject interrupt, we can known which vcpu the interrupt for by the irq_num and the cpuid. So we should just kick this vcpu to avoid iterating through all. Reviewed-by: Christoffer Dall Signed-off-by: Shannon Zhao Signed-off-by: Marc Zyngier --- virt/kvm/arm/vgic.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 631a472..21e035c 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1607,7 +1607,7 @@ static int vgic_validate_injection(struct kvm_vcpu *vcpu, int irq, int level) } } -static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid, +static int vgic_update_irq_pending(struct kvm *kvm, int cpuid, unsigned int irq_num, bool level) { struct vgic_dist *dist = &kvm->arch.vgic; @@ -1673,7 +1673,7 @@ static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid, out: spin_unlock(&dist->lock); - return ret; + return ret ? cpuid : -EINVAL; } /** @@ -1693,9 +1693,14 @@ out: int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num, bool level) { - if (likely(vgic_initialized(kvm)) && - vgic_update_irq_pending(kvm, cpuid, irq_num, level)) - vgic_kick_vcpus(kvm); + int vcpu_id; + + if (likely(vgic_initialized(kvm))) { + vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level); + if (vcpu_id >= 0) + /* kick the specified vcpu */ + kvm_vcpu_kick(kvm_get_vcpu(kvm, vcpu_id)); + } return 0; }