From patchwork Fri Aug 3 13:57:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10555123 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAA8B15E9 for ; Fri, 3 Aug 2018 13:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7A012BBCF for ; Fri, 3 Aug 2018 13:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBD8F2BD32; Fri, 3 Aug 2018 13:57:49 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 4DBEA2BBCF for ; Fri, 3 Aug 2018 13:57:49 +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=q08v2c99ljXf9ZbGx7oag7whYrUNTk2GA0U02RxCmZs=; b=qXQnz6JygDzEp6FYhMmfPiy73O wtnk1StdaWa+wTlIkzbOd2xNn7N71eMDzthWVLrCYYy4XnN+LQP1PrBeTu4vSBx+Sn0t4dyuXCmQJ DqbyER6ZAUSSF8K8qIX90yhRLx72K892jLE4LUUocHifiG/wcoKWUV5aGzWnTljqnfIZn7QNI8UWu Y0p8HQVDgKfwJrvv8lq1PgQ+gAl0jtNK4iEgRmc988GokkorKGFmFePSZ3ItOmDli0jRZPieD9eip fV1FuaCLwOBajJW0eW7nURd9TAqtZ9cHRYglEavwU6F3iWRAfkDHdTybNqHP4xzThlxBlFSGY4kJF 9tRtSDPQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1flaaM-0002mj-5a; Fri, 03 Aug 2018 13:57:42 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1flaa9-0002eu-5x for linux-arm-kernel@lists.infradead.org; Fri, 03 Aug 2018 13:57:34 +0000 Received: by mail-pf1-x441.google.com with SMTP id j8-v6so3293858pff.6 for ; Fri, 03 Aug 2018 06:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OPQwdkXqDlJWFQwM8PJrKFSYX6aJHA1emkWP9neFEcg=; b=cqHe8mDNvNRM4rqyTE4fY+zvYmCxeu6hch6FR0yfbBWD5dF1WVjPr+kA52003fg3AJ RJI9h33DY5vhkLu2J7Aw37ssxXLFZUWfuF90VDV2kbx28StEBIFynCID+RIckcb+Q8Wq ebNNZQoFe20gjXUVVG3SyMvCbOlx/NILcX+EmemxOvj82dZbNB+pcxbV10wJJoubJ0vo VYqbKoRY7jN8gzbhcMAiWnR8jWcBLzGqnf4vnnucTl86Nis8oaJW93TFBmoaKaxOMpM3 TvxXcsSH0O5fMwBS0OsNjDbVdIGBhttdjjjt2+HJkKIn8exLx/Wu9ppOLtqB1E5PVTyl XxTQ== 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=OPQwdkXqDlJWFQwM8PJrKFSYX6aJHA1emkWP9neFEcg=; b=mc4LY7HyMMqamYQg9ReOh1QZGlfz1HLZUsuNIxrStHdTpshriTB/dg7vuoTDUy70+x lq50Z4vO/3C3AxD7ush0BjuB4pTS1n7uPDRVTX4R5259fmKnYbk9xBuvLBmFkT433xB0 Ik0G1BVaHxUzPV1/uFt1OPuja2rFa6zxzfuxllqGjVwib6k9Lgg4cqhGY+WvXYXDK5Od qs9wfH62niQoaelHtNK1lIkL8CabdHVNObnvDN9yb9QSY6TACgQDJRlFzfeSlcEmWnLz /s0kYBAMSUSN1ffTn3Yju3V97c/BiT57HRATq7mlAQJdhsnuTLx8Noqla+z9lyHVOy6H Xkkw== X-Gm-Message-State: AOUpUlEs70X/NQdY+6UcD3qlY2/Me5s2MaoRAjaKM0mXvv2WB7r71xTv qNvXTqlal42DHhuoNU3Bx0sBhvN9hNY= X-Google-Smtp-Source: AAOMgpfsXbrBD/0IKAQ5gTIeIxIW4Z34msz8guaCp1MASNSDSQPTg+HI+wGSMLMNzV1EdmBjNdONWg== X-Received: by 2002:a63:f344:: with SMTP id t4-v6mr3899062pgj.428.1533304643814; Fri, 03 Aug 2018 06:57:23 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id p5-v6sm6755173pfn.57.2018.08.03.06.57.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Aug 2018 06:57:23 -0700 (PDT) From: Jia He X-Google-Original-From: Jia He To: Christoffer Dall , Marc Zyngier , Catalin Marinas , Eric Auger , Ard Biesheuvel Subject: [PATCH 2/2] KVM: arm/arm64: vgic: no need to call spin_lock_irqsave/restore when irq is disabled Date: Fri, 3 Aug 2018 21:57:04 +0800 Message-Id: <1533304624-43250-2-git-send-email-jia.he@hxt-semitech.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1533304624-43250-1-git-send-email-jia.he@hxt-semitech.com> References: <1533304624-43250-1-git-send-email-jia.he@hxt-semitech.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180803_065729_226277_14677D91 X-CRM114-Status: GOOD ( 12.84 ) 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: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Jia He , Andre Przywara , Jia He , kvmarm@lists.cs.columbia.edu, 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 Because kvm_vgic_sync_hwstate currently is definitly in the context which irq is disabled (local_irq_disable/enable). There is no need to call spin_lock_irqsave/restore in vgic_fold_lr_state and vgic_prune_ap_list This patch replace them with the spin_lock/unlock no irq version Signed-off-by: Jia He Acked-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-v2.c | 7 ++++--- virt/kvm/arm/vgic/vgic-v3.c | 7 ++++--- virt/kvm/arm/vgic/vgic.c | 13 +++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c index a5f2e44..487f5f2 100644 --- a/virt/kvm/arm/vgic/vgic-v2.c +++ b/virt/kvm/arm/vgic/vgic-v2.c @@ -62,7 +62,8 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; struct vgic_v2_cpu_if *cpuif = &vgic_cpu->vgic_v2; int lr; - unsigned long flags; + + DEBUG_SPINLOCK_BUG_ON(!irqs_disabled()); cpuif->vgic_hcr &= ~GICH_HCR_UIE; @@ -83,7 +84,7 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) irq = vgic_get_irq(vcpu->kvm, vcpu, intid); - spin_lock_irqsave(&irq->irq_lock, flags); + spin_lock(&irq->irq_lock); /* Always preserve the active bit */ irq->active = !!(val & GICH_LR_ACTIVE_BIT); @@ -126,7 +127,7 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) vgic_irq_set_phys_active(irq, false); } - spin_unlock_irqrestore(&irq->irq_lock, flags); + spin_unlock(&irq->irq_lock); vgic_put_irq(vcpu->kvm, irq); } diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c index cdce653..b66b513 100644 --- a/virt/kvm/arm/vgic/vgic-v3.c +++ b/virt/kvm/arm/vgic/vgic-v3.c @@ -46,7 +46,8 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) struct vgic_v3_cpu_if *cpuif = &vgic_cpu->vgic_v3; u32 model = vcpu->kvm->arch.vgic.vgic_model; int lr; - unsigned long flags; + + DEBUG_SPINLOCK_BUG_ON(!irqs_disabled()); cpuif->vgic_hcr &= ~ICH_HCR_UIE; @@ -75,7 +76,7 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) if (!irq) /* An LPI could have been unmapped. */ continue; - spin_lock_irqsave(&irq->irq_lock, flags); + spin_lock(&irq->irq_lock); /* Always preserve the active bit */ irq->active = !!(val & ICH_LR_ACTIVE_BIT); @@ -118,7 +119,7 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) vgic_irq_set_phys_active(irq, false); } - spin_unlock_irqrestore(&irq->irq_lock, flags); + spin_unlock(&irq->irq_lock); vgic_put_irq(vcpu->kvm, irq); } diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index c22cea6..7cfdfbc 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -593,10 +593,11 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu) { struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; struct vgic_irq *irq, *tmp; - unsigned long flags; + + DEBUG_SPINLOCK_BUG_ON(!irqs_disabled()); retry: - spin_lock_irqsave(&vgic_cpu->ap_list_lock, flags); + spin_lock(&vgic_cpu->ap_list_lock); list_for_each_entry_safe(irq, tmp, &vgic_cpu->ap_list_head, ap_list) { struct kvm_vcpu *target_vcpu, *vcpuA, *vcpuB; @@ -637,7 +638,7 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu) /* This interrupt looks like it has to be migrated. */ spin_unlock(&irq->irq_lock); - spin_unlock_irqrestore(&vgic_cpu->ap_list_lock, flags); + spin_unlock(&vgic_cpu->ap_list_lock); /* * Ensure locking order by always locking the smallest @@ -651,7 +652,7 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu) vcpuB = vcpu; } - spin_lock_irqsave(&vcpuA->arch.vgic_cpu.ap_list_lock, flags); + spin_lock(&vcpuA->arch.vgic_cpu.ap_list_lock); spin_lock_nested(&vcpuB->arch.vgic_cpu.ap_list_lock, SINGLE_DEPTH_NESTING); spin_lock(&irq->irq_lock); @@ -676,7 +677,7 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu) spin_unlock(&irq->irq_lock); spin_unlock(&vcpuB->arch.vgic_cpu.ap_list_lock); - spin_unlock_irqrestore(&vcpuA->arch.vgic_cpu.ap_list_lock, flags); + spin_unlock(&vcpuA->arch.vgic_cpu.ap_list_lock); if (target_vcpu_needs_kick) { kvm_make_request(KVM_REQ_IRQ_PENDING, target_vcpu); @@ -686,7 +687,7 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu) goto retry; } - spin_unlock_irqrestore(&vgic_cpu->ap_list_lock, flags); + spin_unlock(&vgic_cpu->ap_list_lock); } static inline void vgic_fold_lr_state(struct kvm_vcpu *vcpu)