Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753169AbbETHPE (ORCPT ); Wed, 20 May 2015 03:15:04 -0400 Received: from mga02.intel.com ([134.134.136.20]:54596 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222AbbETHO4 convert rfc822-to-8bit (ORCPT ); Wed, 20 May 2015 03:14:56 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,463,1427785200"; d="scan'208";a="728841955" From: "Li, Liang Z" To: Paolo Bonzini , "Zhang, Yang Z" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "gleb@kernel.or" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" Subject: RE: [PATCH] kvm/fpu: Enable eager restore kvm FPU for MPX Thread-Topic: [PATCH] kvm/fpu: Enable eager restore kvm FPU for MPX Thread-Index: AQHQkqcPrsLgypnp5Uar4t31qfyykZ2DzhaAgAAWjwCAAIjxAA== Date: Wed, 20 May 2015 07:14:50 +0000 Message-ID: References: <1432132539-6194-1-git-send-email-liang.z.li@intel.com> <555C2CA6.6040906@redhat.com> In-Reply-To: <555C2CA6.6040906@redhat.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1518 Lines: 43 > > Is it better to use guest_cpuid_has_mpx() instead of > vmx_mpx_supported()? > > CPUID hasn't been set yet, so I think it is okay to key it on > vmx_mpx_supported(). It will be deactivated soon afterwards. > > Or even do it unconditionally; just make sure to add a comment about it. > > >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index > >> 5f38188..5993f5f > >> 100644 > >> --- a/arch/x86/kvm/x86.c > >> +++ b/arch/x86/kvm/x86.c > >> @@ -7060,7 +7060,8 @@ void kvm_put_guest_fpu(struct kvm_vcpu > *vcpu) > >> fpu_save_init(&vcpu->arch.guest_fpu); > >> __kernel_fpu_end(); > >> ++vcpu->stat.fpu_reload; > >> - kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu); > >> + if (!kvm_x86_ops->mpx_supported()) > >> + kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu); > >> trace_kvm_fpu(0); > >> } > > This is a hotter path. Here it's definitely better to avoid the call to > kvm_x86_ops->mpx_supported(). Especially because, with MPX enabled, > you would call this on every userspace exit. > > Yang's suggestion of using CPUID is actually more valuable here. You could > add a new field eager_fpu in kvm->arch and update it in kvm_update_cpuid. Thanks for your comments. I will change the code according to your suggestion. > Thanks, > > Paolo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/