From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 4/5] KVM: Lazify fpu activation and deactivation Date: Tue, 5 Jan 2010 22:25:29 -0200 Message-ID: <20100106002529.GA11233@amt.cnet> References: <1262190342-18611-1-git-send-email-avi@redhat.com> <1262190342-18611-5-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Sheng Yang , Joerg Roedel , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:65458 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754840Ab0AFAlk (ORCPT ); Tue, 5 Jan 2010 19:41:40 -0500 Content-Disposition: inline In-Reply-To: <1262190342-18611-5-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Dec 30, 2009 at 06:25:41PM +0200, Avi Kivity wrote: > 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 > +static void svm_fpu_deactivate(struct kvm_vcpu *vcpu) > +{ > + struct vcpu_svm *svm = to_svm(vcpu); > + > + if (npt_enabled) { > + /* hack: npt requires active fpu at this time */ > + vcpu->fpu_active = 1; > + return; > + } Why is that ? > void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) > { > - kvm_x86_ops->vcpu_put(vcpu); > kvm_put_guest_fpu(vcpu); > + kvm_x86_ops->vcpu_put(vcpu); > } It might be possible to defer host FPU restoration to user-return-notifier/kernel_fpu_begin time, so you'd keep the guest FPU loaded across qemukvm->kernel task->qemukvm switches. Not sure if its worthwhile though.