From patchwork Mon Jan 19 16:43:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 5659581 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1F9819F357 for ; Mon, 19 Jan 2015 16:46:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59DE6203C3 for ; Mon, 19 Jan 2015 16:46:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77F23203B8 for ; Mon, 19 Jan 2015 16:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752492AbbASQpg (ORCPT ); Mon, 19 Jan 2015 11:45:36 -0500 Received: from mail-wg0-f52.google.com ([74.125.82.52]:54115 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752350AbbASQpf (ORCPT ); Mon, 19 Jan 2015 11:45:35 -0500 Received: by mail-wg0-f52.google.com with SMTP id l2so10710537wgh.11 for ; Mon, 19 Jan 2015 08:45:32 -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=cIFPn0l+jXHieaYj7bcj3kJYl2PsGyZgiRMWWdAj1T0=; b=d+wq7ra5bkSrKhnwljheWsMItvzfruqdla/JolbgzieAEXBLF6hc7kNJ7/pPVJFNP/ /N5UgkLo0bvnjCAxmJIqYD72kdswnaonQrW2FtaTrH8ewSSnPJQNxcsHAIcSyOoziJNk cio5ZSeOMCc2uTjzw7GvEFxHYASPeCJ58dnIroRYSjWrxza3wIRRY3O2OftmUWDDMQfp pQdfe2Qs6QYXvrVEG+iYHsSBixwVM4KuugMo0aiYZ8XDz+hUXcKAUeE3yRqgWt5ThAtG +qd5HsxwZxeQGYW479tKrJVhv9qM8SLwC+B/bqui9q9VO6hHcVQh3pkArDqwk6NiJy9m DAuw== X-Gm-Message-State: ALoCoQnDxGQWoOBHgQAQznmB2ws9cW4cm3LGH2we/fK0JVhQTMEMwwlCCw7oZk+ILXut/G2Iodcl X-Received: by 10.194.184.140 with SMTP id eu12mr3559722wjc.25.1421685932715; Mon, 19 Jan 2015 08:45:32 -0800 (PST) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id dp8sm14812495wib.20.2015.01.19.08.45.30 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Jan 2015 08:45:31 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, andre.przywara@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, gleb@kernel.org, pbonzini@redhat.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v8 4/5] KVM: arm/arm64: remove coarse grain dist locking at kvm_vgic_sync_hwstate Date: Mon, 19 Jan 2015 17:43:12 +0100 Message-Id: <1421685793-3547-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421685793-3547-1-git-send-email-eric.auger@linaro.org> References: <1421685793-3547-1-git-send-email-eric.auger@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=unavailable 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 To prepare for irqfd addition, coarse grain locking is removed at kvm_vgic_sync_hwstate level and finer grain locking is introduced in vgic_process_maintenance only. Signed-off-by: Eric Auger Acked-by: Christoffer Dall --- virt/kvm/arm/vgic.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index c84f53df..18060ea 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1447,6 +1447,7 @@ epilog: static bool vgic_process_maintenance(struct kvm_vcpu *vcpu) { u32 status = vgic_get_interrupt_status(vcpu); + struct vgic_dist *dist = &vcpu->kvm->arch.vgic; bool level_pending = false; kvm_debug("STATUS = %08x\n", status); @@ -1464,6 +1465,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu) struct vgic_lr vlr = vgic_get_lr(vcpu, lr); WARN_ON(vgic_irq_is_edge(vcpu, vlr.irq)); + spin_lock(&dist->lock); vgic_irq_clear_queued(vcpu, vlr.irq); WARN_ON(vlr.state & LR_STATE_MASK); vlr.state = 0; @@ -1491,6 +1493,8 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu) vgic_cpu_irq_clear(vcpu, vlr.irq); } + spin_unlock(&dist->lock); + /* * Despite being EOIed, the LR may not have * been marked as empty. @@ -1505,10 +1509,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu) return level_pending; } -/* - * Sync back the VGIC state after a guest run. The distributor lock is - * needed so we don't get preempted in the middle of the state processing. - */ +/* Sync back the VGIC state after a guest run */ static void __kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) { struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; @@ -1555,14 +1556,10 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) { - struct vgic_dist *dist = &vcpu->kvm->arch.vgic; - if (!irqchip_in_kernel(vcpu->kvm)) return; - spin_lock(&dist->lock); __kvm_vgic_sync_hwstate(vcpu); - spin_unlock(&dist->lock); } int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu)