[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1583823679-17648-1-git-send-email-wanpengli@tencent.com>
Date: Tue, 10 Mar 2020 15:01:19 +0800
From: Wanpeng Li <kernellwp@...il.com>
To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>
Subject: [PATCH] KVM: X86: Don't load/put guest FPU context for sleeping AP
From: Wanpeng Li <wanpengli@...cent.com>
kvm_load_guest_fpu() and kvm_put_guest_fpu() each consume more than 14us
observed by ftrace, the qemu userspace FPU is swapped out for the guest
FPU context for the duration of the KVM_RUN ioctl even if sleeping AP,
we shouldn't load/put guest FPU context for this case especially for
serverless scenario which sensitives to boot time.
Signed-off-by: Wanpeng Li <wanpengli@...cent.com>
---
arch/x86/kvm/x86.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 5de2006..080ffa4 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8680,7 +8680,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
vcpu_load(vcpu);
kvm_sigset_activate(vcpu);
- kvm_load_guest_fpu(vcpu);
if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) {
if (kvm_run->immediate_exit) {
@@ -8718,12 +8717,14 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
}
}
+ kvm_load_guest_fpu(vcpu);
+
if (unlikely(vcpu->arch.complete_userspace_io)) {
int (*cui)(struct kvm_vcpu *) = vcpu->arch.complete_userspace_io;
vcpu->arch.complete_userspace_io = NULL;
r = cui(vcpu);
if (r <= 0)
- goto out;
+ goto out_fpu;
} else
WARN_ON(vcpu->arch.pio.count || vcpu->mmio_needed);
@@ -8732,8 +8733,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
else
r = vcpu_run(vcpu);
-out:
+out_fpu:
kvm_put_guest_fpu(vcpu);
+out:
if (vcpu->run->kvm_valid_regs)
store_regs(vcpu);
post_kvm_run_save(vcpu);
--
2.7.4
Powered by blists - more mailing lists