From: Christoffer Dall <cdall@linaro.org> To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier <marc.zyngier@arm.com>, Andre Przywara <andre.przywara@arm.com>, Christoffer Dall <cdall@linaro.org>, kvm@vger.kernel.org Subject: [PATCH 9/9] KVM: arm/arm64: vgic: Improve sync_hwstate performance Date: Mon, 20 Mar 2017 11:58:18 +0100 [thread overview] Message-ID: <20170320105818.20481-10-cdall@linaro.org> (raw) In-Reply-To: <20170320105818.20481-1-cdall@linaro.org> There is no need to call any functions to fold LRs when we don't use any LRs and we don't need to mess with overflow flags, take spinlocks, or prune the AP list if the AP list is empty. Note: list_empty is a single atomic read (uses READ_ONCE) and can therefore check if a list is empty or not without the need to take the spinlock protecting the list. Signed-off-by: Christoffer Dall <cdall@linaro.org> --- virt/kvm/arm/vgic/vgic.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 093873e..8ecb009 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -639,15 +639,18 @@ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) { struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; - if (unlikely(!vgic_initialized(vcpu->kvm))) + /* An empty ap_list_head implies used_lrs == 0 */ + if (list_empty(&vcpu->arch.vgic_cpu.ap_list_head)) return; vgic_clear_uie(vcpu); - vgic_fold_lr_state(vcpu); - vgic_prune_ap_list(vcpu); - /* Make sure we can fast-path in flush_hwstate */ - vgic_cpu->used_lrs = 0; + if (vgic_cpu->used_lrs) { + vgic_fold_lr_state(vcpu); + vgic_cpu->used_lrs = 0; + } + + vgic_prune_ap_list(vcpu); } /* Flush our emulation state into the GIC hardware before entering the guest. */ -- 2.9.0
WARNING: multiple messages have this Message-ID (diff)
From: cdall@linaro.org (Christoffer Dall) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 9/9] KVM: arm/arm64: vgic: Improve sync_hwstate performance Date: Mon, 20 Mar 2017 11:58:18 +0100 [thread overview] Message-ID: <20170320105818.20481-10-cdall@linaro.org> (raw) In-Reply-To: <20170320105818.20481-1-cdall@linaro.org> There is no need to call any functions to fold LRs when we don't use any LRs and we don't need to mess with overflow flags, take spinlocks, or prune the AP list if the AP list is empty. Note: list_empty is a single atomic read (uses READ_ONCE) and can therefore check if a list is empty or not without the need to take the spinlock protecting the list. Signed-off-by: Christoffer Dall <cdall@linaro.org> --- virt/kvm/arm/vgic/vgic.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 093873e..8ecb009 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -639,15 +639,18 @@ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) { struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; - if (unlikely(!vgic_initialized(vcpu->kvm))) + /* An empty ap_list_head implies used_lrs == 0 */ + if (list_empty(&vcpu->arch.vgic_cpu.ap_list_head)) return; vgic_clear_uie(vcpu); - vgic_fold_lr_state(vcpu); - vgic_prune_ap_list(vcpu); - /* Make sure we can fast-path in flush_hwstate */ - vgic_cpu->used_lrs = 0; + if (vgic_cpu->used_lrs) { + vgic_fold_lr_state(vcpu); + vgic_cpu->used_lrs = 0; + } + + vgic_prune_ap_list(vcpu); } /* Flush our emulation state into the GIC hardware before entering the guest. */ -- 2.9.0
next prev parent reply other threads:[~2017-03-20 10:58 UTC|newest] Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-03-20 10:58 [PATCH 0/9] KVM: arm/arm64: vgic: Improvements and optimizations Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall 2017-03-20 10:58 ` [PATCH 1/9] KVM: arm/arm64: vgic: Defer touching GICH_VMCR to vcpu_load/put Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall 2017-03-21 10:29 ` Marc Zyngier 2017-03-21 10:29 ` Marc Zyngier 2017-03-21 11:16 ` Christoffer Dall 2017-03-21 11:16 ` Christoffer Dall 2017-03-20 10:58 ` [PATCH 2/9] KVM: arm/arm64: vgic: Avoid flushing vgic state when there's no pending IRQ Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall 2017-03-21 10:57 ` Marc Zyngier 2017-03-21 10:57 ` Marc Zyngier 2017-03-21 11:17 ` Christoffer Dall 2017-03-21 11:17 ` Christoffer Dall 2017-03-20 10:58 ` [PATCH 3/9] KVM: arm/arm64: vgic: Get rid of live_lrs Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall 2017-03-21 11:06 ` Marc Zyngier 2017-03-21 11:06 ` Marc Zyngier 2017-03-20 10:58 ` [PATCH 4/9] KVM: arm/arm64: vgic: Get rid of unnecessary process_maintenance operation Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall 2017-03-21 11:36 ` Marc Zyngier 2017-03-21 11:36 ` Marc Zyngier 2017-03-21 12:26 ` [PATCH 4/9] KVM: arm/arm64: vgic: Get rid of unnecessary process_maintenance operationjjjj Christoffer Dall 2017-03-21 12:26 ` Christoffer Dall 2017-03-21 13:26 ` Marc Zyngier 2017-03-21 13:26 ` Marc Zyngier 2017-03-21 14:10 ` Christoffer Dall 2017-03-21 14:10 ` Christoffer Dall 2017-03-20 10:58 ` [PATCH 5/9] KVM: arm/arm64: vgic: Get rid of unnecessary save_maint_int_state Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall 2017-03-21 11:44 ` Marc Zyngier 2017-03-21 11:44 ` Marc Zyngier 2017-03-20 10:58 ` [PATCH 6/9] KVM: arm/arm64: vgic: Get rid of MISR and EISR fields Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall 2017-03-21 11:45 ` Marc Zyngier 2017-03-21 11:45 ` Marc Zyngier 2017-03-20 10:58 ` [PATCH 7/9] KVM: arm/arm64: vgic: Implement early VGIC init functionality Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall 2017-03-21 12:05 ` Marc Zyngier 2017-03-21 12:05 ` Marc Zyngier 2017-03-21 12:29 ` Christoffer Dall 2017-03-21 12:29 ` Christoffer Dall 2017-03-21 13:30 ` Marc Zyngier 2017-03-21 13:30 ` Marc Zyngier 2017-03-20 10:58 ` [PATCH 8/9] KVM: arm/arm64: vgic: Don't check vgic_initialized in flush_hwstate Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall 2017-03-21 12:08 ` Marc Zyngier 2017-03-21 12:08 ` Marc Zyngier 2017-03-21 12:30 ` Christoffer Dall 2017-03-21 12:30 ` Christoffer Dall 2017-03-20 10:58 ` Christoffer Dall [this message] 2017-03-20 10:58 ` [PATCH 9/9] KVM: arm/arm64: vgic: Improve sync_hwstate performance Christoffer Dall 2017-03-21 13:29 ` Marc Zyngier 2017-03-21 13:29 ` Marc Zyngier 2017-03-21 14:13 ` Christoffer Dall 2017-03-21 14:13 ` Christoffer Dall
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170320105818.20481-10-cdall@linaro.org \ --to=cdall@linaro.org \ --cc=andre.przywara@arm.com \ --cc=kvm@vger.kernel.org \ --cc=kvmarm@lists.cs.columbia.edu \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=marc.zyngier@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.