diff options
author | Avi Kivity <avi@redhat.com> | 2009-12-30 05:40:26 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2010-03-01 10:35:50 -0500 |
commit | 02daab21d94dc4cf01b2fd09863d59a436900322 (patch) | |
tree | e7caff282dd9019e1b19cd549609c6b991f29152 /arch/x86/kvm/x86.c | |
parent | e8467fda83cdc9de53972fee0cd2e6916cf66f41 (diff) |
KVM: Lazify fpu activation and deactivation
Defer fpu deactivation as much as possible - if the guest fpu is loaded, keep
it loaded until the next heavyweight exit (where we are forced to unload it).
This reduces unnecessary exits.
We also defer fpu activation on clts; while clts signals the intent to use the
fpu, we can't be sure the guest will actually use it.
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 748b15d8e46d..1de2ad7a004d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -1509,8 +1509,8 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
1509 | 1509 | ||
1510 | void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) | 1510 | void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) |
1511 | { | 1511 | { |
1512 | kvm_x86_ops->vcpu_put(vcpu); | ||
1513 | kvm_put_guest_fpu(vcpu); | 1512 | kvm_put_guest_fpu(vcpu); |
1513 | kvm_x86_ops->vcpu_put(vcpu); | ||
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | static int is_efer_nx(void) | 1516 | static int is_efer_nx(void) |
@@ -4006,6 +4006,10 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) | |||
4006 | r = 0; | 4006 | r = 0; |
4007 | goto out; | 4007 | goto out; |
4008 | } | 4008 | } |
4009 | if (test_and_clear_bit(KVM_REQ_DEACTIVATE_FPU, &vcpu->requests)) { | ||
4010 | vcpu->fpu_active = 0; | ||
4011 | kvm_x86_ops->fpu_deactivate(vcpu); | ||
4012 | } | ||
4009 | } | 4013 | } |
4010 | 4014 | ||
4011 | preempt_disable(); | 4015 | preempt_disable(); |
@@ -5075,6 +5079,7 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) | |||
5075 | kvm_fx_save(&vcpu->arch.guest_fx_image); | 5079 | kvm_fx_save(&vcpu->arch.guest_fx_image); |
5076 | kvm_fx_restore(&vcpu->arch.host_fx_image); | 5080 | kvm_fx_restore(&vcpu->arch.host_fx_image); |
5077 | ++vcpu->stat.fpu_reload; | 5081 | ++vcpu->stat.fpu_reload; |
5082 | set_bit(KVM_REQ_DEACTIVATE_FPU, &vcpu->requests); | ||
5078 | } | 5083 | } |
5079 | EXPORT_SYMBOL_GPL(kvm_put_guest_fpu); | 5084 | EXPORT_SYMBOL_GPL(kvm_put_guest_fpu); |
5080 | 5085 | ||