From patchwork Sun Apr 23 17:08:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AB8ED601E9 for ; Sun, 23 Apr 2017 17:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1D0A262F2 for ; Sun, 23 Apr 2017 17:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9686D26490; Sun, 23 Apr 2017 17:34:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2604E26538 for ; Sun, 23 Apr 2017 17:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7KatcgvFUn7PkuGG5yEGsWsRbDpvhcfY+iYI4sCcigg=; b=FkPXpFwsYgYAg4JL1mpKmeDnd3 8OpiKf0MVJAw+ddo/6aQGBLGjBRW0zaMoPhYcRg6nZAiiRU9kSd7+defKTRJsFv6M1GbhH6nrSA+J GSaq0iD6P1KikWJZhX+8dmAX6UoEsKb4YQ4YC+4RKr4Zp6jPjuQ1D0ifPxepDlkrYlc/BG/VEM/7T 24X5A0DrWrdu7NIKQOXeW9GVRvVchptoTnzwFarv2DOHIGvU0Nim3t0ROkesF/5RnU+0VUqIWFOue nkw7gbjRoOsTJLV4EYCFyeCKPaKouVvopgmuhAO4SH6Dyf5+pNeNWeitfQ3SE+ebvfwnNaydwtFBZ hezxTxZg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d2LPA-0006wV-W4; Sun, 23 Apr 2017 17:34:37 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2LM5-0002ZO-Gx for linux-arm-kernel@bombadil.infradead.org; Sun, 23 Apr 2017 17:31:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5MPNSO2UMVhthGbqjkXGhDLiz78n7zWElftZA4KmI9A=; b=E15W1Ow58SHP/ZwnUAnUSWEJH v5d5ElqfOhj9/6m04Uf1dmAfbahOThcZor31G5qhDC8DyjepiCAN3ojNt2O6a1Ik8Wa/IPTg/GS3V iydULIEfJ2+ByavvAkBwZUsVb88WiGLWq8ezVz7SB3/WHa3UtNnyc0NNbxxg7lgNBR7QfBT5sxoZO pKRdAsRQVkg9QCW7rlgjCuu3vs5DepUhwFMOcKX7+HkH9Wi58M2WEiFVUb9RkVC1i1Jnbv5Wdq3EK HXzr8KDDwUNjxSYEJ6+QXCNty/6snVHVwz7Nf7wk9gcUQJ2XYdj6cKJYIchSJdXDS3OD2LYZi8H7S E62xPPJFA==; Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2L3V-0005L3-VU for linux-arm-kernel@lists.infradead.org; Sun, 23 Apr 2017 17:12:17 +0000 Received: by mail-wm0-x233.google.com with SMTP id u65so7501912wmu.1 for ; Sun, 23 Apr 2017 10:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5MPNSO2UMVhthGbqjkXGhDLiz78n7zWElftZA4KmI9A=; b=cfdflEEntFKFsvS6UnrT0rR34Lyk3WsD/iUk1JJJUdrIgp/K5lQzJVM33qY9NSwBX3 cjqLDtra5tWT6i3C//fA98KimtX/Qc7sK781jzlHf6/Pvj8z2G/IA8XteJmY89sut9jl Su0+lGw95SCP0gnm0Ps4Nq7UXTJX7GIPNITlY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5MPNSO2UMVhthGbqjkXGhDLiz78n7zWElftZA4KmI9A=; b=IO+eAm7fGC4r3Qs5VNCvKqbLXSD+8SUWS2RDcO5ulYqfcxptKtJysXRCAhoG5K+Rxu eW0g2A8h8yaDPjiQtg+b9jlRpoNGpW5UxGZEMM5am/u/5CJw40kWdjIt5FKmV1WKeMYQ 4n/RjI5OMGMdL2qwOJo5iMnv93egotpVx14JEaCsh06wuVoYrXFogrSSzQPZJxzvbVBF okGKpzeAC3CDO+qTqHeNn8NiUBVWSOVy9go6kIYL/EWtpWcrGarmP29OgiNDRCiXwVIb 0N2R1xOjkLY7qmJm1fMeMUoJEd2U5ikBAjbIxlPjMDlz03y9X77hAVKsQ4JK4AYvJxPi doQA== X-Gm-Message-State: AN3rC/7qR/VByloWFXJ0GKJlHa31+0aABuDguV/p5cmXq9TjkDiuJFEX wgvDbjrzgvP+qSB8 X-Received: by 10.80.174.99 with SMTP id c90mr133174edd.136.1492967392189; Sun, 23 Apr 2017 10:09:52 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id 58sm2803521edz.2.2017.04.23.10.09.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:09:51 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 20/79] KVM: arm/arm64: vgic: Only set underflow when actually out of LRs Date: Sun, 23 Apr 2017 19:08:30 +0200 Message-Id: <20170423170929.27334-21-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170423170929.27334-1-cdall@linaro.org> References: <20170423170929.27334-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170423_131214_168750_2E18C030 X-CRM114-Status: GOOD ( 11.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Christoffer Dall , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We currently assume that all the interrupts in our AP list will be queued to LRs, but that's not necessarily the case, because some of them could have been migrated away to different VCPUs and only the VCPU thread itself can remove interrupts from its AP list. Therefore, slightly change the logic to only setting the underflow interrupt when we actually run out of LRs. As it turns out, this allows us to further simplify the handling in vgic_sync_hwstate in later patches. Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 1043291..442f7df 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -601,10 +601,8 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu) DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&vgic_cpu->ap_list_lock)); - if (compute_ap_list_depth(vcpu) > kvm_vgic_global_state.nr_lr) { - vgic_set_underflow(vcpu); + if (compute_ap_list_depth(vcpu) > kvm_vgic_global_state.nr_lr) vgic_sort_ap_list(vcpu); - } list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) { spin_lock(&irq->irq_lock); @@ -623,8 +621,12 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu) next: spin_unlock(&irq->irq_lock); - if (count == kvm_vgic_global_state.nr_lr) + if (count == kvm_vgic_global_state.nr_lr) { + if (!list_is_last(&irq->ap_list, + &vgic_cpu->ap_list_head)) + vgic_set_underflow(vcpu); break; + } } vcpu->arch.vgic_cpu.used_lrs = count;