From patchwork Mon May 4 01:25:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47927 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2EF5220553 for ; Mon, 4 May 2015 01:27:45 +0000 (UTC) Received: by laat2 with SMTP id t2sf42094726laa.2 for ; Sun, 03 May 2015 18:27:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=l7q+tUOpvMqvSucedqi3EpFQN9d4Db0UVQ6BfhQPF2E=; b=aVIhJTRh7SqoLI4pV8U1MKfygQgoZClXkdbVOF4eIsC7uSEAsTeXEl1VujEg5GPCZ2 o+iwb4Hkboqi3uZVdm4qguDN6DJjeiq4R1+bBg0KFRTKh7G47OzVQtNFburwO/cT4Til 81eWJB/gTk3KGaHgYYUFaWYZagJbiLL0UFkVrvUueGKOiF3eUvKnA612fz1v9oZRnS/f YPYMd6CJAzo0YAMwBONUriphNik9Y7Yr73vWU1uB3ZM7FxlwmO6AbJTKtUWQ/9Z8ob0Z 15AIR/XGo59VlhnPd8sBFcol1QAJuqgFM4J+ywtgh2sG5fDmZc/Crkp9dx6zUgBb8rfl QthA== X-Gm-Message-State: ALoCoQl1yrXI757oAAQDtVySPY+hyrnMpP4cVJIc+WQadNLfkHmAQboXWJkd08Kng+U3kVol9YZn X-Received: by 10.194.143.98 with SMTP id sd2mr16895608wjb.6.1430702864166; Sun, 03 May 2015 18:27:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.72 with SMTP id h8ls722714laa.71.gmail; Sun, 03 May 2015 18:27:44 -0700 (PDT) X-Received: by 10.153.5.36 with SMTP id cj4mr17362106lad.69.1430702864007; Sun, 03 May 2015 18:27:44 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id z7si9064748lal.43.2015.05.03.18.27.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:27:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbqq2 with SMTP id qq2so95362305lbb.3 for ; Sun, 03 May 2015 18:27:43 -0700 (PDT) X-Received: by 10.152.9.66 with SMTP id x2mr17514626laa.36.1430702863911; Sun, 03 May 2015 18:27:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1405993lbt; Sun, 3 May 2015 18:27:43 -0700 (PDT) X-Received: by 10.70.22.66 with SMTP id b2mr38081828pdf.114.1430702862145; Sun, 03 May 2015 18:27:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id es7si17680936pbd.123.2015.05.03.18.27.40; Sun, 03 May 2015 18:27:42 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751790AbbEDB1k (ORCPT + 2 others); Sun, 3 May 2015 21:27:40 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:33736 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751718AbbEDB1j (ORCPT ); Sun, 3 May 2015 21:27:39 -0400 Received: by pdbnk13 with SMTP id nk13so149559204pdb.0 for ; Sun, 03 May 2015 18:27:39 -0700 (PDT) X-Received: by 10.66.120.237 with SMTP id lf13mr38047346pab.89.1430702859470; Sun, 03 May 2015 18:27:39 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id j10sm11001499pdk.48.2015.05.03.18.27.37 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:27:38 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: sasha.levin@oracle.com, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Shannon Zhao , Marc Zyngier Subject: [PATCH for 3.18.y stable 11/22] arm/arm64: KVM: vgic: kick the specific vcpu instead of iterating through all Date: Mon, 4 May 2015 09:25:15 +0800 Message-Id: <1430702726-2056-12-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430702726-2056-1-git-send-email-shannon.zhao@linaro.org> References: <1430702726-2056-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Shannon Zhao commit 016ed39c54b8a3db680e5c6a43419f806133caf2 upstream. 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 Signed-off-by: Shannon Zhao --- 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 91e6bfc..12c10f2 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1608,7 +1608,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; }