From: Dave.Martin@arm.com (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/4] KVM: arm64: Don't mask softirq with IRQs disabled in vcpu_put()
Date: Fri, 15 Jun 2018 16:47:24 +0100 [thread overview]
Message-ID: <1529077646-2848-3-git-send-email-Dave.Martin@arm.com> (raw)
In-Reply-To: <1529077646-2848-1-git-send-email-Dave.Martin@arm.com>
Commit e6b673b ("KVM: arm64: Optimise FPSIMD handling to reduce
guest/host thrashing") introduces a specific helper
kvm_arch_vcpu_put_fp() for saving the vcpu FPSIMD state during
vcpu_put().
This function uses local_bh_disable()/_enable() to protect the
FPSIMD context manipulation from interruption by softirqs.
This approach is not correct, because vcpu_put() can be invoked
either from the KVM host vcpu thread (when exiting the vcpu run
loop), or via a preempt notifier. In the former case, only
preemption is disabled. In the latter case, the function is called
from inside __schedule(), which means that IRQs are disabled.
Use of local_bh_disable()/_enable() with IRQs disabled is considerd
an error, resulting in lockdep splats while running VMs if lockdep
is enabled.
This patch disables IRQs instead of attempting to disable softirqs,
avoiding the problem of calling local_bh_enable() with IRQs
disabled in the __schedule() path. This creates an additional
interrupt blackout during vcpu run loop exit, but this is the rare
case and the blackout latency is still less than that of
__schedule().
Fixes: e6b673b741ea ("KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashing")
Reported-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
---
Changes since v1:
Requested by Marc Zyngier:
* Disable IRQs unconditionally instead of attempting to conditionally
disable softirqs. This creates an additional interrupt blackout
during vcpu run loop exit. This is the rare case, and the blackout
latency is still less than that of __schedule().
---
arch/arm64/kvm/fpsimd.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c
index dc6ecfa..f9d0931 100644
--- a/arch/arm64/kvm/fpsimd.c
+++ b/arch/arm64/kvm/fpsimd.c
@@ -5,7 +5,7 @@
* Copyright 2018 Arm Limited
* Author: Dave Martin <Dave.Martin@arm.com>
*/
-#include <linux/bottom_half.h>
+#include <linux/irqflags.h>
#include <linux/sched.h>
#include <linux/thread_info.h>
#include <linux/kvm_host.h>
@@ -92,7 +92,9 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu)
*/
void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
{
- local_bh_disable();
+ unsigned long flags;
+
+ local_irq_save(flags);
update_thread_flag(TIF_SVE,
vcpu->arch.flags & KVM_ARM64_HOST_SVE_IN_USE);
@@ -106,5 +108,5 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
fpsimd_bind_task_to_cpu();
}
- local_bh_enable();
+ local_irq_restore(flags);
}
--
2.1.4
next prev parent reply other threads:[~2018-06-15 15:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-15 15:47 [PATCH v2 0/4] KVM: arm64: FPSIMD/SVE fixes for 4.17 Dave Martin
2018-06-15 15:47 ` [PATCH v2 1/4] arm64: introduce sysreg_clear_set() Dave Martin
2018-06-15 16:21 ` Catalin Marinas
2018-06-15 16:43 ` Dave Martin
2018-06-15 15:47 ` Dave Martin [this message]
2018-06-15 15:47 ` [PATCH v2 3/4] KVM: arm64/sve: Fix SVE trap restoration for non-current tasks Dave Martin
2018-06-15 15:47 ` [PATCH v2 4/4] KVM: arm64: Avoid mistaken attempts to save SVE state for vcpus Dave Martin
2018-06-15 15:56 ` [PATCH v2 0/4] KVM: arm64: FPSIMD/SVE fixes for 4.17 Dave Martin
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=1529077646-2848-3-git-send-email-Dave.Martin@arm.com \
--to=dave.martin@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).